Skip to content

Commit

Permalink
Merge pull request #116 from gustavo-marques/fix_ocean_stats
Browse files Browse the repository at this point in the history
 Adds time0 and timenow in MCT and NUOPC
  • Loading branch information
alperaltuntas authored Aug 19, 2019
2 parents 35b5c76 + b61053b commit b595da4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
18 changes: 12 additions & 6 deletions config_src/mct_driver/ocn_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
type(mct_aVect) , intent(inout) :: o2x_o !< Fluxes from ocean to coupler, computed by ocean
character(len=*), optional , intent(in) :: NLFilename !< Namelist filename

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

call set_calendar_type(NOLEAP) !TODO: confirm this

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

! Get current time
call ESMF_ClockGet(EClock, currTime=time_var, rc=rc)
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
time_start = set_date(year, month, day, hour, minute, seconds, err_msg=err_msg)

! Debugging clocks
if (debug .and. is_root_pe()) then
write(glb%stdout,*) 'ocn_init_mct, current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
Expand Down Expand Up @@ -279,7 +285,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
runtype = get_runtype()
if (runtype == "initial") then
! startup (new run) - 'n' is needed below since we don't specify input_filename in input.nml
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time0, input_restart_file = 'n')
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file = 'n')
else ! hybrid or branch or continuos runs
! get output path root
call seq_infodata_GetData( glb%infodata, outPathRoot=restartpath )
Expand All @@ -295,7 +301,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
write(glb%stdout,*) 'Reading restart file: ',trim(restartfile)
end if
call shr_file_freeUnit(nu)
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time0, input_restart_file=trim(restartfile))
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfile))
endif
if (is_root_pe()) then
write(glb%stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'
Expand Down
37 changes: 29 additions & 8 deletions config_src/nuopc_driver/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
type(ice_ocean_boundary_type), pointer :: Ice_ocean_boundary => NULL()
type(ocean_internalstate_wrapper) :: ocean_internalstate
type(ocean_grid_type), pointer :: ocean_grid => NULL()
type(time_type) :: Run_len ! length of experiment
type(time_type) :: Time
type(time_type) :: Run_len !< length of experiment
type(time_type) :: time0 !< Start time of coupled model's calendar.
type(time_type) :: time_start !< The time at which to initialize the ocean model
type(time_type) :: Time_restart
type(time_type) :: DT
integer :: DT_OCEAN
Expand Down Expand Up @@ -841,7 +842,31 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)

! this ocean connector will be driven at set interval
DT = set_time (DT_OCEAN, 0)
Time = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)
! get current time
time_start = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)

if (is_root_pe()) then
write(logunit,*) subname//'current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,second
endif

! get start/reference time
call ESMF_ClockGet(CLOCK, refTime=MyTime, RC=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

call ESMF_TimeGet (MyTime, YY=YEAR, MM=MONTH, DD=DAY, H=HOUR, M=MINUTE, S=SECOND, RC=rc )
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

time0 = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)

if (is_root_pe()) then
write(logunit,*) subname//'start time: y,m,d-',year,month,day,'h,m,s=',hour,minute,second
endif

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

ocean_public%is_ocean_pe = .true.
if (len_trim(restartfile) > 0) then
call ocean_model_init(ocean_public, ocean_state, Time, Time, input_restart_file=trim(restartfile))
else
call ocean_model_init(ocean_public, ocean_state, Time, Time)
endif
call ocean_model_init(ocean_public, ocean_state, time0, time_start, input_restart_file=trim(restartfile))

call ocean_model_init_sfc(ocean_state, ocean_public)

Expand Down

0 comments on commit b595da4

Please sign in to comment.