Skip to content

Commit

Permalink
Merge pull request #1630 from jiandewang/DEV-EMC-endofrun-restart-can…
Browse files Browse the repository at this point in the history
…didate-20240521

dev-emc-candidate 20240521 (end of run restart file)
  • Loading branch information
jiandewang authored May 22, 2024
2 parents 129e1bd + bfe3e4f commit 83fb3f0
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ module MOM_cap_mod
logical :: grid_attach_area = .false.
logical :: use_coldstart = .true.
logical :: use_mommesh = .true.
logical :: restart_eor = .false.
character(len=128) :: scalar_field_name = ''
integer :: scalar_field_count = 0
integer :: scalar_field_idx_grid_nx = 0
Expand Down Expand Up @@ -381,6 +382,13 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
geomtype = ESMF_GEOMTYPE_GRID
endif

! Read end of run restart config option
call NUOPC_CompAttributeGet(gcomp, name="write_restart_at_endofrun", value=value, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
if (trim(value) .eq. '.true.') restart_eor = .true.
end if

end subroutine

Expand Down Expand Up @@ -1637,6 +1645,8 @@ subroutine ModelAdvance(gcomp, rc)
real(8) :: MPI_Wtime, timers
logical :: write_restart
logical :: write_restartfh
logical :: write_restart_eor


rc = ESMF_SUCCESS
if(profile_memory) call ESMF_VMLogMemInfo("Entering MOM Model_ADVANCE: ")
Expand Down Expand Up @@ -1776,7 +1786,6 @@ subroutine ModelAdvance(gcomp, rc)
!---------------
! Get the stop alarm
!---------------

call ESMF_ClockGetAlarm(clock, alarmname='stop_alarm', alarm=stop_alarm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -1807,7 +1816,18 @@ subroutine ModelAdvance(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

if (write_restart .or. write_restartfh) then
write_restart_eor = .false.
if (restart_eor) then
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
if (ChkErr(rc,__LINE__,u_FILE_u)) return
write_restart_eor = .true.
! turn off the alarm
call ESMF_AlarmRingerOff(stop_alarm, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
end if

if (write_restart .or. write_restartfh .or. write_restart_eor) then
! determine restart filename
call ESMF_ClockGetNextTime(clock, MyTime, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down

0 comments on commit 83fb3f0

Please sign in to comment.