Skip to content

Commit d892028

Browse files
authored
Merge pull request #522 from DeniseWorthen/feature/ufs_restartfh
Add arbitrary restart hour for UFS
2 parents e203956 + 57ed117 commit d892028

File tree

6 files changed

+83
-4
lines changed

6 files changed

+83
-4
lines changed

.github/workflows/extbuild.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
ESMF_VERSION: v8.8.0
2424
PNETCDF_VERSION: checkpoint.1.14.0
2525
NETCDF_FORTRAN_VERSION: v4.6.1
26-
PIO_VERSION: pio2_6_4
27-
CDEPS_VERSION: cdeps1.0.64
26+
PIO_VERSION: pio2_6_5
27+
CDEPS_VERSION: cdeps1.0.72
2828
steps:
2929
- uses: actions/checkout@v4
3030
# Build the ESMF library, if the cache contains a previous build

mediator/esmFldsExchange_ufs_mod.F90

+32
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc)
5555
character(len=CS) :: fldname
5656
character(len=CS), allocatable :: flds(:), oflds(:), aflds(:), iflds(:)
5757
character(len=*) , parameter :: subname='(esmFldsExchange_ufs)'
58+
59+
! component name
60+
character(len=CS) :: lnd_name = ''
5861
!--------------------------------------
5962

6063
rc = ESMF_SUCCESS
@@ -76,6 +79,13 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc)
7679
write(msgString,'(A,i6,A)') trim(subname)//': maptype is ',maptype,', '//mapnames(maptype)
7780
call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
7881

82+
! determine which land model is present
83+
if (is_local%wrap%comp_present(complnd)) then
84+
call NUOPC_CompAttributeGet(gcomp, name="LND_model", value=cvalue, rc=rc)
85+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
86+
lnd_name = trim(cvalue)
87+
end if
88+
7989
if (trim(coupling_mode) == 'ufs.nfrac.aoflux' .or. trim(coupling_mode) == 'ufs.frac.aoflux') then
8090
med_aoflux_to_ocn = .true.
8191
else
@@ -773,6 +783,28 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc)
773783
end do
774784
deallocate(flds)
775785

786+
787+
if (lnd_name == 'lm4') then
788+
allocate(flds(4))
789+
flds = (/'Faxa_swndr', 'Faxa_swndf', 'Faxa_swvdr', 'Faxa_swvdf' /)
790+
do n = 1,size(flds)
791+
fldname = trim(flds(n))
792+
if (phase == 'advertise') then
793+
if (is_local%wrap%comp_present(compatm) .and. is_local%wrap%comp_present(complnd)) then
794+
call addfld_from(compatm , fldname)
795+
call addfld_to(complnd , fldname)
796+
end if
797+
else
798+
if ( fldchk(is_local%wrap%FBexp(complnd) , fldname, rc=rc) .and. &
799+
fldchk(is_local%wrap%FBImp(compatm,compatm), fldname, rc=rc)) then
800+
call addmap_from(compatm, fldname, complnd, maptype, 'one', 'unset')
801+
call addmrg_to(complnd, fldname, mrg_from=compatm, mrg_fld=fldname, mrg_type='copy')
802+
end if
803+
end if
804+
end do
805+
deallocate(flds)
806+
end if ! lm4
807+
776808
end subroutine esmFldsExchange_ufs
777809

778810
end module esmFldsExchange_ufs_mod

mediator/med.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -2266,9 +2266,9 @@ subroutine SetRunClock(gcomp, rc)
22662266
use ESMF , only : ESMF_ClockGetAlarmList
22672267
use NUOPC , only : NUOPC_CompCheckSetClock, NUOPC_CompAttributeGet
22682268
use NUOPC_Mediator , only : NUOPC_MediatorGet
2269-
! NUOPC_shr_methods is now in cesm_share and cdeps
2269+
! NUOPC_shr_methods is now in cesm_share and cdeps
22702270
use nuopc_shr_methods, only : AlarmInit
2271-
2271+
22722272
! input/output variables
22732273
type(ESMF_GridComp) :: gcomp
22742274
integer, intent(out) :: rc

mediator/med_phases_restart_mod.F90

+19
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ module med_phases_restart_mod
1414
use med_phases_prep_glc_mod , only : FBocnAccum2glc_o, ocnAccum2glc_cnt
1515
use med_phases_prep_rof_mod , only : FBlndAccum2rof_l, lndAccum2rof_cnt
1616
use pio , only : file_desc_t
17+
#ifndef CESMCOUPLED
18+
use shr_is_restart_fh_mod, only : init_is_restart_fh, is_restart_fh, is_restart_fh_type
19+
#endif
1720
use shr_log_mod , only : shr_log_error
21+
1822
implicit none
1923
private
2024

@@ -24,6 +28,9 @@ module med_phases_restart_mod
2428
private :: med_phases_restart_alarm_init
2529

2630
logical :: write_restart_at_endofrun = .false.
31+
#ifndef CESMCOUPLED
32+
type(is_restart_fh_type) :: restartfh_info ! For flexible restarts in UFS
33+
#endif
2734
logical :: whead(2) = (/.true. , .false./)
2835
logical :: wdata(2) = (/.false., .true. /)
2936
character(*), parameter :: u_FILE_u = &
@@ -117,6 +124,10 @@ subroutine med_phases_restart_alarm_init(gcomp, rc)
117124
write(logunit,*)
118125
end if
119126

127+
#ifndef CESMCOUPLED
128+
call init_is_restart_fh(mcurrtime, timestep_length,maintask, restartfh_info)
129+
#endif
130+
120131
end subroutine med_phases_restart_alarm_init
121132

122133
!===============================================================================
@@ -180,6 +191,9 @@ subroutine med_phases_restart_write(gcomp, rc)
180191
real(R8) :: tbnds(2) ! CF1.0 time bounds
181192
logical :: isPresent
182193
logical :: first_time = .true.
194+
#ifndef CESMCOUPLED
195+
logical :: write_restartfh
196+
#endif
183197
character(len=*), parameter :: subname='(med_phases_restart_write)'
184198
!---------------------------------------
185199

@@ -238,6 +252,11 @@ subroutine med_phases_restart_write(gcomp, rc)
238252
endif
239253
endif
240254

255+
#ifndef CESMCOUPLED
256+
call is_restart_fh(clock, restartfh_info, write_restartfh)
257+
if (write_restartfh) alarmIsOn = .true.
258+
#endif
259+
241260
if (alarmIsOn) then
242261
call ESMF_ClockGet(clock, currtime=currtime, starttime=starttime, rc=rc)
243262
if (ChkErr(rc,__LINE__,u_FILE_u)) return

ufs/ccpp/data/MED_typedefs.F90

+8
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ module MED_typedefs
183183
logical :: restart !< flag whether this is a coldstart (.false.) or a warmstart/restart (.true.)
184184
logical :: cplice !< default no cplice collection (used together with cplflx)
185185
logical :: cplflx !< flag controlling cplflx collection (default off)
186+
logical :: cpl_fire !< flag controlling fire behavior collection (default off)
186187
integer :: kdt !< current forecast iteration
187188
real(kind=kind_phys) :: min_lakeice !< minimum lake ice value
188189
real(kind=kind_phys) :: min_seaice !< minimum sea ice value
@@ -262,7 +263,9 @@ module MED_typedefs
262263
real(kind=kind_phys), pointer :: ffhh(:) => null() !< Monin-Obukhov similarity function for heat
263264
real(kind=kind_phys), pointer :: ffmm(:) => null() !< Monin-Obukhov similarity function for momentum
264265
real(kind=kind_phys), pointer :: evap(:) => null() !< kinematic surface upward latent heat flux (kg kg-1 m s-1)
266+
real(kind=kind_phys), pointer :: evap_fire(:) => null() !< kinematic surface upward latent heat flux of fire (kg kg-1 m s-1)
265267
real(kind=kind_phys), pointer :: hflx(:) => null() !< kinematic surface upward sensible heat flux (K m/s)
268+
real(kind=kind_phys), pointer :: hflx_fire(:) => null() !< kinematic surface upward sensible heat flux of fire (K m/s)
266269
real(kind=kind_phys), pointer :: tiice(:,:) => null() !< sea ice internal temperature
267270
real(kind=kind_phys), pointer :: t2m(:) => null() !< temperature at 2 m
268271
real(kind=kind_phys), pointer :: q2m(:) => null() !< specific humidity at 2 m
@@ -655,6 +658,7 @@ subroutine control_initialize(model)
655658
model%restart = .false.
656659
model%cplice = .false.
657660
model%cplflx = .false.
661+
model%cpl_fire = .false.
658662
model%kdt = 0 ! nint(Model%fhour*con_hr/Model%dtp)
659663
model%min_lakeice = 0.15d0
660664
model%min_seaice = 1.0d-11
@@ -767,8 +771,12 @@ subroutine sfcprop_create(sfcprop, im, model)
767771
sfcprop%ffmm = clear_val
768772
allocate(sfcprop%evap(im))
769773
sfcprop%evap = clear_val
774+
allocate(sfcprop%evap_fire(im))
775+
sfcprop%evap_fire = clear_val
770776
allocate(sfcprop%hflx(im))
771777
sfcprop%hflx = clear_val
778+
allocate(sfcprop%hflx_fire(im))
779+
sfcprop%hflx_fire = clear_val
772780
allocate(sfcprop%tiice(im,model%kice))
773781
sfcprop%tiice = clear_val
774782
allocate(sfcprop%t2m(im))

ufs/ccpp/data/MED_typedefs.meta

+20
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,12 @@
917917
units = 1
918918
dimensions = ()
919919
type = integer
920+
[cpl_fire]
921+
standard_name = do_fire_coupling
922+
long_name = flag controlling fire_behavior collection (default off)
923+
units = flag
924+
dimensions = ()
925+
type = logical
920926
[kdt]
921927
standard_name = index_of_timestep
922928
long_name = current forecast iteration
@@ -1267,13 +1273,27 @@
12671273
dimensions = (horizontal_loop_extent)
12681274
type = real
12691275
kind = kind_phys
1276+
[evap_fire]
1277+
standard_name = surface_upward_specific_humidity_flux_of_fire
1278+
long_name = kinematic surface upward latent heat flux of fire
1279+
units = kg kg-1 m s-1
1280+
dimensions = (horizontal_loop_extent)
1281+
type = real
1282+
kind = kind_phys
12701283
[hflx]
12711284
standard_name = surface_upward_temperature_flux
12721285
long_name = kinematic surface upward sensible heat flux
12731286
units = K m s-1
12741287
dimensions = (horizontal_loop_extent)
12751288
type = real
12761289
kind = kind_phys
1290+
[hflx_fire]
1291+
standard_name = kinematic_surface_upward_sensible_heat_flux_of_fire
1292+
long_name = kinematic surface upward sensible heat flux of fire
1293+
units = K m s-1
1294+
dimensions = (horizontal_loop_extent)
1295+
type = real
1296+
kind = kind_phys
12771297
[tiice]
12781298
standard_name = temperature_in_ice_layer
12791299
long_name = sea ice internal temperature

0 commit comments

Comments
 (0)