Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arbitrary restart hour for UFS #522

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
32 changes: 32 additions & 0 deletions mediator/esmFldsExchange_ufs_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc)
character(len=CS) :: fldname
character(len=CS), allocatable :: flds(:), oflds(:), aflds(:), iflds(:)
character(len=*) , parameter :: subname='(esmFldsExchange_ufs)'

! component name
character(len=CS) :: lnd_name = ''
!--------------------------------------

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

! determine which land model is present
if (is_local%wrap%comp_present(complnd)) then
call NUOPC_CompAttributeGet(gcomp, name="LND_model", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
lnd_name = trim(cvalue)
end if

if (trim(coupling_mode) == 'ufs.nfrac.aoflux' .or. trim(coupling_mode) == 'ufs.frac.aoflux') then
med_aoflux_to_ocn = .true.
else
Expand Down Expand Up @@ -773,6 +783,28 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc)
end do
deallocate(flds)


if (lnd_name == 'lm4') then
allocate(flds(4))
flds = (/'Faxa_swndr', 'Faxa_swndf', 'Faxa_swvdr', 'Faxa_swvdf' /)
do n = 1,size(flds)
fldname = trim(flds(n))
if (phase == 'advertise') then
if (is_local%wrap%comp_present(compatm) .and. is_local%wrap%comp_present(complnd)) then
call addfld_from(compatm , fldname)
call addfld_to(complnd , fldname)
end if
else
if ( fldchk(is_local%wrap%FBexp(complnd) , fldname, rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compatm,compatm), fldname, rc=rc)) then
call addmap_from(compatm, fldname, complnd, maptype, 'one', 'unset')
call addmrg_to(complnd, fldname, mrg_from=compatm, mrg_fld=fldname, mrg_type='copy')
end if
end if
end do
deallocate(flds)
end if ! lm4

end subroutine esmFldsExchange_ufs

end module esmFldsExchange_ufs_mod
4 changes: 2 additions & 2 deletions mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2269,9 +2269,9 @@ subroutine SetRunClock(gcomp, rc)
use ESMF , only : ESMF_ClockGetAlarmList
use NUOPC , only : NUOPC_CompCheckSetClock, NUOPC_CompAttributeGet
use NUOPC_Mediator , only : NUOPC_MediatorGet
! NUOPC_shr_methods is now in cesm_share and cdeps
! NUOPC_shr_methods is now in cesm_share and cdeps
use nuopc_shr_methods, only : AlarmInit

! input/output variables
type(ESMF_GridComp) :: gcomp
integer, intent(out) :: rc
Expand Down
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is missing - did you git add it?

Copy link
Collaborator Author

@DeniseWorthen DeniseWorthen Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be found in our CDEPS share directory (ufs/cdeps_share) which sits at the UFS-WM CDEPS interface level. This are where we have files these files

dtypes.h
shr_assert_mod.F90
shr_frz_mod.F90
shr_infnan_mod.F90

which are generated via genf90.pl for you (and which we cannot use because of restrictions by CentralOps).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at directory cdeps/share I see files shr_assert_mod.F90.in, shr_frz_mod.F90.in and shr_infnan_mod.F90.in but no shr_is_restart_fh_mod.F90.in
or shr_is_restart_fh_mod.F90 - that file needs to go in that directory if only to enable github testing of the ufs build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So a shr_is_restart_fh_mod.F90 inside of cdeps/share will be enough? It doesn't need to be a ".in" file, right?

#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. /)
character(*), parameter :: u_FILE_u = &
Expand Down Expand Up @@ -116,6 +122,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 @@ -179,6 +189,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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need an ifdef here.

character(len=*), parameter :: subname='(med_phases_restart_write)'
!---------------------------------------

Expand Down Expand Up @@ -237,6 +248,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
8 changes: 8 additions & 0 deletions ufs/ccpp/data/MED_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ module MED_typedefs
logical :: restart !< flag whether this is a coldstart (.false.) or a warmstart/restart (.true.)
logical :: cplice !< default no cplice collection (used together with cplflx)
logical :: cplflx !< flag controlling cplflx collection (default off)
logical :: cpl_fire !< flag controlling fire behavior collection (default off)
integer :: kdt !< current forecast iteration
real(kind=kind_phys) :: min_lakeice !< minimum lake ice value
real(kind=kind_phys) :: min_seaice !< minimum sea ice value
Expand Down Expand Up @@ -262,7 +263,9 @@ module MED_typedefs
real(kind=kind_phys), pointer :: ffhh(:) => null() !< Monin-Obukhov similarity function for heat
real(kind=kind_phys), pointer :: ffmm(:) => null() !< Monin-Obukhov similarity function for momentum
real(kind=kind_phys), pointer :: evap(:) => null() !< kinematic surface upward latent heat flux (kg kg-1 m s-1)
real(kind=kind_phys), pointer :: evap_fire(:) => null() !< kinematic surface upward latent heat flux of fire (kg kg-1 m s-1)
real(kind=kind_phys), pointer :: hflx(:) => null() !< kinematic surface upward sensible heat flux (K m/s)
real(kind=kind_phys), pointer :: hflx_fire(:) => null() !< kinematic surface upward sensible heat flux of fire (K m/s)
real(kind=kind_phys), pointer :: tiice(:,:) => null() !< sea ice internal temperature
real(kind=kind_phys), pointer :: t2m(:) => null() !< temperature at 2 m
real(kind=kind_phys), pointer :: q2m(:) => null() !< specific humidity at 2 m
Expand Down Expand Up @@ -655,6 +658,7 @@ subroutine control_initialize(model)
model%restart = .false.
model%cplice = .false.
model%cplflx = .false.
model%cpl_fire = .false.
model%kdt = 0 ! nint(Model%fhour*con_hr/Model%dtp)
model%min_lakeice = 0.15d0
model%min_seaice = 1.0d-11
Expand Down Expand Up @@ -767,8 +771,12 @@ subroutine sfcprop_create(sfcprop, im, model)
sfcprop%ffmm = clear_val
allocate(sfcprop%evap(im))
sfcprop%evap = clear_val
allocate(sfcprop%evap_fire(im))
sfcprop%evap_fire = clear_val
allocate(sfcprop%hflx(im))
sfcprop%hflx = clear_val
allocate(sfcprop%hflx_fire(im))
sfcprop%hflx_fire = clear_val
allocate(sfcprop%tiice(im,model%kice))
sfcprop%tiice = clear_val
allocate(sfcprop%t2m(im))
Expand Down
20 changes: 20 additions & 0 deletions ufs/ccpp/data/MED_typedefs.meta
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,12 @@
units = 1
dimensions = ()
type = integer
[cpl_fire]
standard_name = do_fire_coupling
long_name = flag controlling fire_behavior collection (default off)
units = flag
dimensions = ()
type = logical
[kdt]
standard_name = index_of_timestep
long_name = current forecast iteration
Expand Down Expand Up @@ -1267,13 +1273,27 @@
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
[evap_fire]
standard_name = surface_upward_specific_humidity_flux_of_fire
long_name = kinematic surface upward latent heat flux of fire
units = kg kg-1 m s-1
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
[hflx]
standard_name = surface_upward_temperature_flux
long_name = kinematic surface upward sensible heat flux
units = K m s-1
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
[hflx_fire]
standard_name = kinematic_surface_upward_sensible_heat_flux_of_fire
long_name = kinematic surface upward sensible heat flux of fire
units = K m s-1
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
[tiice]
standard_name = temperature_in_ice_layer
long_name = sea ice internal temperature
Expand Down
Loading