From 7ccd200f9ec156a0e44cabd783e2e705db7cffc6 Mon Sep 17 00:00:00 2001 From: anton-climate Date: Mon, 19 Feb 2024 14:47:47 +1100 Subject: [PATCH 1/5] Set idate0 in nuopc cap, so that the history "time:units" attribute in netcdf output is consistent with other model components. Set use_leap_years in nuopc cap, so that netcdf output "time:calendar" is set correctly in history output --- .../drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index efadabbda..cd4d8fb1c 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -23,10 +23,10 @@ module ice_comp_nuopc use ice_domain_size , only : nx_global, ny_global use ice_grid , only : grid_format, init_grid2 use ice_communicate , only : init_communicate, my_task, master_task, mpi_comm_ice - use ice_calendar , only : force_restart_now, write_ic, init_calendar - use ice_calendar , only : idate, mday, mmonth, myear, year_init + use ice_calendar , only : force_restart_now, write_ic + use ice_calendar , only : idate, idate0, mday, mmonth, myear, year_init, month_init, day_init use ice_calendar , only : msec, dt, calendar, calendar_type, nextsw_cday, istep - use ice_calendar , only : ice_calendar_noleap, ice_calendar_gregorian + use ice_calendar , only : ice_calendar_noleap, ice_calendar_gregorian, use_leap_years use ice_kinds_mod , only : dbl_kind, int_kind, char_len, char_len_long use ice_fileunits , only : nu_diag, nu_diag_set, inst_index, inst_name use ice_fileunits , only : inst_suffix, release_all_fileunits, flush_fileunit @@ -675,6 +675,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) else if(mastertask) write(nu_diag,*) trim(subname)//'WARNING: pio_typename from driver needs to be set for netcdf output to work' end if + ! Set use_leap_years as some CICE calls use this instead of the calendar type + call ESMF_TimeGet( currTime, calkindflag=esmf_caltype, rc=rc ) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (esmf_caltype == ESMF_CALKIND_GREGORIAN) use_leap_years = .true. #else @@ -805,7 +809,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ref_ymd /= start_ymd .or. ref_tod /= start_tod) then if (my_task == master_task) then write(nu_diag,*) trim(subname),': ref_ymd ',ref_ymd, ' must equal start_ymd ',start_ymd - write(nu_diag,*) trim(subname),': ref_ymd ',ref_tod, ' must equal start_ymd ',start_tod + write(nu_diag,*) trim(subname),': ref_ymd ',ref_tod, ' must equal start_tod ',start_tod end if end if @@ -837,6 +841,12 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) end if + ! - start time from ESMF clock. Used to set history time units + idate0 = start_ymd + year_init = (idate0/10000) + month_init= (idate0-year_init*10000)/100 ! integer month of basedate + day_init = idate0-year_init*10000-month_init*100 + call calendar() ! update calendar info !---------------------------------------------------------------------------- From ce8fa479ac950c7f1e9ded6ec006455bb7a5e4b0 Mon Sep 17 00:00:00 2001 From: Anton Steketee <79179784+anton-seaice@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:28:31 +1100 Subject: [PATCH 2/5] Update cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 Co-authored-by: Denise Worthen --- cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index cd4d8fb1c..7f9e266c2 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -809,7 +809,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ref_ymd /= start_ymd .or. ref_tod /= start_tod) then if (my_task == master_task) then write(nu_diag,*) trim(subname),': ref_ymd ',ref_ymd, ' must equal start_ymd ',start_ymd - write(nu_diag,*) trim(subname),': ref_ymd ',ref_tod, ' must equal start_tod ',start_tod + write(nu_diag,*) trim(subname),': ref_tod',ref_tod, ' must equal start_tod ',start_tod end if end if From 6e68ad269b8b6344d90e1d37bdcbf4555309f238 Mon Sep 17 00:00:00 2001 From: anton-climate Date: Mon, 26 Feb 2024 08:51:36 +1100 Subject: [PATCH 3/5] Move setting use_leap_years to ice_calendar --- cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 6 +----- cicecore/shared/ice_calendar.F90 | 9 ++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index 7f9e266c2..4a4e22666 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -26,7 +26,7 @@ module ice_comp_nuopc use ice_calendar , only : force_restart_now, write_ic use ice_calendar , only : idate, idate0, mday, mmonth, myear, year_init, month_init, day_init use ice_calendar , only : msec, dt, calendar, calendar_type, nextsw_cday, istep - use ice_calendar , only : ice_calendar_noleap, ice_calendar_gregorian, use_leap_years + use ice_calendar , only : ice_calendar_noleap, ice_calendar_gregorian use ice_kinds_mod , only : dbl_kind, int_kind, char_len, char_len_long use ice_fileunits , only : nu_diag, nu_diag_set, inst_index, inst_name use ice_fileunits , only : inst_suffix, release_all_fileunits, flush_fileunit @@ -675,10 +675,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) else if(mastertask) write(nu_diag,*) trim(subname)//'WARNING: pio_typename from driver needs to be set for netcdf output to work' end if - ! Set use_leap_years as some CICE calls use this instead of the calendar type - call ESMF_TimeGet( currTime, calkindflag=esmf_caltype, rc=rc ) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (esmf_caltype == ESMF_CALKIND_GREGORIAN) use_leap_years = .true. #else diff --git a/cicecore/shared/ice_calendar.F90 b/cicecore/shared/ice_calendar.F90 index 17f18edb2..955cdeb7b 100644 --- a/cicecore/shared/ice_calendar.F90 +++ b/cicecore/shared/ice_calendar.F90 @@ -211,7 +211,14 @@ subroutine init_calendar nstreams = 0 #ifdef CESMCOUPLED - ! calendar_type set by coupling + ! calendar_type set by coupling + ! set use_leap_years for consistency + if (calendar_type == trim(ice_calendar_gregorian)) then + use_leap_years = .true. + else + use_leap_years = .false. + endif + #else calendar_type = '' if (use_leap_years) then From a9eedefb1ecfa9ba6d953ea94fbc530ca9c54cb2 Mon Sep 17 00:00:00 2001 From: anton-climate Date: Wed, 28 Feb 2024 14:29:44 +1100 Subject: [PATCH 4/5] Revert "Move setting use_leap_years to ice_calendar" This reverts commit 6e68ad269b8b6344d90e1d37bdcbf4555309f238. --- cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 6 +++++- cicecore/shared/ice_calendar.F90 | 9 +-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index 4a4e22666..7f9e266c2 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -26,7 +26,7 @@ module ice_comp_nuopc use ice_calendar , only : force_restart_now, write_ic use ice_calendar , only : idate, idate0, mday, mmonth, myear, year_init, month_init, day_init use ice_calendar , only : msec, dt, calendar, calendar_type, nextsw_cday, istep - use ice_calendar , only : ice_calendar_noleap, ice_calendar_gregorian + use ice_calendar , only : ice_calendar_noleap, ice_calendar_gregorian, use_leap_years use ice_kinds_mod , only : dbl_kind, int_kind, char_len, char_len_long use ice_fileunits , only : nu_diag, nu_diag_set, inst_index, inst_name use ice_fileunits , only : inst_suffix, release_all_fileunits, flush_fileunit @@ -675,6 +675,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) else if(mastertask) write(nu_diag,*) trim(subname)//'WARNING: pio_typename from driver needs to be set for netcdf output to work' end if + ! Set use_leap_years as some CICE calls use this instead of the calendar type + call ESMF_TimeGet( currTime, calkindflag=esmf_caltype, rc=rc ) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (esmf_caltype == ESMF_CALKIND_GREGORIAN) use_leap_years = .true. #else diff --git a/cicecore/shared/ice_calendar.F90 b/cicecore/shared/ice_calendar.F90 index 955cdeb7b..17f18edb2 100644 --- a/cicecore/shared/ice_calendar.F90 +++ b/cicecore/shared/ice_calendar.F90 @@ -211,14 +211,7 @@ subroutine init_calendar nstreams = 0 #ifdef CESMCOUPLED - ! calendar_type set by coupling - ! set use_leap_years for consistency - if (calendar_type == trim(ice_calendar_gregorian)) then - use_leap_years = .true. - else - use_leap_years = .false. - endif - + ! calendar_type set by coupling #else calendar_type = '' if (use_leap_years) then From 9deb0dec9afee8eff501cc0ee8620d163d3972ed Mon Sep 17 00:00:00 2001 From: anton-climate Date: Wed, 28 Feb 2024 16:27:46 +1100 Subject: [PATCH 5/5] Set use_leap_years in nuopc cap to ensure calendar is correct in history output --- cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index 7f9e266c2..6228c0bdd 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -675,10 +675,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) else if(mastertask) write(nu_diag,*) trim(subname)//'WARNING: pio_typename from driver needs to be set for netcdf output to work' end if - ! Set use_leap_years as some CICE calls use this instead of the calendar type - call ESMF_TimeGet( currTime, calkindflag=esmf_caltype, rc=rc ) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (esmf_caltype == ESMF_CALKIND_GREGORIAN) use_leap_years = .true. + + #else @@ -793,7 +791,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call cice_init2() call t_stopf ('cice_init2') !--------------------------------------------------------------------------- - ! use EClock to reset calendar information on initial start + ! use EClock to reset calendar information !--------------------------------------------------------------------------- ! - on initial run @@ -847,6 +845,13 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) month_init= (idate0-year_init*10000)/100 ! integer month of basedate day_init = idate0-year_init*10000-month_init*100 + ! - Set use_leap_years based on calendar (as some CICE calls use this instead of the calendar type) + if (calendar_type == ice_calendar_gregorian) then + use_leap_years = .true. + else + use_leap_years = .false. ! no_leap calendars + endif + call calendar() ! update calendar info !----------------------------------------------------------------------------