From 4764d4dc7b373e67bf9020fe689c8ed7444b02c6 Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:00:22 -0500 Subject: [PATCH] Enable triggering restart writes at any forecast time ("restart_fh") via UFS configuration as for other components (#1001) * No ncat,ntrcr in call icepack_aggregate in ice_prescribed_mod.F90 * Enable writing restarts that can be triggered at any forecast time ("restart_fh") via UFS configuration as for other components Part of https://github.com/ufs-community/ufs-weather-model/issues/2348 * Add 1 more #ifndef CESMCOUPLED to avoid unused variable warning for cesm * #ifndef for dtime here too --- .../drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index 7da8245a3..8ced569a5 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -55,6 +55,9 @@ module ice_comp_nuopc use ice_mesh_mod , only : ice_mesh_init_tlon_tlat_area_hm, ice_mesh_create_scolumn use ice_prescribed_mod , only : ice_prescribed_init use ice_scam , only : scol_valid, single_column +#ifndef CESMCOUPLED + use shr_is_restart_fh_mod, only : init_is_restart_fh, is_restart_fh, is_restart_fh_type +#endif implicit none private @@ -96,6 +99,9 @@ module ice_comp_nuopc logical :: mastertask logical :: runtimelog = .false. logical :: restart_eor = .false. !End of run restart flag +#ifndef CESMCOUPLED + type(is_restart_fh_type) :: restartfh_info ! For flexible restarts in UFS +#endif integer :: start_ymd ! Start date (YYYYMMDD) integer :: start_tod ! start time of day (s) integer :: curr_ymd ! Current date (YYYYMMDD) @@ -1024,6 +1030,9 @@ subroutine ModelAdvance(gcomp, rc) character(char_len_long) :: restart_date character(char_len_long) :: restart_filename logical :: isPresent, isSet +#ifndef CESMCOUPLED + logical :: write_restartfh +#endif character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' character(char_len_long) :: msgString !-------------------------------- @@ -1175,6 +1184,11 @@ subroutine ModelAdvance(gcomp, rc) endif endif +#ifndef CESMCOUPLED + call is_restart_fh(clock, restartfh_info, write_restartfh) + if (write_restartfh) force_restart_now = .true. +#endif + !-------------------------------- ! Unpack import state !-------------------------------- @@ -1292,6 +1306,9 @@ subroutine ModelSetRunClock(gcomp, rc) type(ESMF_ALARM) :: stop_alarm character(len=128) :: name integer :: alarmcount +#ifndef CESMCOUPLED + integer :: dtime +#endif character(len=*),parameter :: subname=trim(modName)//':(ModelSetRunClock) ' !-------------------------------- @@ -1377,6 +1394,11 @@ subroutine ModelSetRunClock(gcomp, rc) call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return +#ifndef CESMCOUPLED + call ESMF_TimeIntervalGet( dtimestep, s=dtime, rc=rc ) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call init_is_restart_fh(mcurrTime, dtime, my_task == master_task, restartfh_info) +#endif end if !--------------------------------