Skip to content

Commit

Permalink
Update Time Manager (#566)
Browse files Browse the repository at this point in the history
* Initial refactor of time manager
- nyr, month, mday, sec are the new time manager prognostic variables
- time is renamed to timesec and is a diagnostic, not prognostic variable
- remove time_forc, was not needed or being used anyway
- refactor ice_calendar, use calendar_type to define calendar after initialization
- add several new subroutines to ice_calendar including
  - advance_time = handles advancing the model a timestep
  - calendar_compute_elapsed_days = compute elapsed days since 0000-01-01
  - calendar_compute_days_between = compute days between two yyyy-mm-dd dates
  - calendar_set_date_from_timesecs = support conversion of timesecs to date for binary restarts
  - calendar = same behavior as old method, just no more argument
- add month_init, day_init, sec_init, and npt_unit to namelist
- this is bit-for-bit with f5f487f on cheyenne with full test suite, manual checks of log files
  were done to verify.  restart files are not identical due to changes in files saved
- old restarts should be backwards compatible
- to advance the model a timestep, call advance_time() or update nyr, month, mday, sec and call calendar().
  subroutine calendar() will adjust the date values as needed (for instance, adding a million seconds to sec).

* Add unit test for calendar

* refactor ice_calendar and update calchk unit test

* update calchk unit test

* update compare scripts to support unit tests

* Add calc_timesteps to compute timesteps from npt and npt_unit
Modify set_nml.run* to use new npt_unit and npt
Add calc_timesteps test to calchk unit test
Update standalone model to call calc_timesteps during initialization
  and after restarts are read

* Update JRA55_data implementation
Update computation of fyear to support cycling correctly with new definition on nyr
Modify restart run lengths to be days instead of timesteps
Add debugging to ice_forcing.F90
Add timer for forcing

* clean up merge from master and recent changes

* update documentation and add timer to serial ice_timers.F90

* Update CICE for coupling with RASM with new time manager

- Update drivers/mct/cesm1/CICE_InitMod.F90 and CICE_RunMod.F90
  - use advance_timestep
  - get rid of use of time variable, shift to nyr, month, mday, sec
  - update calendar call
  - update usage of year_init
- Add section in user guide about coupling with new time manager
- Fix stuff unrelated to time manager
  - Fix bug in wght_file diagnostic in ice_domain.F90, was written before defined
  - Fix bug in bathymetry settings when max kmt is greater than hardcoded 40 levels
  - Add a few missing namelist variables recently added to documentation

* clean up old code

* update documentation

* update ice_calendar comments

* update time manager documentation in dg_dynamics

* update history restart documentation

* Update prognostic calendar variables to myear, mmonth, mday, msec.

They were nyr, month, mday, sec.  The "m" in front means model and it
creates more unique names in the source code than year, month, day, sec
which can be hard to grep for because there are so many matches.
  • Loading branch information
apcraig committed Mar 16, 2021
1 parent 5a0a559 commit b720380
Show file tree
Hide file tree
Showing 60 changed files with 2,457 additions and 774 deletions.
2 changes: 1 addition & 1 deletion cice.setup
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ cd ${testname_base}
source ./cice.settings
if (\${dobuild} == true) then
if (\${doreuse} == true) then
set ciceexe = "../ciceexe.\${ICE_ENVNAME}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}"
set ciceexe = "../ciceexe.\${ICE_TARGET}.\${ICE_ENVNAME}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}"
./cice.build --exe \${ciceexe}
if !(-e \${ciceexe}) cp -p \${ICE_RUNDIR}/cice \${ciceexe}
else
Expand Down
8 changes: 4 additions & 4 deletions cicecore/cicedynB/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ subroutine accum_hist (dt)
use ice_domain_size, only: nfsd
use ice_grid, only: tmask, lmask_n, lmask_s, dxu, dyu
use ice_calendar, only: new_year, write_history, &
write_ic, time, histfreq, nstreams, month, &
write_ic, timesecs, histfreq, nstreams, mmonth, &
new_month
use ice_dyn_eap, only: a11, a12, e11, e12, e22, s11, s12, s22, &
yieldstress11, yieldstress12, yieldstress22
Expand Down Expand Up @@ -1864,7 +1864,7 @@ subroutine accum_hist (dt)
avgct(ns) = avgct(ns) + c1
! if (avgct(ns) == c1) time_beg(ns) = (time-dt)/int(secday)
if (avgct(ns) == c1) then
time_beg(ns) = (time-dt)/int(secday)
time_beg(ns) = (timesecs-dt)/int(secday)
time_beg(ns) = real(time_beg(ns),kind=real_kind)
endif
endif
Expand Down Expand Up @@ -3966,7 +3966,7 @@ subroutine accum_hist (dt)
enddo ! iblk
!$OMP END PARALLEL DO

time_end(ns) = time/int(secday)
time_end(ns) = timesecs/int(secday)
time_end(ns) = real(time_end(ns),kind=real_kind)

!---------------------------------------------------------------
Expand Down Expand Up @@ -4057,7 +4057,7 @@ subroutine accum_hist (dt)
enddo
endif ! new_year

if ( (month .eq. 7) .and. new_month ) then
if ( (mmonth .eq. 7) .and. new_month ) then
do j=jlo,jhi
do i=ilo,ihi
! reset SH Jul 1
Expand Down
20 changes: 10 additions & 10 deletions cicecore/cicedynB/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@ module ice_history_shared

subroutine construct_filename(ncfile,suffix,ns)

use ice_calendar, only: sec, nyr, month, daymo, &
use ice_calendar, only: msec, myear, mmonth, daymo, &
mday, write_ic, histfreq, histfreq_n, &
year_init, new_year, new_month, new_day, &
new_year, new_month, new_day, &
dt
use ice_restart_shared, only: lenstr

Expand All @@ -667,12 +667,12 @@ subroutine construct_filename(ncfile,suffix,ns)
character (len=1) :: cstream
character(len=*), parameter :: subname = '(construct_filename)'

iyear = nyr + year_init - 1 ! set year_init=1 in ice_in to get iyear=nyr
imonth = month
iyear = myear
imonth = mmonth
iday = mday
isec = sec - dt
isec = msec - dt

if (write_ic) isec = sec
if (write_ic) isec = msec
! construct filename
if (write_ic) then
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
Expand All @@ -688,7 +688,7 @@ subroutine construct_filename(ncfile,suffix,ns)
imonth = 12
iday = daymo(imonth)
elseif (new_month) then
imonth = month - 1
imonth = mmonth - 1
iday = daymo(imonth)
elseif (new_day) then
iday = iday - 1
Expand All @@ -703,7 +703,7 @@ subroutine construct_filename(ncfile,suffix,ns)
if (histfreq(ns) == '1') then ! instantaneous, write every dt
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_inst.', &
iyear,'-',imonth,'-',iday,'-',sec,'.',suffix
iyear,'-',imonth,'-',iday,'-',msec,'.',suffix

elseif (hist_avg) then ! write averaged data

Expand All @@ -714,7 +714,7 @@ subroutine construct_filename(ncfile,suffix,ns)
elseif (histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then ! hourly
write(ncfile,'(a,a,i2.2,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_', &
histfreq_n(ns),'h.',iyear,'-',imonth,'-',iday,'-',sec,'.',suffix
histfreq_n(ns),'h.',iyear,'-',imonth,'-',iday,'-',msec,'.',suffix
elseif (histfreq(ns) == 'm'.or.histfreq(ns) == 'M') then ! monthly
write(ncfile,'(a,a,i4.4,a,i2.2,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
Expand All @@ -728,7 +728,7 @@ subroutine construct_filename(ncfile,suffix,ns)
else ! instantaneous with histfreq > dt
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file)),'_inst.', &
iyear,'-',imonth,'-',iday,'-',sec,'.',suffix
iyear,'-',imonth,'-',iday,'-',msec,'.',suffix
endif
endif

Expand Down
Loading

0 comments on commit b720380

Please sign in to comment.