Skip to content

Commit c4a059e

Browse files
committed
Merge remote-tracking branch 'upstream/dev/emc' into feature/update-MOM6-20260112
2 parents 2860600 + e5a7888 commit c4a059e

2 files changed

Lines changed: 84 additions & 1 deletion

File tree

config_src/drivers/nuopc_cap/mom_cap.F90

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ module MOM_cap_mod
9797
#ifndef CESMCOUPLED
9898
use shr_is_restart_fh_mod, only : init_is_restart_fh, is_restart_fh, is_restart_fh_type
9999
#endif
100+
use mom_ufs_trace_wrapper_mod, only: ufs_trace_init_wrapper, ufs_trace_wrapper
100101

101102
implicit none; private
102103

@@ -165,6 +166,7 @@ module MOM_cap_mod
165166
character(len=16) :: inst_suffix = ''
166167
logical :: pointer_date = .true. ! append date to rpointer
167168
real(8) :: timere
169+
integer :: mype = -1
168170

169171
contains
170172

@@ -182,8 +184,18 @@ subroutine SetServices(gcomp, rc)
182184
! local variables
183185
character(len=*),parameter :: subname='(MOM_cap:SetServices)'
184186

187+
type(ESMF_VM) :: vm
188+
185189
rc = ESMF_SUCCESS
186190

191+
call ESMF_GridCompGet(gcomp, vm=vm, rc=rc)
192+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
193+
call ESMF_VMGet(vm, localpet=mype, rc=rc)
194+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
195+
196+
if (mype == 0) call ufs_trace_init_wrapper()
197+
if (mype == 0) call ufs_trace_wrapper("mom", "SetServices", "B")
198+
187199
! the NUOPC model component will register the generic methods
188200
call NUOPC_CompDerive(gcomp, model_routine_SS, rc=rc)
189201
if (ChkErr(rc,__LINE__,u_FILE_u)) return
@@ -223,6 +235,8 @@ subroutine SetServices(gcomp, rc)
223235
specRoutine=ocean_model_finalize, rc=rc)
224236
if (ChkErr(rc,__LINE__,u_FILE_u)) return
225237

238+
if (mype == 0) call ufs_trace_wrapper("mom", "SetServices", "E")
239+
226240
end subroutine SetServices
227241

228242
!> First initialize subroutine called by NUOPC. The purpose
@@ -249,10 +263,11 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
249263
character(len=64) :: value, logmsg
250264
character(len=*),parameter :: subname='(MOM_cap:InitializeP0)'
251265
type(ESMF_VM) :: vm
252-
integer :: mype
253266

254267
rc = ESMF_SUCCESS
255268

269+
if (mype == 0) call ufs_trace_wrapper("mom", "InitializeP0", "B")
270+
256271
! Switch to IPDv03 by filtering all other phaseMap entries
257272
call NUOPC_CompFilterPhaseMap(gcomp, ESMF_METHOD_INITIALIZE, &
258273
acceptStringList=(/"IPDv03p"/), rc=rc)
@@ -415,6 +430,8 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
415430
if (trim(value) .eq. '.true.') restart_eor = .true.
416431
end if
417432

433+
if (mype == 0) call ufs_trace_wrapper("mom", "InitializeP0", "E")
434+
418435
end subroutine
419436

420437
!> Called by NUOPC to advertise import and export fields. "Advertise"
@@ -484,6 +501,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
484501
!--------------------------------
485502

486503
rc = ESMF_SUCCESS
504+
505+
if (mype == 0) call ufs_trace_wrapper("mom", "InitializeAdvertise", "B")
506+
487507
if(write_runtimelog) timeiads = MPI_Wtime()
488508

489509
call ESMF_LogWrite(subname//' enter', ESMF_LOGMSG_INFO)
@@ -927,6 +947,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
927947
enddo
928948
if(write_runtimelog .and. is_root_pe()) write(stdout,*) 'In ',trim(subname),' time ', MPI_Wtime()-timeiads
929949

950+
if (mype == 0) call ufs_trace_wrapper("mom", "InitializeAdvertise", "E")
951+
930952
end subroutine InitializeAdvertise
931953

932954
!> Called by NUOPC to realize import and export fields. "Realizing" a field
@@ -1020,6 +1042,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
10201042
!--------------------------------
10211043

10221044
rc = ESMF_SUCCESS
1045+
1046+
if (mype == 0) call ufs_trace_wrapper("mom", "InitializeRealize", "B")
1047+
10231048
if(write_runtimelog) timeirls = MPI_Wtime()
10241049

10251050
call shr_log_setLogUnit (stdout)
@@ -1610,6 +1635,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
16101635
timere = 0.
16111636
if(write_runtimelog .and. is_root_pe()) write(stdout,*) 'In ',trim(subname),' time ', MPI_Wtime()-timeirls
16121637

1638+
if (mype == 0) call ufs_trace_wrapper("mom", "InitializeRealize", "E")
1639+
16131640
end subroutine InitializeRealize
16141641

16151642
!> TODO
@@ -1641,6 +1668,8 @@ subroutine DataInitialize(gcomp, rc)
16411668
real(8) :: MPI_Wtime, timedis
16421669
!--------------------------------
16431670

1671+
if (mype == 0) call ufs_trace_wrapper("mom", "DataInitialize", "B")
1672+
16441673
if(write_runtimelog) timedis = MPI_Wtime()
16451674

16461675
! query the Component for its clock, importState and exportState
@@ -1705,6 +1734,8 @@ subroutine DataInitialize(gcomp, rc)
17051734

17061735
if(write_runtimelog .and. is_root_pe()) write(stdout,*) 'In ',trim(subname),' time ', MPI_Wtime()-timedis
17071736

1737+
if (mype == 0) call ufs_trace_wrapper("mom", "DataInitialize", "E")
1738+
17081739
end subroutine DataInitialize
17091740

17101741
!> Called by NUOPC to advance the model a single timestep.
@@ -1761,6 +1792,9 @@ subroutine ModelAdvance(gcomp, rc)
17611792
logical :: write_restart_eor
17621793

17631794
rc = ESMF_SUCCESS
1795+
1796+
if (mype == 0) call ufs_trace_wrapper("mom", "ModelAdvance", "B")
1797+
17641798
if(profile_memory) call ESMF_VMLogMemInfo("Entering MOM Model_ADVANCE: ")
17651799
if(write_runtimelog) then
17661800
timers = MPI_Wtime()
@@ -2048,6 +2082,8 @@ subroutine ModelAdvance(gcomp, rc)
20482082

20492083
if(profile_memory) call ESMF_VMLogMemInfo("Leaving MOM Model_ADVANCE: ")
20502084

2085+
if (mype == 0) call ufs_trace_wrapper("mom", "ModelAdvance", "E")
2086+
20512087
end subroutine ModelAdvance
20522088

20532089

@@ -2076,6 +2112,8 @@ subroutine ModelSetRunClock(gcomp, rc)
20762112

20772113
rc = ESMF_SUCCESS
20782114

2115+
if (mype == 0) call ufs_trace_wrapper("mom", "ModelSetRunClock", "B")
2116+
20792117
! query the Component for its clock, importState and exportState
20802118
call NUOPC_ModelGet(gcomp, driverClock=dclock, modelClock=mclock, rc=rc)
20812119
if (ChkErr(rc,__LINE__,u_FILE_u)) return
@@ -2231,6 +2269,8 @@ subroutine ModelSetRunClock(gcomp, rc)
22312269
call ESMF_ClockSet(mclock, currTime=dcurrtime, timeStep=dtimestep, stopTime=mstoptime, rc=rc)
22322270
if (ChkErr(rc,__LINE__,u_FILE_u)) return
22332271

2272+
if (mype == 0) call ufs_trace_wrapper("mom", "ModelSetRunClock", "E")
2273+
22342274
end subroutine ModelSetRunClock
22352275

22362276
!===============================================================================
@@ -2257,6 +2297,8 @@ subroutine ocean_model_finalize(gcomp, rc)
22572297
character(len=*),parameter :: subname='(MOM_cap:ocean_model_finalize)'
22582298
real(8) :: MPI_Wtime, timefs
22592299

2300+
if (mype == 0) call ufs_trace_wrapper("mom", "ocean_model_finalize", "B")
2301+
22602302
if (is_root_pe()) then
22612303
write(stdout,*) 'MOM: --- finalize called ---'
22622304
endif
@@ -2298,6 +2340,8 @@ subroutine ocean_model_finalize(gcomp, rc)
22982340

22992341
if(write_runtimelog .and. is_root_pe()) write(stdout,*) 'In ',trim(subname),' time ', MPI_Wtime()-timefs
23002342

2343+
if(mype == 0) call ufs_trace_wrapper("mom", "ocean_model_finalize", "E")
2344+
23012345
end subroutine ocean_model_finalize
23022346

23032347

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module mom_ufs_trace_wrapper_mod
2+
3+
#ifdef UFS_TRACING
4+
use ufs_trace_mod, only: ufs_trace_init, ufs_trace, ufs_trace_finalize
5+
#endif
6+
7+
implicit none
8+
9+
private
10+
11+
public ufs_trace_init_wrapper
12+
public ufs_trace_wrapper
13+
public ufs_trace_finalize_wrapper
14+
15+
contains
16+
17+
subroutine ufs_trace_init_wrapper()
18+
#ifdef UFS_TRACING
19+
call ufs_trace_init
20+
#endif
21+
return
22+
end subroutine ufs_trace_init_wrapper
23+
24+
subroutine ufs_trace_wrapper(component, routine, ph)
25+
character(len=*), intent(in) :: component, routine, ph
26+
#ifdef UFS_TRACING
27+
call ufs_trace(component, routine, ph)
28+
#endif
29+
return
30+
end subroutine ufs_trace_wrapper
31+
32+
subroutine ufs_trace_finalize_wrapper()
33+
#ifdef UFS_TRACING
34+
call ufs_trace_finalize
35+
#endif
36+
return
37+
end subroutine ufs_trace_finalize_wrapper
38+
39+
end module mom_ufs_trace_wrapper_mod

0 commit comments

Comments
 (0)