Skip to content

Commit 25ed5ef

Browse files
committed
additions for stochy restarts
1 parent a2a374b commit 25ed5ef

5 files changed

Lines changed: 41 additions & 22 deletions

File tree

config_src/nuopc_driver/mom_cap.F90

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ module MOM_cap_mod
9191
use NUOPC_Model, only: model_label_SetRunClock => label_SetRunClock
9292
use NUOPC_Model, only: model_label_Finalize => label_Finalize
9393
use NUOPC_Model, only: SetVM
94+
#ifdef UFS
9495
use get_stochy_pattern_mod, only: write_stoch_restart_ocn
96+
#endif
9597

9698
implicit none; private
9799

@@ -1587,14 +1589,17 @@ subroutine ModelAdvance(gcomp, rc)
15871589
call ocean_model_restart(ocean_state, restartname=restartname)
15881590

15891591
! write stochastic physics restart file if active
1592+
#ifdef UFS
15901593
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
1591-
write(restartname,'(A)')"ocn_stoch.res.nc")
1594+
write(restartname,'(A)')"ocn_stoch.res.nc"
15921595
else
15931596
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
1594-
"oc_stoch.res.", year, month, day, hour, minute, seconds,".nc"
1597+
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
15951598
endif
15961599
call ESMF_LogWrite("MOM_cap: Writing restart : "//trim(restartname), ESMF_LOGMSG_INFO)
1597-
call write_stoch_restart_ocn('RESTART/'//trim(timestamp)//'.ocn_stoch.res.nc')
1600+
if (is_root_pe()) print*,'calling write_stoch_restart_ocn ',trim(restartname)
1601+
call write_stoch_restart_ocn('RESTART/'//trim(restartname))
1602+
#endif
15981603
endif
15991604

16001605
if (is_root_pe()) then

config_src/solo_driver/MOM_driver.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ program MOM_main
7474

7575
use MOM_wave_interface, only: wave_parameters_CS, MOM_wave_interface_init
7676
use MOM_wave_interface, only: MOM_wave_interface_init_lite, Update_Surface_Waves
77+
#ifdef UFS
78+
use get_stochy_pattern_mod, only: write_stoch_restart_ocn
79+
#endif
7780

7881
implicit none
7982

src/core/MOM.F90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ module MOM
142142
use MOM_offline_main, only : offline_fw_fluxes_into_ocean, offline_fw_fluxes_out_ocean
143143
use MOM_offline_main, only : offline_advection_layer, offline_transport_end
144144
use MOM_ALE, only : ale_offline_tracer_final, ALE_main_offline
145+
#ifdef UFS
145146
use stochastic_physics, only : init_stochastic_physics_ocn
147+
#endif
146148

147149
implicit none ; private
148150

@@ -229,8 +231,6 @@ module MOM
229231
logical :: offline_tracer_mode = .false.
230232
!< If true, step_offline() is called instead of step_MOM().
231233
!! This is intended for running MOM6 in offline tracer mode
232-
logical :: do_stochy = .false.
233-
!< If true, call stochastic physics pattern generator
234234

235235
type(time_type), pointer :: Time !< pointer to the ocean clock
236236
real :: dt !< (baroclinic) dynamics time step [T ~> s]
@@ -2361,19 +2361,19 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
23612361
call copy_dyngrid_to_MOM_grid(dG_in, G_in, US)
23622362
call destroy_dyn_horgrid(dG_in)
23632363

2364+
do_epbl=.false.
2365+
do_sppt=.false.
2366+
#ifdef UFS
23642367
num_procs=num_PEs()
23652368
allocate(pelist(num_procs))
23662369
call Get_PElist(pelist,commID = mom_comm)
23672370
me=PE_here()
23682371
master=root_PE()
23692372

23702373
!print*,'callling init_stochastic_physics_ocn',maxval(G%geoLatT)
2371-
do_epbl=.false.
2372-
do_sppt=.false.
2374+
if (master) print*,'about to call init_stochastic_physics'
23732375
call init_stochastic_physics_ocn(CS%dt_therm,G%geoLonT,G%geoLatT,G%ied-G%isd+1,G%jed-G%jsd+1,nz,do_epbl,do_sppt,master,mom_comm,iret)
2374-
if (do_sppt .eq. .true.) CS%do_stochy=.true.
2375-
if (do_epbl .eq. .true.) CS%do_stochy=.true.
2376-
!print*,'back from init_stochastic_physics_ocn',CS%do_stochy
2376+
#endif
23772377

23782378
! Set a few remaining fields that are specific to the ocean grid type.
23792379
call set_first_direction(G, first_direction)

src/parameterizations/vertical/MOM_diabatic_driver.F90

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ module MOM_diabatic_driver
6969
use MOM_verticalGrid, only : verticalGrid_type, get_thickness_units
7070
use MOM_wave_speed, only : wave_speeds
7171
use MOM_wave_interface, only : wave_parameters_CS
72+
#ifdef UFS
7273
use stochastic_physics, only : run_stochastic_physics_ocn
74+
#endif
7375

7476

7577
implicit none ; private
@@ -292,23 +294,28 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
292294

293295
real, dimension(SZI_(G),SZJ_(G)) :: sppt_wts
294296
real, dimension(SZI_(G),SZJ_(G),2) :: t_rp
297+
#ifdef UFS
295298
real, dimension(SZI_(G),SZJ_(G),SZK_(G)) :: h_in
296299
real, dimension(SZI_(G),SZJ_(G),SZK_(G)) :: t_in !< thickness [H ~> m or kg m-2]
297300
real, dimension(SZI_(G),SZJ_(G),SZK_(G)) :: s_in !< thickness [H ~> m or kg m-2]
298301
real :: t_tend,s_tend,h_tend ! holder for tendencey needed for SPPT
299302
real :: t_pert,s_pert,h_pert ! holder for tendencey needed for SPPT
303+
#endif
300304

301305
if (G%ke == 1) return
302306

307+
#ifdef UFS
303308
! save copy of the date for SPPT
304309
if (CS%do_sppt) then
305310
h_in=h
306311
t_in=tv%T
307312
s_in=tv%S
308313
endif
314+
print*,'calling run_stochastic_physics'
309315
call run_stochastic_physics_ocn(t_rp,sppt_wts)
310316
!print*,'in diabatic',CS%do_sppt,size(t_in,1),size(t_in,2),size(t_in,3),size(sppt_wts,1),size(sppt_wts,2)
311-
!print*,'in diabatic',CS%do_sppt,minval(sppt_wts),maxval(sppt_wts)
317+
print*,'in diabatic',CS%do_sppt,minval(sppt_wts),maxval(sppt_wts)
318+
print*,'in diabatic',CS%do_sppt,minval(t_rp),maxval(t_rp)
312319
if (CS%id_t_rp1 > 0) then
313320
call post_data(CS%id_t_rp1, t_rp(:,:,1), CS%diag)
314321
endif
@@ -318,6 +325,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
318325
if (CS%id_sppt_wts > 0) then
319326
call post_data(CS%id_sppt_wts, sppt_wts, CS%diag)
320327
endif
328+
#endif
321329

322330
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = G%ke
323331

@@ -465,6 +473,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
465473

466474
if (CS%debugConservation) call MOM_state_stats('leaving diabatic', u, v, h, tv%T, tv%S, G, GV, US)
467475

476+
#ifdef UFS
468477
if (CS%do_sppt) then
469478
do k=1,nz
470479
do j=js,je
@@ -488,6 +497,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
488497
enddo
489498
enddo
490499
endif
500+
#endif
491501

492502
end subroutine diabatic
493503

@@ -891,7 +901,7 @@ subroutine diabatic_ALE_legacy(u, v, h, tv, Hml, fluxes, t_rp, visc, ADp, CDp, d
891901
endif
892902

893903
call find_uv_at_h(u, v, h, u_h, v_h, G, GV, US)
894-
call energetic_PBL(h, u_h, v_h, tv, fluxes, t_rp, dt, Kd_ePBL, G, GV, US, &
904+
call energetic_PBL(h, u_h, v_h, tv, fluxes, t_rp, CS%do_epbl, dt, Kd_ePBL, G, GV, US, &
895905
CS%energetic_PBL_CSp, dSV_dT, dSV_dS, cTKE, SkinBuoyFlux, waves=waves)
896906

897907
if (associated(Hml)) then
@@ -1623,7 +1633,7 @@ subroutine diabatic_ALE(u, v, h, tv, Hml, fluxes, t_rp, visc, ADp, CDp, dt, Time
16231633
endif
16241634

16251635
call find_uv_at_h(u, v, h, u_h, v_h, G, GV, US)
1626-
call energetic_PBL(h, u_h, v_h, tv, fluxes, t_rp, dt, Kd_ePBL, G, GV, US, &
1636+
call energetic_PBL(h, u_h, v_h, tv, fluxes, t_rp, CS%do_epbl, dt, Kd_ePBL, G, GV, US, &
16271637
CS%energetic_PBL_CSp, dSV_dT, dSV_dS, cTKE, SkinBuoyFlux, waves=waves)
16281638

16291639
if (associated(Hml)) then

src/parameterizations/vertical/MOM_energetic_PBL.F90

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ module MOM_energetic_PBL
246246
!! mixed layer model. It assumes that heating, cooling and freshwater fluxes
247247
!! have already been applied. All calculations are done implicitly, and there
248248
!! is no stability limit on the time step.
249-
subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, t_rp, dt, Kd_int, G, GV, US, CS, &
249+
subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, t_rp, stoch_epbl, dt, Kd_int, G, GV, US, CS, &
250250
dSV_dT, dSV_dS, TKE_forced, buoy_flux, dt_diag, last_call, &
251251
dT_expected, dS_expected, Waves )
252252
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure.
@@ -285,6 +285,7 @@ subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, t_rp, dt, Kd_int, G, GV,
285285
!! call to mixedlayer_init.
286286
real, dimension(SZI_(G),SZJ_(G),2), &
287287
intent(in) :: t_rp !< random pattern to perturb wind
288+
logical, intent(in) :: stoch_epbl !< flag to pertrub production and dissipation of TKE
288289
real, dimension(SZI_(G),SZJ_(G)), &
289290
intent(in) :: buoy_flux !< The surface buoyancy flux [Z2 T-3 ~> m2 s-3].
290291
real, optional, intent(in) :: dt_diag !< The diagnostic time step, which may be less
@@ -438,8 +439,7 @@ subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, t_rp, dt, Kd_int, G, GV,
438439
do K=1,nz+1 ; Kd(K) = 0.0 ; enddo
439440

440441
! Make local copies of surface forcing and process them.
441-
!print*,'PJP EPBL',minval(t_rp),maxval(t_rp)
442-
u_star = fluxes%ustar(i,j)!*t_rp(i,j)
442+
u_star = fluxes%ustar(i,j)
443443
u_star_Mean = fluxes%ustar_gustless(i,j)
444444
B_flux = buoy_flux(i,j)
445445
if (associated(fluxes%ustar_shelf) .and. associated(fluxes%frac_shelf_h)) then
@@ -463,7 +463,7 @@ subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, t_rp, dt, Kd_int, G, GV,
463463

464464
call ePBL_column(h, u, v, T0, S0, dSV_dT_1d, dSV_dS_1d, TKE_forcing, B_flux, absf, &
465465
u_star, u_star_mean, dt, MLD_io, Kd, mixvel, mixlen, GV, &
466-
US, CS, eCD, t_rp(i,j,1),t_rp(i,j,2), dt_diag=dt_diag, Waves=Waves, G=G, i=i, j=j)
466+
US, CS, eCD, t_rp(i,j,1),t_rp(i,j,2), stoch_epbl, dt_diag=dt_diag, Waves=Waves, G=G, i=i, j=j)
467467

468468
! applly stochastic perturbation to TKE generation
469469

@@ -548,7 +548,7 @@ end subroutine energetic_PBL
548548
!! mixed layer model for a single column of water.
549549
subroutine ePBL_column(h, u, v, T0, S0, dSV_dT, dSV_dS, TKE_forcing, B_flux, absf, &
550550
u_star, u_star_mean, dt, MLD_io, Kd, mixvel, mixlen, GV, US, CS, eCD, &
551-
t_rp1,t_rp2, dt_diag, Waves, G, i, j)
551+
t_rp1,t_rp2, stoch_epbl, dt_diag, Waves, G, i, j)
552552
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
553553
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
554554
real, dimension(SZK_(GV)), intent(in) :: h !< Layer thicknesses [H ~> m or kg m-2].
@@ -587,7 +587,8 @@ subroutine ePBL_column(h, u, v, T0, S0, dSV_dT, dSV_dS, TKE_forcing, B_flux, abs
587587
!! call to mixedlayer_init.
588588
type(ePBL_column_diags), intent(inout) :: eCD !< A container for passing around diagnostics.
589589
real, intent(in) :: t_rp1 !< random value to perturb TKE production
590-
real, intent(in) :: t_rp2 !< random value to perturb TKE production
590+
real, intent(in) :: t_rp2 !< random value to perturb TKE dissipation
591+
logical, intent(in) :: stoch_epbl !< flag to pertrub production and dissipation of TKE
591592
real, optional, intent(in) :: dt_diag !< The diagnostic time step, which may be less
592593
!! than dt if there are two calls to mixedlayer [T ~> s].
593594
type(wave_parameters_CS), &
@@ -888,8 +889,8 @@ subroutine ePBL_column(h, u, v, T0, S0, dSV_dT, dSV_dS, TKE_forcing, B_flux, abs
888889
else
889890
mech_TKE = MSTAR_total * (dt*GV%Rho0* u_star**3)
890891
endif
891-
! stochastically pertrub mech_TKE
892-
mech_TKE=mech_TKE*t_rp1
892+
! stochastically pertrub mech_TKE in the UFS
893+
if (stoch_epbl) mech_TKE=mech_TKE*t_rp1
893894

894895
if (CS%TKE_diagnostics) then
895896
eCD%dTKE_conv = 0.0 ; eCD%dTKE_mixing = 0.0
@@ -973,7 +974,7 @@ subroutine ePBL_column(h, u, v, T0, S0, dSV_dT, dSV_dS, TKE_forcing, B_flux, abs
973974
if (CS%TKE_diagnostics) &
974975
!eCD%dTKE_mech_decay = eCD%dTKE_mech_decay + (exp_kh-1.0) * mech_TKE * I_dtdiag
975976
eCD%dTKE_mech_decay = exp_kh
976-
mech_TKE = mech_TKE * (1+(exp_kh-1) * t_rp2)
977+
if (stoch_epbl) mech_TKE = mech_TKE * (1+(exp_kh-1) * t_rp2)
977978

978979
! Accumulate any convectively released potential energy to contribute
979980
! to wstar and to drive penetrating convection.

0 commit comments

Comments
 (0)