Skip to content

Commit

Permalink
add memory profiling (NOAA-EMC#36)
Browse files Browse the repository at this point in the history
* add profile_memory calls to CICE cap
  • Loading branch information
DeniseWorthen authored Aug 23, 2021
1 parent 55586f7 commit 7f089d0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module ice_comp_nuopc
integer :: nthrds ! Number of threads to use in this component

integer :: dbug = 0
logical :: profile_memory = .false.
integer , parameter :: debug_import = 0 ! internal debug level
integer , parameter :: debug_export = 0 ! internal debug level
character(*), parameter :: modName = "(ice_comp_nuopc)"
Expand Down Expand Up @@ -157,6 +158,10 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
type(ESMF_State) :: importState, exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc

logical :: isPresent, isSet
character(len=64) :: value
character(len=char_len_long) :: logmsg
!--------------------------------

rc = ESMF_SUCCESS
Expand All @@ -166,6 +171,14 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
acceptStringList=(/"IPDv01p"/), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

profile_memory = .false.
call NUOPC_CompAttributeGet(gcomp, name="ProfileMemory", value=value, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) profile_memory=(trim(value)=="true")
write(logmsg,*) profile_memory
call ESMF_LogWrite('CICE_cap:ProfileMemory = '//trim(logmsg), ESMF_LOGMSG_INFO)

end subroutine InitializeP0

!===============================================================================
Expand Down Expand Up @@ -902,6 +915,8 @@ subroutine ModelAdvance(gcomp, rc)
!--------------------------------

rc = ESMF_SUCCESS
if(profile_memory) call ESMF_VMLogMemInfo("Entering CICE Model_ADVANCE: ")

if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO)

! query the Component for its clock, importState and exportState
Expand Down Expand Up @@ -1049,7 +1064,9 @@ subroutine ModelAdvance(gcomp, rc)
! Advance cice and timestep update
!--------------------------------

if(profile_memory) call ESMF_VMLogMemInfo("Entering CICE_Run : ")
call CICE_Run()
if(profile_memory) call ESMF_VMLogMemInfo("Leaving CICE_Run : ")

!--------------------------------
! Create export state
Expand Down Expand Up @@ -1110,6 +1127,8 @@ subroutine ModelAdvance(gcomp, rc)

if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO)

if(profile_memory) call ESMF_VMLogMemInfo("Leaving CICE Model_ADVANCE: ")

end subroutine ModelAdvance

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

0 comments on commit 7f089d0

Please sign in to comment.