Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b595da4

Browse files
Merge pull request NCAR#116 from gustavo-marques/fix_ocean_stats
Adds time0 and timenow in MCT and NUOPC
2 parents 35b5c76 + b61053b commit b595da4

2 files changed

Lines changed: 41 additions & 14 deletions

File tree

config_src/mct_driver/ocn_comp_mct.F90

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
109109
type(mct_aVect) , intent(inout) :: o2x_o !< Fluxes from ocean to coupler, computed by ocean
110110
character(len=*), optional , intent(in) :: NLFilename !< Namelist filename
111111

112-
! local variables
113-
type(time_type) :: time0 !< Model start time
112+
! local variable
113+
type(time_type) :: time0 !< Start time of coupled model's calendar.
114+
type(time_type) :: time_start !< The time at which to initialize the ocean model
114115
type(ESMF_time) :: time_var !< ESMF_time variable to query time
115116
type(ESMF_time) :: time_in_ESMF !< Initial time for ocean
116117
type(ESMF_timeInterval) :: ocn_cpl_interval !< Ocean coupling interval
@@ -202,11 +203,16 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
202203

203204
call set_calendar_type(NOLEAP) !TODO: confirm this
204205

205-
! Get the initial time
206-
call ESMF_ClockGet(EClock, currTime=time_var, rc=rc)
206+
! Get start time
207+
call ESMF_ClockGet(EClock, StartTime=time_var, rc=rc)
207208
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
208209
time0 = set_date(year, month, day, hour, minute, seconds, err_msg=err_msg)
209210

211+
! Get current time
212+
call ESMF_ClockGet(EClock, currTime=time_var, rc=rc)
213+
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
214+
time_start = set_date(year, month, day, hour, minute, seconds, err_msg=err_msg)
215+
210216
! Debugging clocks
211217
if (debug .and. is_root_pe()) then
212218
write(glb%stdout,*) 'ocn_init_mct, current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
@@ -279,7 +285,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
279285
runtype = get_runtype()
280286
if (runtype == "initial") then
281287
! startup (new run) - 'n' is needed below since we don't specify input_filename in input.nml
282-
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time0, input_restart_file = 'n')
288+
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file = 'n')
283289
else ! hybrid or branch or continuos runs
284290
! get output path root
285291
call seq_infodata_GetData( glb%infodata, outPathRoot=restartpath )
@@ -295,7 +301,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
295301
write(glb%stdout,*) 'Reading restart file: ',trim(restartfile)
296302
end if
297303
call shr_file_freeUnit(nu)
298-
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time0, input_restart_file=trim(restartfile))
304+
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfile))
299305
endif
300306
if (is_root_pe()) then
301307
write(glb%stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'

config_src/nuopc_driver/mom_cap.F90

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
737737
type(ice_ocean_boundary_type), pointer :: Ice_ocean_boundary => NULL()
738738
type(ocean_internalstate_wrapper) :: ocean_internalstate
739739
type(ocean_grid_type), pointer :: ocean_grid => NULL()
740-
type(time_type) :: Run_len ! length of experiment
741-
type(time_type) :: Time
740+
type(time_type) :: Run_len !< length of experiment
741+
type(time_type) :: time0 !< Start time of coupled model's calendar.
742+
type(time_type) :: time_start !< The time at which to initialize the ocean model
742743
type(time_type) :: Time_restart
743744
type(time_type) :: DT
744745
integer :: DT_OCEAN
@@ -841,7 +842,31 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
841842

842843
! this ocean connector will be driven at set interval
843844
DT = set_time (DT_OCEAN, 0)
844-
Time = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)
845+
! get current time
846+
time_start = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)
847+
848+
if (is_root_pe()) then
849+
write(logunit,*) subname//'current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,second
850+
endif
851+
852+
! get start/reference time
853+
call ESMF_ClockGet(CLOCK, refTime=MyTime, RC=rc)
854+
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
855+
line=__LINE__, &
856+
file=__FILE__)) &
857+
return ! bail out
858+
859+
call ESMF_TimeGet (MyTime, YY=YEAR, MM=MONTH, DD=DAY, H=HOUR, M=MINUTE, S=SECOND, RC=rc )
860+
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
861+
line=__LINE__, &
862+
file=__FILE__)) &
863+
return ! bail out
864+
865+
time0 = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)
866+
867+
if (is_root_pe()) then
868+
write(logunit,*) subname//'start time: y,m,d-',year,month,day,'h,m,s=',hour,minute,second
869+
endif
845870

846871
! rsd need to figure out how to get this without share code
847872
!call shr_nuopc_get_component_instance(gcomp, inst_suffix, inst_index)
@@ -970,11 +995,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
970995
endif
971996

972997
ocean_public%is_ocean_pe = .true.
973-
if (len_trim(restartfile) > 0) then
974-
call ocean_model_init(ocean_public, ocean_state, Time, Time, input_restart_file=trim(restartfile))
975-
else
976-
call ocean_model_init(ocean_public, ocean_state, Time, Time)
977-
endif
998+
call ocean_model_init(ocean_public, ocean_state, time0, time_start, input_restart_file=trim(restartfile))
978999

9791000
call ocean_model_init_sfc(ocean_state, ocean_public)
9801001

0 commit comments

Comments
 (0)