Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GMI issue related to stOX_loss #235

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Modified TR to only import stOX_loss if loss_species == OX; without this, a GMI _ASSERT may exit the program needlessly.

## [1.10.4] - 2022-11-08
### Added
### Removed
Expand Down
4 changes: 2 additions & 2 deletions TR_GridComp/TR_GridComp---stOX.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Tracer with O3 values in stratosphere, and O3 loss applied in the troposphere
# Tracer with OX values in stratosphere, and OX loss applied in the troposphere
#

# SHOULD THE TRACER SOURCE BE ADDED FIRST, OR THE SINK APPLIED FIRST
Expand All @@ -26,7 +26,7 @@
# ---------------------------
# snk_mode: none
snk_mode: chemical_loss
loss_species: O3
loss_species: OX

# SINK - Horizontal coverage: all | lat_zone | latlon_box
# ---------------------------
Expand Down
46 changes: 36 additions & 10 deletions TR_GridComp/TR_GridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,14 @@ SUBROUTINE SetServices ( GC, RC )
character(len=ESMF_MAXSTR) :: rcfilen
character(len=ESMF_MAXSTR) :: src_mode
character(len=ESMF_MAXSTR) :: snk_mode
character(len=ESMF_MAXSTR) :: loss_species
character(len=ESMF_MAXSTR) :: regions_ExtData_entry
character(len=ESMF_MAXSTR) :: friend_list
logical :: dry_dep
logical :: wet_removal
logical :: gocart_conv
logical :: lai_needed
logical :: stOX_loss_needed

character(len=ESMF_MAXSTR), allocatable :: str_array(:) ! to hold unique ExtData entries
integer :: s_count ! number of entries in str_array
Expand Down Expand Up @@ -832,14 +834,17 @@ SUBROUTINE SetServices ( GC, RC )
RESTART = MAPL_RestartSkip, &
__RC__ )

call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'stOX_loss', &
LONG_NAME = 'loss to apply to strat OX tracer', &
UNITS = 'mole m-3 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
! Only do this conditionally, because GMI needs to run all the QQJ & QQK
! in order to provide it:
!
! call MAPL_AddImportSpec(GC, &
! SHORT_NAME = 'stOX_loss', &
! LONG_NAME = 'loss to apply to strat OX tracer', &
! UNITS = 'mole m-3 s-1', &
! DIMS = MAPL_DimsHorzVert, &
! VLOCATION = MAPL_VLocationCenter, &
! RESTART = MAPL_RestartSkip, &
! __RC__ )

call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'DD_OX', &
Expand Down Expand Up @@ -868,6 +873,7 @@ SUBROUTINE SetServices ( GC, RC )
!! Add EXPORT (WR,WRvsum) specs for tracers subject to Wet Removal
!!
lai_needed = .FALSE.
stOX_loss_needed = .FALSE.

allocate ( str_array( r%nq ), __STAT__ )
s_count = 0
Expand Down Expand Up @@ -1029,6 +1035,13 @@ SUBROUTINE SetServices ( GC, RC )

! END IF

IF ( TRIM(snk_mode) == "chemical_loss" ) THEN
call ESMF_ConfigGetAttribute ( myState%CF, label='loss_species:', value=loss_species, default='NO_SPECIES', __RC__ )
IF( TRIM(loss_species) == "OX") THEN
stOX_loss_needed = .TRUE.
END IF
END IF

call ESMF_ConfigGetAttribute ( myState%CF, label='GOCART_convection:', value=gocart_conv, default=.FALSE., __RC__ )

!MEM
Expand Down Expand Up @@ -1082,6 +1095,19 @@ SUBROUTINE SetServices ( GC, RC )

END IF

! Only import if it's going to be used (expensive!):
IF ( stOX_loss_needed ) THEN

call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'stOX_loss', &
LONG_NAME = 'loss to apply to strat OX tracer', &
UNITS = 'mole m-3 s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RESTART = MAPL_RestartSkip, &
__RC__ )
END IF

! Import the Region Masks
DO n = 1, s_count

Expand Down Expand Up @@ -2769,7 +2795,7 @@ SUBROUTINE TR_init_tracer_spec_ ( tname, tunits, kit, CF, spec, impChem, expChem

call ESMF_ConfigGetAttribute ( CF, label='loss_species:', value=spec%loss_species, __RC__ )

IF( TRIM(spec%loss_species) == "O3") THEN
IF( TRIM(spec%loss_species) == "OX") THEN
! OK
ELSE
IF(MAPL_AM_I_ROOT()) PRINT *,myname,": Invalid loss_species specified for TRACER snk."
Expand Down Expand Up @@ -4174,7 +4200,7 @@ SUBROUTINE TR_run_tracer_ ( pet, kit, spec_array, spec, qa, grid_esmf, impChem,

!CL CALL MAPL_GetPointer( expChem, cl_export_3d, 'CL_'//TRIM(spec%name), __RC__ )

IF ( TRIM(spec%loss_species) == 'O3' ) THEN
IF ( TRIM(spec%loss_species) == 'OX' ) THEN

! Use volume mixing ratio
data_double = DBLE(DATA3d)
Expand Down