Skip to content

Commit

Permalink
Flexible restart write times (restart_fh) (#125)
Browse files Browse the repository at this point in the history
* restart_fh using shr_is_restart_fh_mod
* Use is_restart_fh revised to avoid thread-local storage inter-component conflicts
  • Loading branch information
NickSzapiro-NOAA authored Dec 11, 2024
1 parent 24e9eed commit 55576eb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mediator/med_phases_restart_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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, is_restart_fh_type
#endif
implicit none
private

Expand All @@ -23,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. /)

Expand Down Expand Up @@ -115,6 +121,10 @@ subroutine med_phases_restart_alarm_init(gcomp, rc)
write(logunit,*)
end if

#ifndef CESMCOUPLED
call init_is_restart_fh(mcurrtime, timestep_length,maintask, restartfh_info)
#endif

end subroutine med_phases_restart_alarm_init

!===============================================================================
Expand Down Expand Up @@ -178,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)'
!---------------------------------------

Expand Down Expand Up @@ -244,6 +255,11 @@ subroutine med_phases_restart_write(gcomp, rc)
endif
endif

#ifndef CESMCOUPLED
call is_restart_fh(clock, restartfh_info, write_restartfh)
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
Expand Down

0 comments on commit 55576eb

Please sign in to comment.