Skip to content

Commit

Permalink
ice_calendar: fix yearly output with 'histfreq_n /= 1'
Browse files Browse the repository at this point in the history
In ice_calendar::calendar, we loop over the output frequencies and set
'write_history(ns)' to true if the current time corresponds to the
frequency requested in 'histfreq_n'. For yearly outputs, however, the
model year 'myear' is used in the modulo computation, whereas it's
really the number of elapsed years since the beginning of the run that
should be used. This has been the case since the update of the time
manager in b720380 (Update Time Manager (CICE-Consortium#566), 2021-03-16). Prior to
that, the variable 'nyr' was used, which at that point of the subroutine
contained the number of years since the beginning of the run.

Fix that regression by introducing the variable 'elapsed_years'.
  • Loading branch information
phil-blain committed May 6, 2021
1 parent 1cddc84 commit c8792a6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cicecore/shared/ice_calendar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ subroutine calendar()
integer (kind=int_kind) :: &
ns , & ! loop index
yearp,monthp,dayp,hourp , & ! previous year, month, day, hour
elapsed_years , & ! since beginning this run
elapsed_days , & ! since beginning this run
elapsed_months , & ! since beginning this run
elapsed_hours ! since beginning this run
Expand All @@ -350,7 +351,8 @@ subroutine calendar()
idate = (myear)*10000 + mmonth*100 + mday ! date (yyyymmdd)
yday = daycal(mmonth) + mday ! day of the year
hour = (msec+1)/(seconds_per_hour)
elapsed_months = (myear - year_init)*months_per_year + mmonth - month_init
elapsed_years = myear - year_init
elapsed_months = elapsed_years*months_per_year + mmonth - month_init
elapsed_days = compute_days_between(year_init,month_init,day_init,myear,mmonth,mday)
elapsed_hours = elapsed_days * hours_per_day
call calendar_date2time(myear,mmonth,mday,msec,timesecs)
Expand All @@ -373,7 +375,7 @@ subroutine calendar()
select case (histfreq(ns))
case ("y", "Y")
if (new_year .and. histfreq_n(ns)/=0) then
if (mod(myear, histfreq_n(ns))==0) &
if (mod(elapsed_years, histfreq_n(ns))==0) &
write_history(ns) = .true.
endif
case ("m", "M")
Expand Down

0 comments on commit c8792a6

Please sign in to comment.