Skip to content

Commit

Permalink
working timestamp in rpointer
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Sep 26, 2024
1 parent 8a9c558 commit 25efa68
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
13 changes: 7 additions & 6 deletions src/main/clm_initializeMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,14 @@ subroutine initialize2(ni,nj, currtime)


! Initialize time manager
call timemgr_init(currtime)
! else
if (.not. nsrest == nsrStartup) then
! call restFile_open( flag='read', file=fnamer, ncid=ncid )
! call timemgr_restart_io( ncid=ncid, flag='read' )
! call restFile_close( ncid=ncid )
if (nsrest == nsrStartup) then
call timemgr_init()
else
call timemgr_init(curr_date_in=currtime)
call restFile_getfile(file=fnamer, path=pnamer)
call restFile_open( flag='read', file=fnamer, ncid=ncid )
call timemgr_restart_io( ncid=ncid, flag='read' )
call restFile_close( ncid=ncid )
call timemgr_restart()
end if

Expand Down
2 changes: 1 addition & 1 deletion src/main/restFileMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ subroutine restFile_open( flag, file, ncid )
! Open netcdf restart file

if (masterproc) then
write(iulog,*) 'Reading restart dataset'
write(iulog,*) 'Reading restart dataset: ', trim(file)
end if
call ncd_pio_openfile (ncid, trim(file), 0)

Expand Down
43 changes: 21 additions & 22 deletions src/utils/clm_time_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ end subroutine set_timemgr_init

!=========================================================================================

subroutine timemgr_init(curr_date )
type(ESMF_Time), intent(in) :: curr_date ! temporary date used in logic
subroutine timemgr_init(curr_date_in )
type(ESMF_Time), intent(in), optional :: curr_date_in

!---------------------------------------------------------------------------------
! Initialize the ESMF time manager from the sync clock
Expand All @@ -189,6 +189,7 @@ subroutine timemgr_init(curr_date )
integer :: rc ! return code
type(ESMF_Time) :: start_date ! start date for run
type(ESMF_Time) :: ref_date ! reference date for time coordinate
type(ESMF_Time) :: curr_date ! temporary date used in logic
type(ESMF_TimeInterval) :: day_step_size ! day step size
type(ESMF_TimeInterval) :: step_size ! timestep size
!---------------------------------------------------------------------------------
Expand All @@ -211,8 +212,11 @@ subroutine timemgr_init(curr_date )
start_date = TimeSetymd( start_ymd, start_tod, "start_date" )

! Initialize current date

! curr_date = start_date
if(present(curr_date_in)) then
curr_date = curr_date_in
else
curr_date = start_date
endif

call ESMF_TimeIntervalSet( step_size, s=dtime, rc=rc )
call chkrc(rc, sub//': error return from ESMF_TimeIntervalSet: setting step_size')
Expand Down Expand Up @@ -253,7 +257,7 @@ subroutine init_clock( start_date, ref_date, curr_date )
!---------------------------------------------------------------------------------
! Purpose: Initialize the clock based on the start_date, ref_date and curr_date
!
use ESMF , only : ESMF_ClockCreate, ESMF_ClockAdvance
use ESMF , only : ESMF_ClockCreate, ESMF_ClockAdvance, esmf_clockiscreated

type(ESMF_Time), intent(in) :: start_date ! start date for run
type(ESMF_Time), intent(in) :: ref_date ! reference date for time coordinate
Expand All @@ -277,6 +281,7 @@ subroutine init_clock( start_date, ref_date, curr_date )
! manager included in cime appears to require stopTime.
call ESMF_TimeSet(stop_date, yy=really_big_year, mm=12, dd=31, s=0, &
calendar=tm_cal, rc=rc)
call chkrc(rc, sub//': error return from ESMF_TimeIntervalSet: setting step_size')

! Error check

Expand All @@ -299,9 +304,10 @@ subroutine init_clock( start_date, ref_date, curr_date )

! Initialize the clock


tm_clock = ESMF_ClockCreate(name="CLM Time-manager clock", timeStep=step_size, startTime=start_date, &
stopTime=stop_date, refTime=ref_date, rc=rc)
call chkrc(rc, sub//': error return from ESMF_ClockSetup')
call chkrc(rc, sub//': error return from ESMF_ClockCreate')

! Advance clock to the current time (in case of a restart)

Expand Down Expand Up @@ -519,34 +525,27 @@ subroutine timemgr_restart()

! Initialize the timestep from restart info

! dtime = rst_step_sec

! Initialize start date from restart info
dtime = rst_step_sec

! start_date = TimeSetymd( rst_start_ymd, rst_start_tod, "start_date" )
! Check start date from restart info

! Initialize current date from restart info
if (rst_start_ymd .ne. start_ymd .or. rst_start_tod .ne. start_tod) then
call shr_sys_abort(sub//'ERROR: mismatch in start date with restart file')
endif

! curr_date = TimeSetymd( rst_curr_ymd, rst_curr_tod, "curr_date" )

! call ESMF_TimeIntervalSet( step_size, s=dtime, rc=rc )
! call chkrc(rc, sub//': error return from ESMF_TimeIntervalSet: setting step_size')
if (rst_ref_ymd .ne. ref_ymd .or. rst_ref_tod .ne. ref_tod) then
call shr_sys_abort(sub//'ERROR: mismatch in reference date with restart file')
endif

call ESMF_TimeIntervalSet( day_step_size, d=1, rc=rc )
call chkrc(rc, sub//': error return from ESMF_TimeIntervalSet: setting day_step_size')

! Initialize nstep_rad_prev from restart info

! nstep_rad_prev = rst_nstep_rad_prev
nstep_rad_prev = rst_nstep_rad_prev

! Initialize ref date from restart info

! ref_date = TimeSetymd( rst_ref_ymd, rst_ref_tod, "ref_date" )

! Initialize clock

call init_clock( start_date, ref_date, curr_date)

! Advance the timestep.
! Data from the restart file corresponds to the last timestep of the previous run.

Expand Down

0 comments on commit 25efa68

Please sign in to comment.