Skip to content
3 changes: 3 additions & 0 deletions model/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ if(UFS_CAP)

target_sources(ww3_lib PRIVATE ${cap_src})
target_link_libraries(ww3_lib PUBLIC esmf)
if(UFS_TRACING)
target_link_libraries(ww3_lib PUBLIC ufs_tracing)
endif()
# Don't build executables when building WW3 ESMF library
set(programs "")
endif()
Expand Down
62 changes: 62 additions & 0 deletions model/src/wav_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ module wav_comp_nuopc
#ifndef W3_CESMCOUPLED
use shr_is_restart_fh_mod , only : init_is_restart_fh, is_restart_fh, is_restart_fh_type
#endif
#ifdef UFS_TRACING
use ufs_trace_mod
#endif

implicit none
private ! except
Expand Down Expand Up @@ -96,6 +99,7 @@ module wav_comp_nuopc
character(*), parameter :: u_FILE_u = & !< a character string for an ESMF log message
__FILE__

integer :: mype = -1
!===============================================================================
contains
!===============================================================================
Expand All @@ -112,10 +116,21 @@ subroutine SetServices(gcomp, rc)
integer, intent(out) :: rc

character(len=*),parameter :: subname=trim(modName)//':(SetServices) '
type(ESMF_VM) :: vm

rc = ESMF_SUCCESS
call ESMF_LogWrite(trim(subname)//' called', ESMF_LOGMSG_INFO)

call ESMF_GridCompGet(gcomp, vm=vm,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_VMGet(vm, localpet=mype, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace_init()
if (mype == 0) call ufs_trace("wave", "SetServices", "B")
#endif

! the NUOPC gcomp component will register the generic methods
call NUOPC_CompDerive(gcomp, model_routine_SS, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -156,6 +171,9 @@ subroutine SetServices(gcomp, rc)

call ESMF_LogWrite(trim(subname)//' done', ESMF_LOGMSG_INFO)

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "SetServices", "E")
#endif
end subroutine SetServices

!===============================================================================
Expand All @@ -180,12 +198,18 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "InitializeP0", "B")
#endif

! Switch to IPDv01 by filtering all other phaseMap entries

call NUOPC_CompFilterPhaseMap(gcomp, ESMF_METHOD_INITIALIZE, acceptStringList=(/"IPDv01p"/), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "InitializeP0", "E")
#endif
end subroutine InitializeP0

!===============================================================================
Expand Down Expand Up @@ -263,6 +287,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
character(len=*), parameter :: subname=trim(modName)//':(InitializeAdvertise) '
!-------------------------------------------------------------------------------

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "InitializeAdvertise", "B")
#endif
call ufs_settimer(wtime)
rc = ESMF_SUCCESS
call ESMF_LogWrite(trim(subname)//' called', ESMF_LOGMSG_INFO)
Expand Down Expand Up @@ -681,6 +708,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)

call ESMF_LogWrite(trim(subname)//' done', ESMF_LOGMSG_INFO)

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "InitializeAdvertise", "E")
#endif

end subroutine InitializeAdvertise
!========================================================================
!> Realize the import and export fields.
Expand Down Expand Up @@ -750,6 +781,10 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
rc = ESMF_SUCCESS
if (dbug_flag > 5) call ESMF_LogWrite(trim(subname)//' called', ESMF_LOGMSG_INFO)

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "InitializeRealize", "B")
#endif

call ufs_settimer(wtime)

call ESMF_GridCompGet(gcomp, vm=vm, localPet=iam, rc=rc)
Expand Down Expand Up @@ -923,6 +958,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

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

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "InitializeRealize", "E")
#endif
end subroutine InitializeRealize

!===============================================================================
Expand Down Expand Up @@ -959,6 +997,9 @@ subroutine DataInitialize(gcomp, rc)

rc = ESMF_SUCCESS
if (dbug_flag > 5) call ESMF_LogWrite(trim(subname)//' called', ESMF_LOGMSG_INFO)
#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "DataInitialize", "B")
#endif

call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -1012,6 +1053,9 @@ subroutine DataInitialize(gcomp, rc)

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

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "DataInitialize", "E")
#endif
end subroutine DataInitialize

!=====================================================================
Expand Down Expand Up @@ -1060,6 +1104,9 @@ subroutine ModelAdvance(gcomp, rc)

rc = ESMF_SUCCESS
if (dbug_flag > 5) call ESMF_LogWrite(trim(subname)//' called', ESMF_LOGMSG_INFO)
#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "ModelAdvance", "B")
#endif

!------------
! query the Component for its importState, exportState and clock
Expand Down Expand Up @@ -1170,6 +1217,9 @@ subroutine ModelAdvance(gcomp, rc)
if (root_task) call ufs_logtimer(nu_timer,time,tod,'ModelAdvance time: ',runtimelog,wtime)
call ufs_settimer(wtime)

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "ModelAdvance", "E")
#endif
end subroutine ModelAdvance

!===============================================================================
Expand Down Expand Up @@ -1216,6 +1266,9 @@ subroutine ModelSetRunClock(gcomp, rc)

rc = ESMF_SUCCESS
call ESMF_LogWrite(trim(subname)//' called', ESMF_LOGMSG_INFO)
#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "ModelSetRunClock", "B")
#endif

! query the Component for its clocks
call NUOPC_ModelGet(gcomp, driverClock=dclock, modelClock=mclock, rc=rc)
Expand Down Expand Up @@ -1364,6 +1417,9 @@ subroutine ModelSetRunClock(gcomp, rc)

call ESMF_LogWrite(trim(subname)//' done', ESMF_LOGMSG_INFO)

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "ModelSetRunClock", "E")
#endif
end subroutine ModelSetRunClock

!===============================================================================
Expand All @@ -1388,6 +1444,9 @@ subroutine ModelFinalize(gcomp, rc)

rc = ESMF_SUCCESS
call ESMF_LogWrite(trim(subname)//' called', ESMF_LOGMSG_INFO)
#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "ModelFinalize", "B")
#endif

if ( root_task ) then
write(nds(1),F91)
Expand All @@ -1398,6 +1457,9 @@ subroutine ModelFinalize(gcomp, rc)
call ESMF_LogWrite(trim(subname)//' done', ESMF_LOGMSG_INFO)
if(root_task) call ufs_logtimer(nu_timer,timen,tod,'ModelFinalize time: ',runtimelog,wtime)

#ifdef UFS_TRACING
if (mype == 0) call ufs_trace("wave", "ModelFinalize", "E")
#endif
end subroutine ModelFinalize

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