Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This adds additional write restart at end of run functionality. #984

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module ice_restart
use ice_communicate, only: my_task, master_task
use ice_exit, only: abort_ice
use ice_fileunits, only: nu_diag, nu_restart, nu_rst_pointer
#ifdef CESMCOUPLED
use ice_fileunits, only: inst_suffix
#endif
use ice_kinds_mod
use ice_restart_shared
use ice_pio
Expand Down Expand Up @@ -46,7 +49,6 @@ subroutine init_restart_read(ice_ic)
mday, msec, npt
use ice_domain_size, only: ncat
use ice_read_write, only: ice_open

character(len=char_len_long), intent(in), optional :: ice_ic

! local variables
Expand All @@ -57,13 +59,19 @@ subroutine init_restart_read(ice_ic)
integer (kind=int_kind) :: status

logical (kind=log_kind), save :: first_call = .true.

logical :: exist
character(len=*), parameter :: subname = '(init_restart_read)'

if (present(ice_ic)) then
filename = trim(ice_ic)
else
if (my_task == master_task) then
#ifdef CESMCOUPLED
write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec
inquire(file=pointer_file, exist=exist)
if (.not. exist) pointer_file = 'rpointer.ice'//trim(inst_suffix)
#endif
open(nu_rst_pointer,file=pointer_file)
read(nu_rst_pointer,'(a)') filename0
filename = trim(filename0)
Expand Down Expand Up @@ -220,6 +228,10 @@ subroutine init_restart_write(filename_spec)

! write pointer (path/file)
if (my_task == master_task) then
#ifdef CESMCOUPLED
write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec
#endif
open(nu_rst_pointer,file=pointer_file)
write(nu_rst_pointer,'(a)') filename
close(nu_rst_pointer)
Expand Down Expand Up @@ -740,7 +752,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, &

call ice_pio_check(pio_inq_varndims(File, vardesc, ndims), &
subname// " ERROR: missing varndims "//trim(vname),file=__FILE__,line=__LINE__)

call pio_seterrorhandling(File, PIO_INTERNAL_ERROR)

if (ndim3 == ncat .and. ndims == 3) then
Expand Down
46 changes: 22 additions & 24 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
if(mastertask) write(nu_diag,*) trim(subname)//'WARNING: pio_typename from driver needs to be set for netcdf output to work'
end if



#else

! Read the cice namelist as part of the call to cice_init1
Expand Down Expand Up @@ -1331,51 +1329,51 @@ subroutine ModelSetRunClock(gcomp, rc)
call ESMF_LogWrite(subname//'setting alarms for ' // trim(name), ESMF_LOGMSG_INFO)

!----------------
! Restart alarm
! Stop alarm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you re-order the Stop alarm and Restart alarm code blocks? I believe that will remove this file from having any differences.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - the reason they are reordered is so that a REST_OPTION=end can be initialized using the stop alarm. If you do the rest alarm first you can not initialize this option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See line 927 of ice_shr_methods.F90

!----------------
call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) restart_n
read(cvalue,*) stop_n

call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) restart_ymd
read(cvalue,*) stop_ymd

call alarmInit(mclock, restart_alarm, restart_option, &
opt_n = restart_n, &
opt_ymd = restart_ymd, &
call alarmInit(mclock, stop_alarm, stop_option, &
opt_n = stop_n, &
opt_ymd = stop_ymd, &
RefTime = mcurrTime, &
alarmname = 'alarm_restart', rc=rc)
alarmname = 'alarm_stop', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc)
call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----------------
! Stop alarm
! Restart alarm
!----------------
call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) stop_n
read(cvalue,*) restart_n

call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) stop_ymd
read(cvalue,*) restart_ymd

call alarmInit(mclock, stop_alarm, stop_option, &
opt_n = stop_n, &
opt_ymd = stop_ymd, &
call alarmInit(mclock, restart_alarm, restart_option, &
opt_n = restart_n, &
opt_ymd = restart_ymd, &
RefTime = mcurrTime, &
alarmname = 'alarm_stop', rc=rc)
alarmname = 'alarm_restart', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc)
call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

end if
Expand Down
11 changes: 10 additions & 1 deletion cicecore/drivers/nuopc/cmeps/ice_shr_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module ice_shr_methods
use ESMF , only : ESMF_Mesh, ESMF_MeshGet
use ESMF , only : ESMF_GEOMTYPE_MESH, ESMF_GEOMTYPE_GRID, ESMF_FIELDSTATUS_COMPLETE
use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet
use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance
use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance, ESMF_ClockGetAlarm
use ESMF , only : ESMF_Alarm, ESMF_AlarmCreate, ESMF_AlarmGet, ESMF_AlarmSet
use ESMF , only : ESMF_Calendar, ESMF_CALKIND_NOLEAP, ESMF_CALKIND_GREGORIAN
use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet
Expand Down Expand Up @@ -65,6 +65,7 @@ module ice_shr_methods
optMonthly = "monthly" , &
optYearly = "yearly" , &
optDate = "date" , &
optEnd = "end" , &
optIfdays0 = "ifdays0"

! Module data
Expand Down Expand Up @@ -920,6 +921,14 @@ subroutine alarmInit( clock, alarm, option, &
if (chkerr(rc,__LINE__,u_FILE_u)) return
update_nextalarm = .true.

case (optEnd)
call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_ClockGetAlarm(clock, alarmname="alarm_stop", alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_AlarmGet(alarm, ringTime=NextAlarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

case default
call abort_ice(subname//'unknown option '//trim(option))

Expand Down
Loading