From 57d50f5ae8208a73c0bf68f2cd730ca7bcd66f56 Mon Sep 17 00:00:00 2001 From: Nick Szapiro Date: Wed, 16 Oct 2024 04:27:36 +0000 Subject: [PATCH 1/2] restart_fh using shr_is_restart_fh_mod --- mediator/med_phases_restart_mod.F90 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mediator/med_phases_restart_mod.F90 b/mediator/med_phases_restart_mod.F90 index 6bbdb6b7..c1f80b2c 100644 --- a/mediator/med_phases_restart_mod.F90 +++ b/mediator/med_phases_restart_mod.F90 @@ -14,6 +14,9 @@ module med_phases_restart_mod use med_phases_prep_glc_mod , only : FBocnAccum2glc_o, ocnAccum2glc_cnt use med_phases_prep_rof_mod , only : FBlndAccum2rof_l, lndAccum2rof_cnt use pio , only : file_desc_t +#ifndef CESMCOUPLED + use shr_is_restart_fh_mod, only : init_is_restart_fh, is_restart_fh, write_restartfh +#endif implicit none private @@ -115,6 +118,10 @@ subroutine med_phases_restart_alarm_init(gcomp, rc) write(logunit,*) end if +#ifndef CESMCOUPLED + call init_is_restart_fh(mcurrtime, timestep_length,maintask) +#endif + end subroutine med_phases_restart_alarm_init !=============================================================================== @@ -244,6 +251,11 @@ subroutine med_phases_restart_write(gcomp, rc) endif endif +#ifndef CESMCOUPLED + write_restartfh = is_restart_fh(clock) + if (write_restartfh) alarmIsOn = .true. +#endif + if (alarmIsOn) then call ESMF_ClockGet(clock, currtime=currtime, starttime=starttime, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return From 3d3d28c120a1ad343f91e0e14dd38cd0cde6ae96 Mon Sep 17 00:00:00 2001 From: Nick Szapiro Date: Tue, 19 Nov 2024 00:56:48 -0600 Subject: [PATCH 2/2] Use is_restart_fh revised to avoid thread-local storage inter-component conflicts --- mediator/med_phases_restart_mod.F90 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mediator/med_phases_restart_mod.F90 b/mediator/med_phases_restart_mod.F90 index c1f80b2c..b161f6b7 100644 --- a/mediator/med_phases_restart_mod.F90 +++ b/mediator/med_phases_restart_mod.F90 @@ -15,7 +15,7 @@ module med_phases_restart_mod use med_phases_prep_rof_mod , only : FBlndAccum2rof_l, lndAccum2rof_cnt use pio , only : file_desc_t #ifndef CESMCOUPLED - use shr_is_restart_fh_mod, only : init_is_restart_fh, is_restart_fh, write_restartfh + use shr_is_restart_fh_mod, only : init_is_restart_fh, is_restart_fh, is_restart_fh_type #endif implicit none private @@ -26,6 +26,9 @@ module med_phases_restart_mod private :: med_phases_restart_alarm_init logical :: write_restart_at_endofrun = .false. +#ifndef CESMCOUPLED + type(is_restart_fh_type) :: restartfh_info ! For flexible restarts in UFS +#endif logical :: whead(2) = (/.true. , .false./) logical :: wdata(2) = (/.false., .true. /) @@ -119,7 +122,7 @@ subroutine med_phases_restart_alarm_init(gcomp, rc) end if #ifndef CESMCOUPLED - call init_is_restart_fh(mcurrtime, timestep_length,maintask) + call init_is_restart_fh(mcurrtime, timestep_length,maintask, restartfh_info) #endif end subroutine med_phases_restart_alarm_init @@ -185,6 +188,7 @@ subroutine med_phases_restart_write(gcomp, rc) real(R8) :: tbnds(2) ! CF1.0 time bounds logical :: isPresent logical :: first_time = .true. + logical :: write_restartfh character(len=*), parameter :: subname='(med_phases_restart_write)' !--------------------------------------- @@ -252,7 +256,7 @@ subroutine med_phases_restart_write(gcomp, rc) endif #ifndef CESMCOUPLED - write_restartfh = is_restart_fh(clock) + call is_restart_fh(clock, restartfh_info, write_restartfh) if (write_restartfh) alarmIsOn = .true. #endif