Skip to content

Commit

Permalink
Add end of run functionality to CICE (NOAA-EMC#77)
Browse files Browse the repository at this point in the history
* Add end of run restart file functionality
* Add CICE write_restart_at_endofrun config option call
* Update cice_wrapper_mod.F90
  • Loading branch information
dpsarmie authored and NickSzapiro-NOAA committed Aug 9, 2024
1 parent 64b6aa3 commit 40b46ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cicecore/drivers/nuopc/cmeps/cice_wrapper_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ subroutine ufs_logfhour(msg,hour)
real(dbl_kind), intent(in) :: hour
character(len=char_len) :: filename
integer(int_kind) :: nunit
write(filename,'(a,i3.3)')'log.ice.f',int(hour)
write(filename,'(a,i4.4)')'log.ice.f',int(hour)
open(newunit=nunit,file=trim(filename))
write(nunit,'(a)')'completed: cice'
write(nunit,'(a,f10.3)')'forecast hour:',hour
Expand Down
23 changes: 21 additions & 2 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module ice_comp_nuopc
logical :: profile_memory = .false.
logical :: mastertask
logical :: runtimelog = .false.
logical :: restart_eor = .false. !End of run restart flag
integer :: start_ymd ! Start date (YYYYMMDD)
integer :: start_tod ! start time of day (s)
integer :: curr_ymd ! Current date (YYYYMMDD)
Expand Down Expand Up @@ -316,6 +317,12 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
write(logmsg,*) runtimelog
call ESMF_LogWrite('CICE_cap:RunTimeLog = '//trim(logmsg), ESMF_LOGMSG_INFO)

call NUOPC_CompAttributeGet(gcomp, name="write_restart_at_endofrun", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
if (trim(cvalue) .eq. '.true.') restart_eor = .true.
endif

!----------------------------------------------------------------------------
! generate local mpi comm
!----------------------------------------------------------------------------
Expand Down Expand Up @@ -1139,6 +1146,8 @@ subroutine ModelAdvance(gcomp, rc)
call ESMF_ClockGetAlarm(clock, alarmname='alarm_restart', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

force_restart_now = .false.

if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
force_restart_now = .true.
Expand All @@ -1152,8 +1161,18 @@ subroutine ModelAdvance(gcomp, rc)

write(restart_date,"(i4.4,a,i2.2,a,i2.2,a,i5.5)") yy, '-', mm, '-',dd,'-',tod
write(restart_filename,'(4a)') trim(restart_dir), trim(restart_file), '.', trim(restart_date)
else
force_restart_now = .false.
endif

! Handle end of run restart
if (restart_eor) then
call ESMF_ClockGetAlarm(clock, alarmname='alarm_stop', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
force_restart_now = .true.
call ESMF_AlarmRingerOff( alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif
endif

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

0 comments on commit 40b46ed

Please sign in to comment.