geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
169 stars 165 forks source link

[FEATURE REQUEST] Remove hard-coded State_Grid%MaxTropLev and State_Grid%MaxStratLev #284

Open msulprizio opened 4 years ago

msulprizio commented 4 years ago

The State_Grid%MaxStratLev and State_Grid%MaxTropLev scalars are used in very few places, and can be replaced by State_Met%InStratosphere and State_Met%InTroposphere logicals. This will allow for removal of MaxStratLev and MaxTropLev completely. The State_Grid%MaxChemLev scalar can be moved to State_Met, where the other chemistry grid fields (ChemGridLev, InChemGrid) are stored.

In subroutine AIRQNT (in GeosCore/calc_met_mod.F90), State_Met%InStratosphere can be computed using the threshold of 1 hPa as the stratopause. Seb Eastham wrote, "The value of [MaxStratLev=]59 is actually based on the stratopause being at 1 hPa, so that would be a much better way to define it!" In that routine, we can also compute State_Met%MaxChemLev based on the actual tropopause or stratopause level.

yantosca commented 1 year ago

The State_Grid%MaxTropLev is defined but not used anywhere. We can remove it.

GeosUtil/gc_grid_mod.F90:124:       State_Grid%MaxTropLev  = 38
GeosUtil/gc_grid_mod.F90:127:       State_Grid%MaxTropLev  = 40
GeosUtil/gc_grid_mod.F90:131:       State_Grid%MaxTropLev  = 28
GeosUtil/gc_grid_mod.F90:135:       State_Grid%MaxTropLev  = 60
GeosUtil/gc_grid_mod.F90:139:       State_Grid%MaxTropLev  = 60
GeosUtil/gc_grid_mod.F90:143:                ' does not have MaxTropLev and MaxStratLev defined.'// &
Headers/state_grid_mod.F90:69:     INTEGER            :: MaxTropLev  ! Max # levels below trop
Headers/state_grid_mod.F90:177:    State_Grid%MaxTropLev   = 0

On the other hand, the MaxStratLev is used in a couple of places but we can probably take those out without too much trouble.

GeosCore/calc_met_mod.F90:563:            ( L <= State_Grid%MaxStratLev .and. State_Met%InStratMeso(I,J,L) )
GeosCore/mercury_mod.F90:998:       !IF ( L > State_Grid%MaxStratLev ) CYCLE
GeosCore/mercury_mod.F90:2788:       IF ( L > State_Grid%MaxStratLev ) CYCLE
GeosUtil/gc_grid_mod.F90:125:       State_Grid%MaxStratLev = 44
GeosUtil/gc_grid_mod.F90:128:       State_Grid%MaxStratLev = 59
GeosUtil/gc_grid_mod.F90:132:       State_Grid%MaxStratLev = 40
GeosUtil/gc_grid_mod.F90:136:       State_Grid%MaxStratLev = 72
GeosUtil/gc_grid_mod.F90:140:       State_Grid%MaxStratLev = 91
GeosUtil/gc_grid_mod.F90:143:                ' does not have MaxTropLev and MaxStratLev defined.'// &
GeosUtil/gc_grid_mod.F90:150:    State_Grid%MaxChemLev  = State_Grid%MaxStratLev
Headers/state_grid_mod.F90:68:     INTEGER            :: MaxStratLev ! Max # levels below strat
Headers/state_grid_mod.F90:176:    State_Grid%MaxStratLev  = 0

Tagging @msulprizio @lizziel

yantosca commented 1 year ago

Also State_Grid%MaxChemLev is defined in several places. It is initialized from MaxStratLev. We should probably replace this with State_Grid%NZ

GeosCore/aero_drydep.F90:303:             L     = State_Grid%MaxChemLev
GeosCore/aero_drydep.F90:307:             DO L = State_Grid%MaxChemLev-1, 1, -1
GeosCore/aero_drydep.F90:397:    DO L = 1, State_Grid%MaxChemLev
GeosCore/aerosol_mod.F90:1817:                     L <= State_Grid%MaxChemLev      .AND. &
GeosCore/calc_met_mod.F90:566:       IF ( L > State_Grid%MaxChemLev ) THEN
GeosCore/calc_met_mod.F90:574:          State_Met%InChemGrid(I,J,L) = ( L <= State_Grid%MaxChemLev )
GeosCore/carbon_mod.F90:1813:   DO L = 1, State_Grid%MaxChemLev
GeosCore/carbon_mod.F90:2272:         print*, 'POA to trop', SUM(Spc(id_POA1)%Conc(:,:,1:State_Grid%MaxChemLev))+ &
GeosCore/carbon_mod.F90:2273:                                SUM(Spc(id_POA2)%Conc(:,:,1:State_Grid%MaxChemLev))
GeosCore/carbon_mod.F90:5798:      IF ( L <= State_Grid%MaxChemLev ) THEN
GeosCore/carbon_mod.F90:6541:   DO L = 1, State_Grid%MaxChemLev
GeosCore/carbon_mod.F90:6683:   DO L = 1, State_Grid%MaxChemLev
GeosCore/diagnostics_mod.F90:1382:          State_Diag%SatDiagnOH(I,:,1:State_Grid%MaxChemLev) =               &
GeosCore/diagnostics_mod.F90:1383:               ( Spc(id_OH)%Conc(I,:,1:State_Grid%MaxChemLev) * good  *      &
GeosCore/diagnostics_mod.F90:1384:               State_Met%AIRDEN(I,:,1:State_Grid%MaxChemLev)  * AVO ) /      &
GeosCore/dust_mod.F90:872:          L           = State_Grid%MaxChemLev
GeosCore/dust_mod.F90:877:          DO L = State_Grid%MaxChemLev-1, 1, -1
GeosCore/dust_mod.F90:1480:       DO L = 1, State_Grid%MaxChemLev
GeosCore/dust_mod.F90:1541:          DO L = 1, State_Grid%MaxChemLev
GeosCore/dust_mod.F90:1558:       DO L = 1, State_Grid%MaxChemLev
GeosCore/fast_jx_mod.F90:80:                       ZZJ,       DDJ,        maxChemLev, State_Chm,  &
GeosCore/fast_jx_mod.F90:112:    INTEGER,  INTENT(IN)                       :: maxChemLev
GeosCore/fast_jx_mod.F90:424:    call JRATET(PPJ,T_INPUT,FFF, VALJXX,L_,maxChemLev,NJX)
GeosCore/fjx_interface_mod.F90:617:                      Z_CLIM,    AIR_CLIM,   State_Grid%maxChemLev, &
GeosCore/fjx_interface_mod.F90:622:       DO L=1,State_Grid%MaxChemLev
GeosCore/fjx_interface_mod.F90:633:       IF (State_Grid%MaxChemLev.lt.L_) THEN
GeosCore/fjx_interface_mod.F90:634:          DO L=State_Grid%MaxChemLev+1,L_
GeosCore/fjx_interface_mod.F90:1246:            (I <= State_Grid%MaxChemLev) .and. &
GeosCore/global_br_mod.F90:262:    IF ( State_Grid%MaxChemLev < State_Grid%NZ ) THEN
GeosCore/global_br_mod.F90:263:       J_BrO(:,:,State_Grid%MaxChemLev+1:State_Grid%NZ) = 0e+0_fp 
GeosCore/hco_utilities_gc_mod.F90:1755:            IF ( L > State_Grid%MaxChemLev .and. &
GeosCore/linear_chem_mod.F90:251:    IF ( State_Grid%MaxChemLev == State_Grid%NZ ) THEN
GeosCore/ocean_mercury_mod.F90:385:    SO4_GC(:,:,1:State_Grid%MaxChemLev) = ARRAYso4(:,:,1:State_Grid
MaxChemLev)
GeosCore/ocean_mercury_mod.F90:396:    NH4_CONC(:,:,1:State_Grid%MaxChemLev) = ARRAYnh4(:,:,1:State_Grid%MaxChemLev)
GeosCore/ocean_mercury_mod.F90:407:    NIT_CONC(:,:,1:State_Grid%MaxChemLev) = ARRAYnit(:,:,1:State_Grid%MaxChemLev)
GeosCore/ocean_mercury_mod.F90:432:    BC_CONC(:,:,1:State_Grid%MaxChemLev) = ARRAYtemp(:,:,1:State_Grid%MaxChemLev)
GeosCore/ocean_mercury_mod.F90:457:    OC_CONC(:,:,1:State_Grid%MaxChemLev) = ARRAYtemp(:,:,1:State_Grid%MaxChemLev)
GeosCore/ocean_mercury_mod.F90:468:    DST_CONC(:,:,1:State_Grid%MaxChemLev) = ARRAYdst1(:,:,1:State_Grid%MaxChemLev)
GeosCore/pbl_mix_mod.F90:373:       DO L = 1, State_Grid%MaxChemLev
GeosCore/seasalt_mod.F90:778:       L         = State_Grid%MaxChemLev
GeosCore/seasalt_mod.F90:782:       DO L = State_Grid%MaxChemLev-1, 1, -1
GeosCore/sulfate_mod.F90:1733:       L    = State_Grid%MaxChemLev
GeosCore/sulfate_mod.F90:1738:       DO L = State_Grid%MaxChemLev-1, 1, -1
GeosCore/sulfate_mod.F90:2705:          IF ( L <= State_Grid%MaxChemLev ) THEN
GeosCore/sulfate_mod.F90:8261:      DO L = 1, State_Grid%MaxChemLev
GeosCore/sulfate_mod.F90:8926:    ALLOCATE( PMSA_DMS( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8932:    ALLOCATE( PSO2_DMS( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8938:    ALLOCATE( PSO4_SO2( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8944:    ALLOCATE( PHMS_SO2( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8950:    ALLOCATE( PSO2_HMS( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8956:    ALLOCATE( PSO4_HMS( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8962:    ALLOCATE( PSO4_ss( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8968:    ALLOCATE( PNITs( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), &
GeosCore/sulfate_mod.F90:8974:    ALLOCATE( PNIT( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev), STAT=RC )
GeosCore/sulfate_mod.F90:8979:    ALLOCATE( PACL( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), STAT=RC )
GeosCore/sulfate_mod.F90:8984:    ALLOCATE( PCCL( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev ), STAT=RC )
GeosCore/sulfate_mod.F90:8990:    ALLOCATE( PSO4_dust( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev, &
GeosCore/sulfate_mod.F90:8997:    ALLOCATE( PNIT_dust( State_Grid%NX, State_Grid%NY, State_Grid%MaxChemLev, &
GeosUtil/gc_grid_mod.F90:150:    State_Grid%MaxChemLev  = State_Grid%MaxStratLev
Headers/state_grid_mod.F90:67:     INTEGER            :: MaxChemLev  ! Max # levels in chemistry grid
Headers/state_grid_mod.F90:175:    State_Grid%MaxChemLev   = 0