Skip to content

Commit

Permalink
Merge pull request #8 from GEOS-ESM/feature/mmanyin/tracer_timers
Browse files Browse the repository at this point in the history
Added timer for each passive tracer
  • Loading branch information
mmanyin authored Jan 23, 2024
2 parents 827138c + e72958a commit 8c0c254
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added

- Added a timer for each tracer, and the option of 'strict' timing (with a barrier before and after each tracer)

### Changed

- Reformatted the YAML ExtData file, zero diff
Expand Down
8 changes: 8 additions & 0 deletions TR_GridComp.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Resource file for TR (Passive Tracer Gridded Component)

# Use only for diagnostic timing tests:
# --------------------------------------------------
strict_tracer_timing: .FALSE.


35 changes: 29 additions & 6 deletions TR_GridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ MODULE TR_GridCompMod

integer :: pet ! ID of the persistent execution thread

LOGICAL :: strict_tracer_timing ! Call a barrier before and after each tracer is run
! Only use this to test timings, not operationally

END TYPE TR_State

! Hook for the ESMF
Expand Down Expand Up @@ -362,6 +365,7 @@ SUBROUTINE SetServices ( GC, RC )
logical :: gocart_conv
logical :: lai_needed
logical :: stOX_loss_needed
type (ESMF_Config) :: myCF

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 @@ -450,6 +454,16 @@ SUBROUTINE SetServices ( GC, RC )
! --------------------------
call ESMF_UserCompSetInternalState ( GC, 'TR_STATE', wrap, STATUS )
VERIFY_(STATUS)

! Read resource settings
! ----------------------
myCF = ESMF_ConfigCreate(__RC__)
call ESMF_ConfigLoadFile (myCF, 'TR_GridComp.rc', __RC__ )
call ESMF_ConfigGetAttribute(myCF, myState%strict_tracer_timing, Default=.FALSE., Label="strict_tracer_timing:", __RC__ )
call ESMF_ConfigDestroy (myCF, __RC__)

IF(MAPL_AM_I_ROOT()) PRINT *, TRIM(Iam)//": strict_tracer_timing =", myState%strict_tracer_timing


! ------------------
! MAPL Data Services
Expand Down Expand Up @@ -1246,12 +1260,6 @@ SUBROUTINE SetServices ( GC, RC )
! VERIFY_(STATUS)


! Set the Profiling timers
! ------------------------
CALL MAPL_TimerAdd(GC, NAME="INITIALIZE", __RC__ )
CALL MAPL_TimerAdd(GC, NAME="RUN", __RC__ )
CALL MAPL_TimerAdd(GC, NAME="FINALIZE", __RC__ )

! Generic Set Services
! --------------------
call MAPL_GenericSetServices ( GC, __RC__ )
Expand Down Expand Up @@ -1610,6 +1618,8 @@ SUBROUTINE Run_ ( GC, IMPORT, EXPORT, CLOCK, RC )

logical :: verbose=.FALSE.

type (ESMF_VM) :: VM


! For NTYPE
# include "gmi_emiss_constants.h"
Expand Down Expand Up @@ -1739,14 +1749,27 @@ SUBROUTINE Run_ ( GC, IMPORT, EXPORT, CLOCK, RC )

END IF

IF ( myState%strict_tracer_timing ) THEN
call ESMF_VMGetCurrent ( VM=VM, __RC__ )
call ESMF_VMBarrier(VM, __RC__ )
END IF


! Run each tracer (source and sink)
! ---------------------------------
do n = 1, k%tr_count

call MAPL_TimerOn( genState, trim(myState%spec(n)%name))

call TR_run_tracer_ ( myState%pet, myState%kit, myState%spec, myState%spec(n), myState%qa, &
GRID, IMPORT, EXPORT, nymd, nhms, cdt, GC, CLOCK, __RC__ )

IF ( myState%strict_tracer_timing ) THEN
call ESMF_VMBarrier(VM, __RC__ )
END IF

call MAPL_TimerOff(genState, trim(myState%spec(n)%name))

end do


Expand Down

0 comments on commit 8c0c254

Please sign in to comment.