From 29063ec7b631d3a967172e8c45c5af13a18e0a82 Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:22:06 -0500 Subject: [PATCH] Building on recent netcdf restart capability, enhancement allows for arbitrary restart times. (#1320) This is useful for IAU methods, for example. --- model/src/cmake/src_list.cmake | 1 + model/src/wav_comp_nuopc.F90 | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/model/src/cmake/src_list.cmake b/model/src/cmake/src_list.cmake index 00fb33cad..eaa5c26d7 100644 --- a/model/src/cmake/src_list.cmake +++ b/model/src/cmake/src_list.cmake @@ -62,6 +62,7 @@ set(pio_src wav_history_mod.F90 wav_pio_mod.F90 wav_restart_mod.F90 + ${PROJECT_SOURCE_DIR}/../CDEPS-interface/ufs/cdeps_share/shr_is_restart_fh_mod.F90 wav_shr_mod.F90 wav_kind_mod.F90 wav_import_export.F90 diff --git a/model/src/wav_comp_nuopc.F90 b/model/src/wav_comp_nuopc.F90 index 4280b3b14..544b40817 100644 --- a/model/src/wav_comp_nuopc.F90 +++ b/model/src/wav_comp_nuopc.F90 @@ -56,6 +56,7 @@ module wav_comp_nuopc use wmmdatmd , only : nmpscr use w3updtmd , only : w3uini use w3adatmd , only : flcold, fliwnd + use shr_is_restart_fh_mod , only : init_is_restart_fh, is_restart_fh, is_restart_fh_type #endif use constants , only : is_esmf_component @@ -89,6 +90,7 @@ module wav_comp_nuopc logical :: cesmcoupled = .true. !< logical to indicate CESM use case #else logical :: cesmcoupled = .false. !< logical to indicate non-CESM use case + type(is_restart_fh_type) :: restartfh_info ! For flexible restarts in UFS #endif integer, allocatable :: tend(:,:) !< the ending time of ModelAdvance when !! run with multigrid=true @@ -1126,6 +1128,7 @@ subroutine ModelAdvance(gcomp, rc) type(ESMF_Time) :: currTime, nextTime, startTime, stopTime integer :: yy,mm,dd,hh,ss integer :: imod + logical :: write_restartfh !integer :: shrlogunit ! original log unit and level character(ESMF_MAXSTR) :: msgString character(len=*),parameter :: subname = '(wav_comp_nuopc:ModelAdvance) ' @@ -1219,6 +1222,10 @@ subroutine ModelAdvance(gcomp, rc) else rstwr = .false. endif +#ifndef W3_CESMCOUPLED + call is_restart_fh(clock, restartfh_info, write_restartfh) + if (write_restartfh) rstwr = .true. +#endif ! Determine if time to write ww3 history files call ESMF_ClockGetAlarm(clock, alarmname='alarm_history', alarm=alarm, rc=rc) @@ -1295,7 +1302,7 @@ subroutine ModelSetRunClock(gcomp, rc) integer :: history_ymd ! History date (YYYYMMDD) type(ESMF_ALARM) :: history_alarm character(len=128) :: name - integer :: alarmcount + integer :: alarmcount, dt_cpl character(len=*),parameter :: subname=trim(modName)//':(ModelSetRunClock) ' !------------------------------------------------------------------------------- @@ -1363,6 +1370,12 @@ subroutine ModelSetRunClock(gcomp, rc) call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return +#ifndef W3_CESMCOUPLED + 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, root_task, restartfh_info) +#endif + end if !----------------