Skip to content

Commit

Permalink
Merge pull request #33 from jimmielin/feature/timers
Browse files Browse the repository at this point in the history
Detailed process timers for GEOS-Chem chemistry.F90
  • Loading branch information
lizziel authored Jun 24, 2024
2 parents 98b260f + a2624d0 commit 4126267
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions src/chemistry/geoschem/chemistry.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
LOGICAL :: lastChunk
INTEGER :: RC

call t_startf('GEOSChem_All_Tend')

! Initialize pointers
SpcInfo => NULL()
Expand All @@ -2082,6 +2083,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
pbuf_ik => NULL()
pbuf_i => NULL()

call t_startf('GEOSChem_CAM_Interfacing')
! LCHNK: which chunk we have on this process
LCHNK = state%LCHNK
! NCOL: number of atmospheric columns on this chunk
Expand Down Expand Up @@ -2250,6 +2252,11 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
State_Chm(LCHNK)%Species(M)%Conc(1,:nY,:nZ) = REAL(SlsData(:nY,nZ:1:-1,N),fp)
ENDDO

call t_stopf('GEOSChem_CAM_Interfacing')

! We want to put t_startf timers outside of C-preprocessor flags
! in order to always have these timers present even if zero. (hplin, 4/30/24)
call t_startf('GEOSChem_MAM_Interfacing')
#if defined( MODAL_AERO )
! NOTE: GEOS-Chem bulk aerosol concentrations (BCPI, BCPO, SO4, ...) are ZEROED OUT
! here in order to be reconstructed from the modal concentrations.
Expand Down Expand Up @@ -2519,7 +2526,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
mmr_tend(:nY,:nZ,N) = state%q(:nY,:nZ,-M)
ENDIF
ENDDO
call t_stopf('GEOSChem_MAM_Interfacing')

call t_startf('GEOSChem_CAM_Interfacing')
! If H2O tendencies are propagated to specific humidity, then make sure
! that Q actually applies tendencies
IF ( Input_Opt%applyQtend ) lq(cQ) = .True.
Expand Down Expand Up @@ -3461,6 +3470,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDIF

ENDIF
call t_stopf('GEOSChem_CAM_Interfacing')

! This is not necessary as we prescribe CH4 surface mixing ratios
! through CAM.
Expand Down Expand Up @@ -3556,6 +3566,8 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
! Thibaud M. Fritz - 27 Feb 2020
!==================================================================

call t_startf('GEOSChem_DryDep')

IF ( Input_Opt%LDryD ) THEN
! Compute the Olson landmap fields of State_Met
! (e.g. State_Met%IREG, State_Met%ILAND, etc.)
Expand Down Expand Up @@ -3653,7 +3665,11 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDIF

!===========================================================
! ***** M I X E D L A Y E R M I X I N G *****
! ***** S U R F A C E F L U X E S *****
! Note: Turbulence (PBL mixing) is NOT done by GEOS-Chem routines
! and is handled by CAM. But we reuse GEOS-Chem code here to compute
! the surface *deposition-only* fluxes (-dflx) to merge with the CAM
! fluxes passed to turbulence. (hplin, 4/30/24)
!===========================================================

! Updates from Bob Yantosca, 06/2020
Expand All @@ -3678,23 +3694,30 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDIF
ENDIF

! This dry deposition timer intentionally ends after Compute_Sflx_For_Vdiff
! because the SurfaceFlux is only the GEOS-Chem deposition flux. (hplin, 4/30/24)
call t_stopf('GEOSChem_DryDep')

!-----------------------------------------------------------------------
! Get emissions from HEMCO + Lightning + Fire
! Add surface emissions to cam_in
!-----------------------------------------------------------------------

call t_startf('GEOSChem_Emissions')
CALL GC_Emissions_Calc( state = state, &
hco_pbuf2d = hco_pbuf2d, &
State_Met = State_Met(LCHNK), &
cam_in = cam_in, &
eflx = eflx, &
iStep = iStep )
call t_stopf('GEOSChem_Emissions')

!-----------------------------------------------------------------------
! Add dry deposition flux
! Add dry deposition flux from GEOS-Chem State_Chm%SurfaceFlux
! (stored as SurfaceFlux = -dflx)
!-----------------------------------------------------------------------

call t_startf('GEOSChem_DryDep')
IF ( Input_Opt%LDryD ) THEN
DO ND = 1, State_Chm(BEGCHUNK)%nDryDep
! Get the species ID from the drydep ID
Expand All @@ -3708,11 +3731,14 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
+ State_Chm(LCHNK)%SurfaceFlux(1,1:nY,N)
ENDDO
ENDIF
call t_stopf('GEOSChem_DryDep')

!-----------------------------------------------------------------------
! Add non-surface emissions
!-----------------------------------------------------------------------

call t_startf('GEOSChem_Emissions')

! Use units of kg/m2 as State_Chm%Species to add emissions fluxes
CALL Convert_Spc_Units( Input_Opt = Input_Opt, &
State_Chm = State_Chm(LCHNK), &
Expand Down Expand Up @@ -3757,6 +3783,8 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
CALL Error_Stop( ErrMsg, ThisLoc )
ENDIF

call t_stopf('GEOSChem_Emissions')

!==============================================================
! ***** C H E M I S T R Y *****
!==============================================================
Expand Down Expand Up @@ -3831,6 +3859,8 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
iSfcMrObj => iSfcMrObj%Next
ENDDO

call t_startf('GEOSChem_Fullchem')

! Reset photolysis rates
State_Chm(LCHNK)%Phot%ZPJ = 0.0e+0_r8

Expand All @@ -3847,6 +3877,8 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
CALL Error_Stop( ErrMsg, ThisLoc )
ENDIF

call t_stopf('GEOSChem_Fullchem')

! GEOS-Chem considers CO2 as a dead species and resets its concentration
! internally. Right after the call to `Do_Chemistry`, State_Chm%Species(iCO2)
! corresponds to the chemically-produced CO2. The real CO2 concentration
Expand Down Expand Up @@ -3911,6 +3943,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
!==============================================================

#if defined( MODAL_AERO )
call t_startf('GEOSChem_MAM_Interfacing')
! Construct dgncur_a array for the dry geometric mean diameter [m]
! of given number distribution. (hplin, 3/6/23)
! Requires a pbuf field DGNUM
Expand Down Expand Up @@ -4036,6 +4069,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDIF
ENDIF

call t_stopf('GEOSChem_MAM_Interfacing')
call t_startf('GEOSChem_MAM_GasAerExch')

call aero_model_gasaerexch( loffset = iFirstCnst - 1, &
ncol = NCOL, &
lchnk = LCHNK, &
Expand All @@ -4059,6 +4095,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
vmr = vmr1, &
pbuf = pbuf )

call t_stopf('GEOSChem_MAM_GasAerExch')
call t_startf('GEOSChem_MAM_Interfacing')

! Repartition MAM SOAs following mapping:
! TSOA0 + ASOAN + SOAIE + SOAGX -> soa1_a* + soa2_a*
! TSOA1 + ASOA1 -> soa3_a*
Expand Down Expand Up @@ -4166,10 +4205,12 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDDO

#endif
call t_stopf('GEOSChem_MAM_Interfacing')

!==============================================================
! ***** W E T D E P O S I T I O N (rainout + washout) *****
!==============================================================
call t_startf('GEOSChem_Neu_Wetdep')
IF ( Input_Opt%LWetD ) THEN

IF ( gas_wetdep_method == 'NEU' ) THEN
Expand All @@ -4193,6 +4234,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDIF

ENDIF
call t_stopf('GEOSChem_Neu_Wetdep')

!==============================================================
! ***** B O U N D A R Y C O N D I T I O N S *****
Expand Down Expand Up @@ -4247,6 +4289,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDDO

#if defined( MODAL_AERO )
call t_startf('GEOSChem_MAM_Interfacing')
! Here apply tendencies to MAM aerosols
! Initial mass in bin SM is stored as state%q(N)
! Final mass in bin SM is stored as binRatio(SM,M) * State_Chm(P)
Expand Down Expand Up @@ -4297,6 +4340,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
* adv_mass(P) / MWDry
ENDIF
ENDDO
call t_stopf('GEOSChem_MAM_Interfacing')
#endif

DO N = 1, gas_pcnst
Expand All @@ -4315,6 +4359,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ptend%q(:,:,cQ) = ptend%q(:,:,cH2O)
ENDIF

call t_startf('GEOSChem_Diagnostics')
CALL GC_Diagnostics_Calc( Input_Opt = Input_Opt, &
State_Chm = State_Chm(LCHNK), &
State_Diag = State_Diag(LCHNK), &
Expand Down Expand Up @@ -4358,6 +4403,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
HistoryConfig = HistoryConfig, &
LCHNK = LCHNK, &
RC = RC )
call t_stopf('GEOSChem_Diagnostics')

IF ( ghg_chem ) THEN
ptend%lq(1) = .True.
Expand Down Expand Up @@ -4395,6 +4441,8 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
FIRST = .false.
ENDIF

call t_stopf('GEOSChem_All_Tend')

end subroutine chem_timestep_tend

!================================================================================================
Expand Down

0 comments on commit 4126267

Please sign in to comment.