Skip to content

Commit

Permalink
Move configuration check to IntializeAdvertise
Browse files Browse the repository at this point in the history
The check for the write_restart_at_endofrun config option was going
to run at each model step. This change will run the check once and
set a logical variable for the subsequent check.
  • Loading branch information
dpsarmie committed Apr 25, 2024
1 parent 40c5cce commit 0dfc2bb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 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 @@ -1136,13 +1143,10 @@ subroutine ModelAdvance(gcomp, rc)
endif

! Handle end of run restart
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
call ESMF_ClockGetAlarm(clock, alarmname='alarm_stop', alarm=alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (isPresent .and. isSet .and. ESMF_AlarmIsRinging(alarm, rc=rc)) then
if (trim(cvalue) .eq. '.true.') force_restart_now = .true.
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)) force_restart_now = .true.
endif

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

0 comments on commit 0dfc2bb

Please sign in to comment.