GEOS-ESM / GEOS-ESM/GEOSgcm_GridComp

Constants Inconsistency in New Physics Moist

Open
#661 1 comment 0 reactions 2 assignees View on GitHub

@sdrabenh is already working on this.

Since Oct 28, 2022.

bug
Dominant language
Fortran
Stars
10
Forks
13
Avg merge
17h 35m
Merged PRs (30d)
14

Description

Recently, as a test, I tried to build the feature/sdrabenh/merge_v10.23.0_MSTRF branch that @sdrabenh is using to track the new Physics with GNU instead of Intel and it threw out a number of issues.

One is a simple Fortran standard violation here:
https://github.com/GEOS-ESM/GEOSgcm_GridComp/blob/d4b64898ef763c52204960981c074f98a3391a74/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/ConvPar_GF2020.F90#L11525
which should be:

       if(versionx==1 .or. COUPL_MPHYSICS .eqv. .false.) then

But the more exciting issues come after that.

First, we have:

/discover/swdev/mathomp4/Models/GEOSgcm-ScottBranch-GNU/GEOSgcm/src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/Process_Library.F90:32:26:

   13 |   use Aer_Actv_Single_Moment
      |      2
......
   32 |   real, parameter :: R_AIR   =  3.47e-3   ! m3 Pa kg-1K-1
      |                          1
Error: Symbol 'r_air' at (1) conflicts with symbol from module 'aer_actv_single_moment', use-associated at (2)

The issue here is that both aer_actv_single_moment.F90 and Process_Library.F90 provide R_AIR. You can "solve" this by removing R_AIR from aer_actv_single_moment.F90 but there is still the fact that R_AIR is defined a few times in moist:

cloudnew.F90
351:   real, parameter :: R_AIR = 3.47e-3 !m3 Pa kg-1K-1

Process_Library.F90
32:  real, parameter :: R_AIR   =  3.47e-3   ! m3 Pa kg-1K-1

GEOS_MGB2_2M_InterfaceMod.F90
617:      real, parameter :: r_air = 3.47d-3 !m3 Pa kg-1K-1

cldmacro.F90
68:   real, parameter :: R_AIR = 3.47e-3 !m3 Pa kg-1K-1

aer_actv_single_moment.F90
18:       real        , parameter :: R_AIR     =  3.47e-3 !m3 Pa kg-1K-1

The "good" news is that they are all the same value (well, the MGB2 one is REAL64) but they are all the same. Still, probably best to be defined in one place. NOTE: I'm not sure if this is a constant in MAPL or not (nothing in MAPL screams 0.00347).

For now, let's move past R_AIR and see what GNU flags next...

/discover/swdev/mathomp4/Models/GEOSgcm-ScottBranch-GNU/GEOSgcm/src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/ConvPar_GF_GEOS5.F90:63:6:

   16 | USE ConvPar_GF_SharedParams
      |    2
......
   63 |   rgas    = 287.,    & ! J K-1 kg-1
      |      1
Error: Symbol 'rgas' at (1) conflicts with symbol from module 'convpar_gf_sharedparams', use-associated at (2)

Again, something similar, rgas is defined too many places. But this one is worse. Moist has a few values of rgas:

Process_Library.F90
431:       RHO = 100.*PL / (MAPL_RGAS*TE )
1277:                              rgas   => MAPL_RGAS,   &

cldwat2m_micro.F90
57:   real(r8), parameter :: rair        = MAPL_RGAS

ConvPar_GF2020.F90
7862:      PKE      = (PLE/MAPL_P00)**(MAPL_RGAS/MAPL_CP)
7863:      PK       = (PLO/MAPL_P00)**(MAPL_RGAS/MAPL_CP)
7881:        ,   rgas     = 287.               &

ConvPar_GF_GEOS5.F90
63:  rgas    = 287.,    & ! J K-1 kg-1
7506:        ,   rgas     = 287.               &

micro_mg3_0.F90
207:   real(r8), parameter :: rair        = MAPL_RGAS

ConvPar_GF_Shared.F90
68:  rgas    = 287.,    & ! J K-1 kg-1
237:  real, parameter:: rgas  =  8.205e-2 ! atm M^-1 K^-1 ! 8.314 gas constant [J/(mol*K)]

aer_actv_single_moment.F90
446:      real(AER_PR), parameter :: rgasjmol = 8.31451d+00         ! [j/mol/k]

cldmacro.F90
17:         MAPL_RGAS , MAPL_H2OMW, &
65:   real, parameter :: ZVIR = MAPL_RVAP/MAPL_RGAS - 1.
66:   real, parameter :: GORD = MAPL_GRAV/MAPL_RGAS

uwshcu.F90
59:   real, parameter :: r     = MAPL_RGAS             ! Gas constant for dry air

aer_cloud.F90
151:      data rgas_par    /8.31d0/                  ! universal gas constant
169:      DATA rgas_ice /8.314d0/  ! Universal gas constant

Some routines use MAPL_RGAS but some (GF) have their own of just 287. GF2020 uses both!

This is also picking up use of rgas as the universal gas constant in aer_cloud.F90 and aer_actv_single_moment.F90 both of which are different than MAPL_RUNIV.

I think this issue might be more wide spread. For example in GF code you often see:

    real, parameter :: &
            cpg      = 102.45             &
        ,   rgas     = 287.               &
        ,   cp       = 1004.              &
        ,   p00      = 1.e5               &
        ,   g        = 9.80               &
        ,   rocp     = rgas / cp          &
        ,   p00i     = 1. / p00           &
        ,   cpor     = cp / rgas          &
        ,   cpi      = 1. / cp            &
        ,   p00k     = 26.870941          &  !  = p00 ** rocp
        ,   p00ki    = 1. / p00k

and I have to think many of these are MAPL_ constants. I mean, I know g is as MAPL_GRAV and there are a few other g in Moist as well:

gfdl_cloud_microphys.F90
71:    real, parameter :: grav = 9.80665 !< gfs: acceleration due to gravity

aer_cloud.F90
150:      data grav_par    /9.81d0/                  ! g constant
170:      DATA grav_ice /9.81d0/  ! gravity

ConvPar_GF_GEOS5.F90
7509:        ,   g        = 9.80               &

ConvPar_GF2020.F90
7884:        ,   g        = 9.80               &
8388:    real, parameter ::  XG    = 9.80665     ! gravity constant

aer_actv_single_moment.F90
264:                wupdraft           = -9.81*air_den*omega(i,j,k)     ! m/s - grid-scale only
454:      real(AER_PR), parameter :: gravity  = 9.81d+00            ! grav. accel. at the earth's surface [m/s/s]

I'm not sure what to do here. We eventually have to figure out how to get GNU to compile this. But I'm wondering what the "right" thing to do is. Change code to use MAPL_ constants? Only do the bare minimum to let it compile?

CC: @tclune @gmao-ckung

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.