From 94c65b6e0c6463fb5932f6f453003163200d4caf Mon Sep 17 00:00:00 2001 From: alperaltuntas Date: Thu, 26 Mar 2026 21:23:20 -0600 Subject: [PATCH 1/2] Fix spurious restart writes caused by incorrect stop_alarm ring time In ModelSetRunClock, the stop_alarm was created using the driver clock's stopTime, which is just one coupling step ahead (currTime + driver_timestep), not the end of the simulation. This caused the alarm to ring on the first ocean coupling step, triggering spurious restart and rpointer file writes whenever write_restart_at_endofrun was enabled. The bug manifests in fully coupled (B) cases where the driver timestep (set by the fastest component, e.g., atmosphere at 1800s) differs from the ocean coupling interval (3600s). Fix: For CESM-coupled runs, use the model clock's stopTime (captured before ModelSetRunClock overwrites it), which holds the NUOPC-initialized end-of-run time. The non-CESM path is left unchanged for NOAA-EMC to address independently, preferably by removing the cesm_coupled branching this commit adds. --- config_src/drivers/nuopc_cap/mom_cap.F90 | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/config_src/drivers/nuopc_cap/mom_cap.F90 b/config_src/drivers/nuopc_cap/mom_cap.F90 index 1f7e3b3cf7..0095c9a1d6 100644 --- a/config_src/drivers/nuopc_cap/mom_cap.F90 +++ b/config_src/drivers/nuopc_cap/mom_cap.F90 @@ -2039,6 +2039,7 @@ subroutine ModelSetRunClock(gcomp, rc) type(ESMF_Clock) :: mclock, dclock type(ESMF_Time) :: mcurrtime, dcurrtime type(ESMF_Time) :: mstoptime, dstoptime + type(ESMF_Time) :: mstoptime_prev ! model stop time before it is updated by this routine type(ESMF_TimeInterval) :: mtimestep, dtimestep character(len=128) :: mtimestring, dtimestring character(len=256) :: cvalue @@ -2064,7 +2065,8 @@ subroutine ModelSetRunClock(gcomp, rc) stopTime=dstoptime, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_ClockGet(mclock, currTime=mcurrtime, timeStep=mtimestep, rc=rc) + call ESMF_ClockGet(mclock, currTime=mcurrtime, timeStep=mtimestep, & + stopTime=mstoptime_prev, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return !-------------------------------- @@ -2188,12 +2190,21 @@ subroutine ModelSetRunClock(gcomp, rc) endif ! create a 1-shot alarm at the driver stop time - stop_alarm = ESMF_AlarmCreate(mclock, ringtime=dstopTime, name = "stop_alarm", rc=rc) - call ESMF_LogWrite(subname//" Create Stop alarm", ESMF_LOGMSG_INFO) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (cesm_coupled) then + stop_alarm = ESMF_AlarmCreate(mclock, ringtime=mstoptime_prev, name = "stop_alarm", rc=rc) + call ESMF_LogWrite(subname//" Create Stop alarm", ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeGet(dstoptime, timestring=timestr, rc=rc) - call ESMF_LogWrite("Stop Alarm will ring at : "//trim(timestr), ESMF_LOGMSG_INFO) + call ESMF_TimeGet(mstoptime_prev, timestring=timestr, rc=rc) + call ESMF_LogWrite("Stop Alarm will ring at : "//trim(timestr), ESMF_LOGMSG_INFO) + else + stop_alarm = ESMF_AlarmCreate(mclock, ringtime=dstopTime, name = "stop_alarm", rc=rc) + call ESMF_LogWrite(subname//" Create Stop alarm", ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_TimeGet(dstoptime, timestring=timestr, rc=rc) + call ESMF_LogWrite("Stop Alarm will ring at : "//trim(timestr), ESMF_LOGMSG_INFO) + endif first_time = .false. From 10bb0c65a64ba459164d649e965bf335c967e21c Mon Sep 17 00:00:00 2001 From: alperaltuntas Date: Fri, 27 Mar 2026 07:45:21 -0600 Subject: [PATCH 2/2] fix trailing whitespace --- config_src/drivers/nuopc_cap/mom_cap.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_src/drivers/nuopc_cap/mom_cap.F90 b/config_src/drivers/nuopc_cap/mom_cap.F90 index 0095c9a1d6..a4c9a68a44 100644 --- a/config_src/drivers/nuopc_cap/mom_cap.F90 +++ b/config_src/drivers/nuopc_cap/mom_cap.F90 @@ -2197,7 +2197,7 @@ subroutine ModelSetRunClock(gcomp, rc) call ESMF_TimeGet(mstoptime_prev, timestring=timestr, rc=rc) call ESMF_LogWrite("Stop Alarm will ring at : "//trim(timestr), ESMF_LOGMSG_INFO) - else + else stop_alarm = ESMF_AlarmCreate(mclock, ringtime=dstopTime, name = "stop_alarm", rc=rc) call ESMF_LogWrite(subname//" Create Stop alarm", ESMF_LOGMSG_INFO) if (ChkErr(rc,__LINE__,u_FILE_u)) return