Skip to content

Commit

Permalink
Set idate0 in nuopc cap, so that the history "time:units" attribute i…
Browse files Browse the repository at this point in the history
…n 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
  • Loading branch information
anton-seaice committed Feb 25, 2024
1 parent 64177e3 commit 7ccd200
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

!----------------------------------------------------------------------------
Expand Down

0 comments on commit 7ccd200

Please sign in to comment.