Skip to content

Commit

Permalink
Update calls to Convert_Spc_Units in GeosCore and Interfaces subdirs
Browse files Browse the repository at this point in the history
This commit updates the various calls to Convert_Spc_Units in modules
throughout the GeosCore/*.F90, Interfaces/GCHP/*.F90, and
Interfaces/GEOS/*.F90.  Updates include:

- Adding the "mapping" argument to pass one of the State_Chm%Map_*
  arrays.  This is the list of modelId's for each species.
- Renaming "outUnit" -> "new_units"
- Renaming "origUnit" -> "previous_units

NOTE: Some additional work will be needed, as some code (mostly
in TOMAS) still relies on the old State_Chm%Spc_Units variable.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Dec 11, 2023
1 parent 7d98e79 commit 31cc208
Show file tree
Hide file tree
Showing 22 changed files with 305 additions and 249 deletions.
20 changes: 11 additions & 9 deletions GeosCore/aerosol_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ SUBROUTINE AEROSOL_CONC( Input_Opt, State_Chm, State_Diag, &
REAL(fp), POINTER :: KG_STRAT_AER(:,:,:,:)

! Other variables
INTEGER :: OrigUnit
INTEGER :: previous_units


! For spatially and seasonally varying OM/OC
Expand Down Expand Up @@ -305,13 +305,14 @@ SUBROUTINE AEROSOL_CONC( Input_Opt, State_Chm, State_Diag, &

! Convert species to [kg] for this routine
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = KG_SPECIES, &
origUnit = origUnit, &
RC = RC )
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
new_units = KG_SPECIES, &
mapping = State_Chm%Map_Advect, &
previous_units = previous_units &
RC = RC )

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
Expand Down Expand Up @@ -1023,7 +1024,8 @@ SUBROUTINE AEROSOL_CONC( Input_Opt, State_Chm, State_Diag, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = origUnit, &
mapping = State_Chm%Map_Advect, &
new_units = previous_units, &
RC = RC )

IF ( RC /= GC_SUCCESS ) THEN
Expand Down
20 changes: 11 additions & 9 deletions GeosCore/airs_ch4_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ SUBROUTINE CALC_AIRS_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &
INTEGER :: IOS
INTEGER, SAVE :: TotalObs = 0
CHARACTER(LEN=255) :: FILENAME
INTEGER :: origUnit
INTEGER :: previous_units
CHARACTER(LEN=255) :: ThisLoc
CHARACTER(LEN=512) :: ErrMsg
INTEGER :: RC
Expand Down Expand Up @@ -518,13 +518,14 @@ SUBROUTINE CALC_AIRS_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &

! Convert species units to [v/v] (mps, 6/12/2020)
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = MOLES_SPECIES_PER_MOLES_DRY_AIR, &
origUnit = origUnit, &
RC = RC )
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_Advect, &
new_units = MOLES_SPECIES_PER_MOLES_DRY_AIR, &
previous_units = previous_units, &
RC = RC )

IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Unit conversion error (kg/kg dry -> v/v dry)'
Expand Down Expand Up @@ -699,7 +700,8 @@ SUBROUTINE CALC_AIRS_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = origUnit, &
mapping = State_Chm%Map_Advect, &
new_units = previous_units, &
RC = RC )

! Trap errors
Expand Down
22 changes: 12 additions & 10 deletions GeosCore/carbon_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4968,7 +4968,7 @@ SUBROUTINE EMISSCARBONTOMAS( Input_Opt, State_Chm, State_Grid, State_Met, RC )
LOGICAL :: SGCOAG = .True.
INTEGER :: L, K, EMTYPE
INTEGER :: ii=53, jj=29
INTEGER :: origUnit
INTEGER :: previous_units
LOGICAL, SAVE :: FIRST = .TRUE. !(ramnarine 12/27/2018)
LOGICAL, SAVE :: USE_FIRE_NUM = .FALSE.
LOGICAL :: FND !(ramnarine 1/2/2019)
Expand Down Expand Up @@ -5029,14 +5029,15 @@ SUBROUTINE EMISSCARBONTOMAS( Input_Opt, State_Chm, State_Grid, State_Met, RC )
! Convert concentration units to [kg] for TOMAS. This will be
! removed once TOMAS uses mixing ratio instead of mass
! as species units (ewl, 9/11/15)
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = KG_SPECIES, &
origUnit = origUnit, &
RC = RC )
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_Advect, &
new_units = KG_SPECIES, &
previous_units = previous_units, &
RC = RC )

! Trap errors
IF ( RC /= GC_SUCCESS ) THEN
Expand Down Expand Up @@ -5266,7 +5267,8 @@ SUBROUTINE EMISSCARBONTOMAS( Input_Opt, State_Chm, State_Grid, State_Met, RC )
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = origUnit, &
mapping = State_Chm%Map_Advect, &
new_units = previous_units, &
RC = RC )

! Trap errors
Expand Down
45 changes: 20 additions & 25 deletions GeosCore/chemistry_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &
LOGICAL, SAVE :: FIRST = .TRUE.

! Strings
INTEGER :: OrigUnit
INTEGER :: previous_units
CHARACTER(LEN=255) :: ErrMsg, ThisLoc

!=======================================================================
Expand Down Expand Up @@ -205,13 +205,14 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &

! Convert units from mol/mol dry to kg
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = KG_SPECIES, &
origUnit = origUnit, &
RC = RC )
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_All, &
new_units = KG_SPECIES, &
previous_units = previous_units, &
RC = RC )

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
Expand Down Expand Up @@ -455,17 +456,10 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &
errCode = RC )

! Check units (ewl, 10/5/15)
IF ( State_Chm%Spc_Units /= KG_SPECIES ) THEN
ErrMsg = 'Incorrect species units after DO_LINEARCHEM!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
ENDIF

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Error encountered in ""!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF
!IF ( State_Chm%Spc_Units /= KG_SPECIES ) THEN
! ErrMsg = 'Incorrect species units after DO_LINEARCHEM!'
! CALL GC_Error( ErrMsg, RC, ThisLoc )
!ENDIF

IF ( Input_Opt%useTimers ) THEN
CALL Timer_End( "=> Linearized chem", RC )
Expand Down Expand Up @@ -548,11 +542,11 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &
FullRun = .TRUE., &
RC = RC )

! Check units (ewl, 10/5/15)
IF ( State_Chm%Spc_Units /= KG_SPECIES ) THEN
ErrMsg = 'Incorrect species units after CHEMSULFATE!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
ENDIF
!! Check units (ewl, 10/5/15)
!IF ( State_Chm%Spc_Units /= KG_SPECIES ) THEN
! ErrMsg = 'Incorrect species units after CHEMSULFATE!'
! CALL GC_Error( ErrMsg, RC, ThisLoc )
!ENDIF

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
Expand Down Expand Up @@ -1081,7 +1075,8 @@ SUBROUTINE Do_Chemistry( Input_Opt, State_Chm, State_Diag, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = origUnit, &
mapping = State_Chm%Map_All, &
new_units = previous_units, &
RC = RC )

! Trap potential errors
Expand Down
18 changes: 10 additions & 8 deletions GeosCore/fullchem_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,14 @@ SUBROUTINE Do_FullChem( Input_Opt, State_Chm, State_Diag, &
! Convert species to [molec/cm3] (ewl, 8/16/16)
!========================================================================
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = MOLECULES_SPECIES_PER_CM3, &
origUnit = origUnit, &
RC = RC )
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_All, &
new_units = MOLECULES_SPECIES_PER_CM3, &
previous_units = previous_units, &
RC = RC )

IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Unit conversion error!'
Expand Down Expand Up @@ -1731,7 +1732,8 @@ SUBROUTINE Do_FullChem( Input_Opt, State_Chm, State_Diag, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = origUnit, &
mapping = State_Chm%Map_All, &
new_units = previous_units, &
RC = RC )

IF ( RC /= GC_SUCCESS ) THEN
Expand Down
20 changes: 11 additions & 9 deletions GeosCore/gosat_ch4_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ SUBROUTINE CALC_GOSAT_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &
INTEGER :: IIJJ(2), I, J, N
INTEGER :: L, LL, LGOS
INTEGER :: JLOOP, NOBS, IND
INTEGER :: origUnit
INTEGER :: previous_units
INTEGER :: INDS(MAXGOS)
REAL(fp) :: REF_DATE, TIME
REAL(fp) :: GC_PRES(State_Grid%NZ)
Expand Down Expand Up @@ -584,13 +584,14 @@ SUBROUTINE CALC_GOSAT_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &

! Convert species units to [v/v dry] aka [mol/mol dry]
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = MOLES_SPECIES_PER_MOLES_DRY_AIR, &
origUnit = origUnit, &
RC = RC )
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_Advect, &
new_units = MOLES_SPECIES_PER_MOLES_DRY_AIR, &
previous_units = previous_units, &
RC = RC )

IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Unit conversion error (kg/kg dry -> v/v dry)'
Expand Down Expand Up @@ -945,7 +946,8 @@ SUBROUTINE CALC_GOSAT_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = origUnit, &
mapping = State_Chm%Map_Advect, &
new_units = previous_units, &
RC = RC )

IF ( RC /= GC_SUCCESS ) THEN
Expand Down
22 changes: 12 additions & 10 deletions GeosCore/hco_interface_gc_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4605,7 +4605,7 @@ SUBROUTINE Compute_Sflx_for_Vdiff( Input_Opt, State_Chm, State_Diag, &
INTEGER :: L, NA
INTEGER :: ND, N
INTEGER :: Hg_Cat, topMix
INTEGER :: S, origUnit
INTEGER :: S, previous_units
REAL(fp) :: dep, emis
REAL(fp) :: MW_kg, fracNoHg0Dep
REAL(fp) :: tmpFlx
Expand Down Expand Up @@ -4660,14 +4660,15 @@ SUBROUTINE Compute_Sflx_for_Vdiff( Input_Opt, State_Chm, State_Diag, &
!=======================================================================
! Convert units to [v/v dry] aka [mol/mol dry]
!=======================================================================
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = MOLES_SPECIES_PER_MOLES_DRY_AIR, &
origUnit = origUnit, &
RC = RC )
CALL Convert_Spc_Units(
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_Advect, &
outUnit = MOLES_SPECIES_PER_MOLES_DRY_AIR, &
previous_units = previous_units, &
RC = RC )

! Trap potential error
IF ( RC /= GC_SUCCESS ) THEN
Expand Down Expand Up @@ -5124,7 +5125,8 @@ SUBROUTINE Compute_Sflx_for_Vdiff( Input_Opt, State_Chm, State_Diag, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
outUnit = origUnit, &
mapping = State_Chm%Map_Advect, &
new_units = previous_units, &
RC = RC )

! Trap potential errors
Expand Down
Loading

0 comments on commit 31cc208

Please sign in to comment.