Skip to content

Commit

Permalink
Merge branch 'staging/modVars' of git://github.com/jimmielin/geos-che…
Browse files Browse the repository at this point in the history
…m into dev/12.8.2

This merges Haipeng Lin's updates to move certain module variables
into global objects State_Met and State_Chm.  This is necessary for
interfacing GEOS-Chem into external modules such as WRF or CESM2.

Signed-off-by: Bob Yantosca <[email protected]>
  • Loading branch information
yantosca committed May 26, 2020
2 parents 535cbfe + 941d524 commit 4ad1815
Show file tree
Hide file tree
Showing 12 changed files with 385 additions and 490 deletions.
20 changes: 0 additions & 20 deletions GeosCore/cleanup.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ SUBROUTINE CLEANUP( Input_Opt, State_Grid, ERROR, RC )
USE PRESSURE_MOD, ONLY : CLEANUP_PRESSURE
USE Regrid_A2A_Mod, ONLY : Cleanup_Map_A2a
USE SEASALT_MOD, ONLY : CLEANUP_SEASALT
USE Set_Global_CH4_Mod, ONLY : Cleanup_Set_Global_CH4
USE SULFATE_MOD, ONLY : CLEANUP_SULFATE
USE State_Grid_Mod, ONLY : GrdState
USE STRAT_CHEM_MOD, ONLY : CLEANUP_STRAT_CHEM
USE TAGGED_CO_MOD, ONLY : CLEANUP_TAGGED_CO
USE UCX_MOD, ONLY : CLEANUP_UCX
USE WETSCAV_MOD, ONLY : CLEANUP_WETSCAV
USE EMISSIONS_MOD, ONLY : EMISSIONS_FINAL
USE SFCVMR_MOD, ONLY : FixSfcVmr_Final
#ifdef BPCH_DIAG
Expand All @@ -63,7 +61,6 @@ SUBROUTINE CLEANUP( Input_Opt, State_Grid, ERROR, RC )
#ifdef TOMAS
USE TOMAS_MOD, ONLY : CLEANUP_TOMAS !sfarina, 1/16/13
#endif
USE TOMS_MOD, ONLY : CLEANUP_TOMS
USE TPCORE_FVDAS_MOD, ONLY : EXIT_TPCORE
USE TPCORE_WINDOW_MOD, ONLY : EXIT_TPCORE_WINDOW
#if !defined( ESMF_ ) && !defined( MODEL_ )
Expand Down Expand Up @@ -156,7 +153,6 @@ SUBROUTINE CLEANUP( Input_Opt, State_Grid, ERROR, RC )
CALL CLEANUP_PJC_PFIX()
CALL CLEANUP_PRESSURE()
CALL CLEANUP_SEASALT()
Call Cleanup_Set_Global_CH4()
CALL CLEANUP_SULFATE()
CALL CLEANUP_STRAT_CHEM()

Expand All @@ -181,22 +177,6 @@ SUBROUTINE CLEANUP( Input_Opt, State_Grid, ERROR, RC )
RETURN
ENDIF

! Cleanup TOMS module
CALL CLEANUP_TOMS( RC )
IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Error encountered in "Cleanup_TOMS"!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

! Cleanup wet scavenging module
CALL CLEANUP_WETSCAV( RC )
IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Error encountered in "Cleanup_Wetscav"!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

IF ( State_Grid%NestedGrid ) THEN
CALL EXIT_TPCORE_WINDOW()
ELSE
Expand Down
2 changes: 1 addition & 1 deletion GeosCore/fast_jx_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ SUBROUTINE FAST_JX( WLAOD, Input_Opt, State_Chm, State_Diag, &
! Overhead ozone column [DU] at (NLON, NLAT)
! These values are either from the met fields or TOMS/SBUV,
! depending on the settings in input.geos
O3_TOMS = GET_OVERHEAD_O3( NLON, NLAT )
O3_TOMS = GET_OVERHEAD_O3( State_Chm, NLON, NLAT )

! CTM ozone densities (molec/cm3) at (NLON, NLAT)
O3_CTM = 0e+0_fp
Expand Down
11 changes: 0 additions & 11 deletions GeosCore/gc_environment_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ SUBROUTINE GC_Init_Extra( Diag_List, Input_Opt, State_Chm, &
USE Sulfate_Mod, ONLY : Init_Sulfate
USE Tagged_CO_Mod, ONLY : Init_Tagged_CO
USE Tagged_O3_Mod, ONLY : Init_Tagged_O3
USE Toms_Mod, ONLY : Init_Toms
USE Vdiff_Pre_Mod, ONLY : Set_Vdiff_Values
USE WetScav_Mod, ONLY : Init_WetScav
#ifdef BPCH_DIAG
Expand Down Expand Up @@ -651,16 +650,6 @@ SUBROUTINE GC_Init_Extra( Diag_List, Input_Opt, State_Chm, &
ENDIF
ENDIF

!-----------------------------------------------------------------
! Initialize "toms_mod.F90"
!-----------------------------------------------------------------
CALL Init_Toms( Input_Opt, State_Chm, State_Diag, State_Grid, RC )
IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Error encountered in "Init_Toms"!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

!=================================================================
! Initialize specialty simulation modules here
!=================================================================
Expand Down
4 changes: 2 additions & 2 deletions GeosCore/main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ PROGRAM GEOS_Chem
IF ( Input_Opt%USE_TOMS_O3 ) THEN
! Get TOMS overhead O3 columns for photolysis from
! the HEMCO data structure (bmy, 3/20/15)
CALL Read_TOMS( Input_Opt, RC )
CALL Read_TOMS( Input_Opt, State_Chm, RC )

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
Expand Down Expand Up @@ -2560,7 +2560,7 @@ SUBROUTINE Get_Overhead_O3_For_FastJ( Input_Opt, State_Grid, State_Met )

! Get the overhead O3 column for FAST-J. Take either the
! TOMS O3 data or the column O3 directly from the met fields
CALL Compute_Overhead_O3( Input_Opt, State_Grid, DAY, &
CALL Compute_Overhead_O3( Input_Opt, State_Grid, State_Chm, DAY, &
Input_Opt%USE_O3_FROM_MET, &
State_Met%TO3 )
ENDIF
Expand Down
2 changes: 1 addition & 1 deletion GeosCore/rrtmg_rad_transfer_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ SUBROUTINE DO_RRTMG_RAD_TRANSFER( ThisDay, ThisMonth, &
! Overhead ozone column [DU]
! These values are either from the met fields or TOMS/SBUV,
! depending on the settings in input.geos
O3COL = GET_OVERHEAD_O3(I,J)
O3COL = GET_OVERHEAD_O3(State_Chm, I,J)

! CTM ozone densities (molec/cm3)
O3_CTM = 0d0
Expand Down
45 changes: 4 additions & 41 deletions GeosCore/set_global_ch4_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@ MODULE Set_Global_CH4_Mod
! !PUBLIC MEMBER FUNCTIONS:
!
PUBLIC :: Set_CH4
PUBLIC :: Cleanup_Set_Global_CH4
!
! !REVISION HISTORY:
! 18 Jan 2018 - M. Sulprizio- Initial version
! See https://github.com/geoschem/geos-chem for complete history
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !PRIVATE TYPES:
!
REAL(f4), POINTER :: SFC_CH4(:,:) => NULL() ! Global surface CH4

CONTAINS
!EOC
!------------------------------------------------------------------------------
Expand Down Expand Up @@ -121,7 +115,6 @@ SUBROUTINE Set_CH4( Input_Opt, State_Chm, State_Diag, State_Grid, &
CHARACTER(LEN=255) :: ThisLoc

! SAVEd variables
LOGICAL, SAVE :: FIRST = .TRUE.
INTEGER, SAVE :: id_CH4

!=================================================================
Expand All @@ -138,18 +131,18 @@ SUBROUTINE Set_CH4( Input_Opt, State_Chm, State_Diag, State_Grid, &
RETURN
ENDIF

IF ( FIRST ) THEN
IF ( .not. ASSOCIATED( State_Chm%SFC_CH4 ) ) THEN

! Get species ID
id_CH4 = Ind_( 'CH4' )

! Use the NOAA spatially resolved data where available
CALL HCO_GetPtr( HcoState, 'NOAA_GMD_CH4', SFC_CH4, RC, FOUND=FOUND )
CALL HCO_GetPtr( HcoState, 'NOAA_GMD_CH4', State_Chm%SFC_CH4, RC, FOUND=FOUND )
IF (.NOT. FOUND ) THEN
FOUND = .TRUE.
! Use the CMIP6 data from Meinshausen et al. 2017, GMD
! https://doi.org/10.5194/gmd-10-2057-2017a
CALL HCO_GetPtr( HcoState, 'CMIP6_Sfc_CH4', SFC_CH4, RC, FOUND=FOUND )
CALL HCO_GetPtr( HcoState, 'CMIP6_Sfc_CH4', State_Chm%SFC_CH4, RC, FOUND=FOUND )
ENDIF
IF (.NOT. FOUND ) THEN
ErrMsg = 'Cannot get pointer to NOAA_GMD_CH4 or CMIP6_Sfc_CH4 ' // &
Expand All @@ -160,9 +153,6 @@ SUBROUTINE Set_CH4( Input_Opt, State_Chm, State_Diag, State_Grid, &
RETURN
ENDIF

! Reset first-time flag
FIRST = .FALSE.

ENDIF

! Convert species to [v/v dry] for this routine
Expand Down Expand Up @@ -198,7 +188,7 @@ SUBROUTINE Set_CH4( Input_Opt, State_Chm, State_Diag, State_Grid, &
PBL_TOP = CEILING( State_Met%PBL_TOP_L(I,J) )

! Surface CH4 from HEMCO is in units [ppbv], convert to [v/v dry]
CH4 = SFC_CH4(I,J) * 1e-9_fp
CH4 = State_Chm%SFC_CH4(I,J) * 1e-9_fp

#if defined( MODEL_GEOS )
! Zero diagnostics
Expand Down Expand Up @@ -245,31 +235,4 @@ SUBROUTINE Set_CH4( Input_Opt, State_Chm, State_Diag, State_Grid, &

END SUBROUTINE Set_CH4
!EOC
!------------------------------------------------------------------------------
! GEOS-Chem Global Chemical Transport Model !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: cleanup_set_global_ch4
!
! !DESCRIPTION: Subroutine CLEANUP\_SET\_GLOBAL\_CH4 deallocates memory from
! previously allocated module arrays.
!\\
!\\
! !INTERFACE:
!
SUBROUTINE Cleanup_Set_Global_CH4
!
! !REVISION HISTORY:
! 18 Jan 2018 - M. Sulprizio- Initial version
! See https://github.com/geoschem/geos-chem for complete history
!EOP
!------------------------------------------------------------------------------
!BOC

! Free pointers
SFC_CH4 => NULL()

END SUBROUTINE Cleanup_Set_Global_CH4
!EOC
END MODULE Set_Global_CH4_Mod
6 changes: 5 additions & 1 deletion GeosCore/sulfate_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5812,7 +5812,6 @@ SUBROUTINE CHEM_SO4( Input_Opt, State_Chm, State_Diag, State_Grid, &
USE APM_INIT_MOD, ONLY : IFEMITBCOCS
USE APM_DRIV_MOD, ONLY : PSO4GAS
USE APM_DRIV_MOD, ONLY : FCLOUD
USE WETSCAV_MOD, ONLY : PSO4_SO2APM2
#endif
!
! !INPUT PARAMETERS:
Expand Down Expand Up @@ -5859,6 +5858,9 @@ SUBROUTINE CHEM_SO4( Input_Opt, State_Chm, State_Diag, State_Grid, &

! Pointers
REAL(fp), POINTER :: Spc(:,:,:,:)
#ifdef APM
REAL(fp), POINTER :: PSO4_SO2APM2(:,:,:)
#endif

#ifdef APM
REAL*8 :: MASS0, MASS, PMASS
Expand All @@ -5885,6 +5887,8 @@ SUBROUTINE CHEM_SO4( Input_Opt, State_Chm, State_Diag, State_Grid, &
CALL WET_SETTLINGBIN( Input_Opt, State_Chm, State_Diag, State_Grid, &
State_Met, RC )

! Point to PSO4_SO2APM2 now moved to State_Met
PSO4_SO2APM2 => State_Met%PSO4_SO2APM2
#endif

! Point to chemical species array [kg]
Expand Down
Loading

0 comments on commit 4ad1815

Please sign in to comment.