From afe000eadff1a05ba8632f9997a87098e231d066 Mon Sep 17 00:00:00 2001 From: Nick Szapiro Date: Wed, 16 Oct 2024 05:16:43 +0000 Subject: [PATCH] restart_fh using shr_is_restart_fh_mod --- config_src/drivers/nuopc_cap/mom_cap.F90 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/config_src/drivers/nuopc_cap/mom_cap.F90 b/config_src/drivers/nuopc_cap/mom_cap.F90 index 814934f6c9..127ac0b87d 100644 --- a/config_src/drivers/nuopc_cap/mom_cap.F90 +++ b/config_src/drivers/nuopc_cap/mom_cap.F90 @@ -91,6 +91,10 @@ module MOM_cap_mod use NUOPC_Model, only: model_label_Finalize => label_Finalize use NUOPC_Model, only: SetVM +#ifndef CESMCOUPLED + use shr_is_restart_fh_mod, only : init_is_restart_fh, is_restart_fh, write_restartfh +#endif + implicit none; private public SetServices @@ -1641,6 +1645,7 @@ subroutine ModelAdvance(gcomp, rc) character(len=:), allocatable :: rpointer_filename integer :: num_rest_files real(8) :: MPI_Wtime, timers + logical :: write_restart logical :: write_restart_eor rc = ESMF_SUCCESS @@ -1792,12 +1797,14 @@ subroutine ModelAdvance(gcomp, rc) call ESMF_ClockGetAlarm(clock, alarmname='restart_alarm', alarm=restart_alarm, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + write_restart = .false. if (ESMF_AlarmIsRinging(restart_alarm, rc=rc)) then if (ChkErr(rc,__LINE__,u_FILE_u)) return - + write_restart = .true. ! turn off the alarm call ESMF_AlarmRingerOff(restart_alarm, rc=rc ) if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if write_restart_eor = .false. if (restart_eor) then @@ -1810,6 +1817,11 @@ subroutine ModelAdvance(gcomp, rc) end if end if +#ifndef CESMCOUPLED + write_restartfh = is_restart_fh(clock) + if (write_restartfh) write_restart = .true. +#endif + if (write_restart .or. write_restart_eor) then ! determine restart filename call ESMF_ClockGetNextTime(clock, MyTime, rc=rc) @@ -1923,6 +1935,7 @@ subroutine ModelSetRunClock(gcomp, rc) character(len=256) :: restart_option ! Restart option units integer :: restart_n ! Number until restart interval integer :: restart_ymd ! Restart date (YYYYMMDD) + integer :: dt_cpl type(ESMF_Alarm) :: restart_alarm type(ESMF_Alarm) :: stop_alarm logical :: isPresent, isSet @@ -2042,6 +2055,9 @@ subroutine ModelSetRunClock(gcomp, rc) call ESMF_LogWrite(subname//" Restarts will be written at finalize only", ESMF_LOGMSG_INFO) endif endif + call ESMF_TimeIntervalGet(dtimestep, s=dt_cpl, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call init_is_restart_fh(mcurrTime, dt_cpl, is_root_pe()) endif if (restart_mode == 'alarms') then