From c8792a6d0ddc6da13c658abf314468be4d3b4c12 Mon Sep 17 00:00:00 2001 From: Philippe Blain Date: Thu, 6 May 2021 10:02:30 -0400 Subject: [PATCH] ice_calendar: fix yearly output with 'histfreq_n /= 1' 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 (#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'. --- cicecore/shared/ice_calendar.F90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cicecore/shared/ice_calendar.F90 b/cicecore/shared/ice_calendar.F90 index 4d7ae378f..22b1f74d3 100644 --- a/cicecore/shared/ice_calendar.F90 +++ b/cicecore/shared/ice_calendar.F90 @@ -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 @@ -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) @@ -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")