Skip to content

Commit 182ef34

Browse files
Philip PegionPhilip Pegion
authored andcommitted
additions for stochastic physics and ePBL perts
1 parent cb79e97 commit 182ef34

6 files changed

Lines changed: 54 additions & 5 deletions

File tree

config_src/nuopc_driver/mom_surface_forcing_nuopc.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, G, US, CS, &
285285

286286
call safe_alloc_ptr(fluxes%p_surf ,isd,ied,jsd,jed)
287287
call safe_alloc_ptr(fluxes%p_surf_full,isd,ied,jsd,jed)
288+
print*,'allocate fluxes%t_rp'
289+
call safe_alloc_ptr(fluxes%t_rp,isd,ied,jsd,jed)
288290
if (CS%use_limited_P_SSH) then
289291
fluxes%p_surf_SSH => fluxes%p_surf
290292
else

src/core/MOM.F90

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module MOM
2727
use MOM_domains, only : To_All, Omit_corners, CGRID_NE, SCALAR_PAIR
2828
use MOM_domains, only : create_group_pass, do_group_pass, group_pass_type
2929
use MOM_domains, only : start_group_pass, complete_group_pass, Omit_Corners
30+
use MOM_domains, only : root_PE,PE_here,Get_PElist,num_PEs
3031
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING, is_root_pe
3132
use MOM_error_handler, only : MOM_set_verbosity, callTree_showQuery
3233
use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint
@@ -130,6 +131,7 @@ module MOM
130131
use MOM_offline_main, only : offline_fw_fluxes_into_ocean, offline_fw_fluxes_out_ocean
131132
use MOM_offline_main, only : offline_advection_layer, offline_transport_end
132133
use MOM_ALE, only : ale_offline_tracer_final, ALE_main_offline
134+
use stochastic_physics, only : init_stochastic_physics_ocn,run_stochastic_physics_ocn
133135

134136
implicit none ; private
135137

@@ -212,6 +214,8 @@ module MOM
212214
logical :: offline_tracer_mode = .false.
213215
!< If true, step_offline() is called instead of step_MOM().
214216
!! This is intended for running MOM6 in offline tracer mode
217+
logical :: do_stochy = .false.
218+
!< If true, call stochastic physics pattern generator
215219

216220
type(time_type), pointer :: Time !< pointer to the ocean clock
217221
real :: dt !< (baroclinic) dynamics time step [s]
@@ -703,6 +707,9 @@ subroutine step_MOM(forces, fluxes, sfc_state, Time_start, time_interval, CS, &
703707
enddo ; enddo
704708
endif
705709

710+
print*,'calling run_stochastic_physics_ocn',CS%do_stochy
711+
if (CS%do_stochy) call run_stochastic_physics_ocn(forces%t_rp)
712+
706713
call step_MOM_dynamics(forces, CS%p_surf_begin, CS%p_surf_end, dt, &
707714
dt_therm_here, bbl_time_int, CS, &
708715
Time_local, Waves=Waves)
@@ -843,7 +850,7 @@ subroutine step_MOM(forces, fluxes, sfc_state, Time_start, time_interval, CS, &
843850
if (CS%time_in_thermo_cycle > 0.0) then
844851
call enable_averaging(CS%time_in_thermo_cycle, Time_local, CS%diag)
845852
call post_surface_thermo_diags(CS%sfc_IDs, G, GV, US, CS%diag, CS%time_in_thermo_cycle, &
846-
sfc_state, CS%tv, ssh, CS%ave_ssh_ibc)
853+
sfc_state, CS%tv, ssh, fluxes%t_rp, CS%ave_ssh_ibc)
847854
endif
848855
call disable_averaging(CS%diag)
849856
call cpu_clock_end(id_clock_diagnostics)
@@ -1580,6 +1587,11 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
15801587
integer :: nkml, nkbl, verbosity, write_geom
15811588
integer :: dynamics_stencil ! The computational stencil for the calculations
15821589
! in the dynamic core.
1590+
integer,allocatable :: pelist(:) ! list of pes for this instance of the ocean
1591+
integer :: num_procs
1592+
! model
1593+
integer :: me ! my pe
1594+
integer :: master ! root pe
15831595
real :: conv2watt, conv2salt
15841596
character(len=48) :: flux_units, S_flux_units
15851597

@@ -2146,6 +2158,17 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
21462158
call copy_dyngrid_to_MOM_grid(dG, G, US)
21472159
call destroy_dyn_horgrid(dG)
21482160

2161+
num_procs=num_PEs()
2162+
allocate(pelist(num_procs))
2163+
call Get_PElist(pelist)
2164+
me=PE_here()
2165+
master=root_PE()
2166+
2167+
!call init_stochastic_physics_ocn(CS%dt_therm,G,me,master,pelist,CS%do_stochy)
2168+
print*,'callling init_stochastic_physics_ocn',maxval(G%geoLatT)
2169+
call init_stochastic_physics_ocn(CS%dt_therm,G%geoLonT,G%geoLatT,G%ied-G%isd+1,G%jed-G%jsd+1,nz,CS%do_stochy)
2170+
print*,'back from init_stochastic_physics_ocn',CS%do_stochy
2171+
21492172
! Set a few remaining fields that are specific to the ocean grid type.
21502173
call set_first_direction(G, first_direction)
21512174
! Allocate the auxiliary non-symmetric domain for debugging or I/O purposes.

src/core/MOM_forcing_type.F90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ module MOM_forcing_type
123123
!< Pressure at the top ocean interface [Pa] that is used in corrections to the sea surface
124124
!! height field that is passed back to the calling routines.
125125
!! p_surf_SSH may point to p_surf or to p_surf_full.
126+
real, pointer, dimension(:,:) :: t_rp => NULL()
127+
!< random pattern at t-points
126128
logical :: accumulate_p_surf = .false. !< If true, the surface pressure due to the atmosphere
127129
!! and various types of ice needs to be accumulated, and the
128130
!! surface pressure explicitly reset to zero at the driver level
@@ -217,6 +219,8 @@ module MOM_forcing_type
217219
real, pointer, dimension(:,:) :: &
218220
rigidity_ice_u => NULL(), & !< Depth-integrated lateral viscosity of ice shelves or sea ice at u-points [m3 s-1]
219221
rigidity_ice_v => NULL() !< Depth-integrated lateral viscosity of ice shelves or sea ice at v-points [m3 s-1]
222+
real, pointer, dimension(:,:) :: t_rp => NULL()
223+
!< random pattern at t-points
220224
real :: dt_force_accum = -1.0 !< The amount of time over which the mechanical forcing fluxes
221225
!! have been averaged [s].
222226
logical :: net_mass_src_set = .false. !< If true, an estimate of net_mass_src has been provided.
@@ -2020,6 +2024,12 @@ subroutine copy_common_forcing_fields(forces, fluxes, G, skip_pres)
20202024

20212025
do_pres = .true. ; if (present(skip_pres)) do_pres = .not.skip_pres
20222026

2027+
if (associated(forces%t_rp) .and. associated(fluxes%t_rp)) then
2028+
do j=js,je ; do i=is,ie
2029+
fluxes%t_rp(i,j) = forces%t_rp(i,j)
2030+
enddo ; enddo
2031+
endif
2032+
20232033
if (associated(forces%ustar) .and. associated(fluxes%ustar)) then
20242034
do j=js,je ; do i=is,ie
20252035
fluxes%ustar(i,j) = forces%ustar(i,j)
@@ -2845,6 +2855,7 @@ subroutine allocate_mech_forcing(G, forces, stress, ustar, shelf, press, iceberg
28452855
call myAlloc(forces%p_surf,isd,ied,jsd,jed, press)
28462856
call myAlloc(forces%p_surf_full,isd,ied,jsd,jed, press)
28472857
call myAlloc(forces%net_mass_src,isd,ied,jsd,jed, press)
2858+
call myAlloc(forces%t_rp,isd,ied,jsd,jed, press)
28482859

28492860
call myAlloc(forces%rigidity_ice_u,IsdB,IedB,jsd,jed, shelf)
28502861
call myAlloc(forces%rigidity_ice_v,isd,ied,JsdB,JedB, shelf)
@@ -2908,6 +2919,7 @@ subroutine deallocate_forcing_type(fluxes)
29082919
if (associated(fluxes%seaice_melt)) deallocate(fluxes%seaice_melt)
29092920
if (associated(fluxes%salt_flux)) deallocate(fluxes%salt_flux)
29102921
if (associated(fluxes%p_surf_full)) deallocate(fluxes%p_surf_full)
2922+
if (associated(fluxes%t_rp)) deallocate(fluxes%t_rp)
29112923
if (associated(fluxes%p_surf)) deallocate(fluxes%p_surf)
29122924
if (associated(fluxes%TKE_tidal)) deallocate(fluxes%TKE_tidal)
29132925
if (associated(fluxes%ustar_tidal)) deallocate(fluxes%ustar_tidal)
@@ -2932,6 +2944,7 @@ subroutine deallocate_mech_forcing(forces)
29322944
if (associated(forces%ustar)) deallocate(forces%ustar)
29332945
if (associated(forces%p_surf)) deallocate(forces%p_surf)
29342946
if (associated(forces%p_surf_full)) deallocate(forces%p_surf_full)
2947+
if (associated(forces%t_rp)) deallocate(forces%t_rp)
29352948
if (associated(forces%net_mass_src)) deallocate(forces%net_mass_src)
29362949
if (associated(forces%rigidity_ice_u)) deallocate(forces%rigidity_ice_u)
29372950
if (associated(forces%rigidity_ice_v)) deallocate(forces%rigidity_ice_v)

src/diagnostics/MOM_diagnostics.F90

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ module MOM_diagnostics
167167
integer :: id_salt_deficit = -1
168168
integer :: id_Heat_PmE = -1
169169
integer :: id_intern_heat = -1
170+
! stochastic pattern
171+
integer :: id_t_rp = -1
170172
!!@}
171173
end type surface_diag_IDs
172174

@@ -1193,7 +1195,7 @@ end subroutine post_surface_dyn_diags
11931195
!> This routine posts diagnostics of various ocean surface and integrated
11941196
!! quantities at the time the ocean state is reported back to the caller
11951197
subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv, &
1196-
ssh, ssh_ibc)
1198+
ssh, t_rp, ssh_ibc)
11971199
type(surface_diag_IDs), intent(in) :: IDs !< A structure with the diagnostic IDs.
11981200
type(ocean_grid_type), intent(in) :: G !< ocean grid structure
11991201
type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
@@ -1204,6 +1206,8 @@ subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv
12041206
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables
12051207
real, dimension(SZI_(G),SZJ_(G)), &
12061208
intent(in) :: ssh !< Time mean surface height without corrections for ice displacement [m]
1209+
real, dimension(SZI_(G),SZJ_(G)), &
1210+
intent(in) :: t_rp!< random pattern for stochastic proceeses
12071211
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: ssh_ibc !< Time mean surface height with corrections
12081212
!! for ice displacement and the inverse barometer [m]
12091213

@@ -1328,6 +1332,11 @@ subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv
13281332
call post_data(IDs%id_sss_sq, work_2d, diag, mask=G%mask2dT)
13291333
endif
13301334

1335+
if (IDs%id_t_rp > 0) then
1336+
!call post_data(IDs%id_t_rp, t_rp, diag, mask=G%mask2dT)
1337+
call post_data(IDs%id_t_rp, t_rp, diag)
1338+
endif
1339+
13311340
call coupler_type_send_data(sfc_state%tr_fields, get_diag_time_end(diag))
13321341

13331342
end subroutine post_surface_thermo_diags
@@ -1789,6 +1798,8 @@ subroutine register_surface_diags(Time, G, IDs, diag, tv)
17891798
'Heat flux into ocean from mass flux into ocean', 'W m-2')
17901799
IDs%id_intern_heat = register_diag_field('ocean_model', 'internal_heat', diag%axesT1, Time,&
17911800
'Heat flux into ocean from geothermal or other internal sources', 'W m-2')
1801+
IDs%id_t_rp = register_diag_field('ocean_model', 'random_pattern', diag%axesT1, Time, &
1802+
'random pattern for stochastics', 'None')
17921803

17931804
end subroutine register_surface_diags
17941805

src/framework/MOM_domains.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module MOM_domains
33

44
! This file is part of MOM6. See LICENSE.md for the license.
55

6-
use MOM_coms, only : PE_here, root_PE, num_PEs, MOM_infra_init, MOM_infra_end
6+
use MOM_coms, only : PE_here, root_PE, num_PEs, MOM_infra_init, MOM_infra_end, Get_PElist
77
use MOM_coms, only : broadcast, sum_across_PEs, min_across_PEs, max_across_PEs
88
use MOM_cpu_clock, only : cpu_clock_begin, cpu_clock_end
99
use MOM_error_handler, only : MOM_error, MOM_mesg, NOTE, WARNING, FATAL, is_root_pe
@@ -34,7 +34,7 @@ module MOM_domains
3434

3535
public :: MOM_domains_init, MOM_infra_init, MOM_infra_end, get_domain_extent, get_domain_extent_dsamp2
3636
public :: MOM_define_domain, MOM_define_io_domain, clone_MOM_domain
37-
public :: pass_var, pass_vector, PE_here, root_PE, num_PEs
37+
public :: pass_var, pass_vector, PE_here, root_PE, num_PEs, Get_PElist
3838
public :: pass_var_start, pass_var_complete, fill_symmetric_edges, broadcast
3939
public :: pass_vector_start, pass_vector_complete
4040
public :: global_field_sum, sum_across_PEs, min_across_PEs, max_across_PEs

src/parameterizations/vertical/MOM_energetic_PBL.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, dt, Kd_int, G, GV, US, CS
427427
do K=1,nz+1 ; Kd(K) = 0.0 ; enddo
428428

429429
! Make local copies of surface forcing and process them.
430-
u_star = fluxes%ustar(i,j)
430+
u_star = fluxes%ustar(i,j)*(fluxes%t_rp(i,j))
431431
u_star_Mean = fluxes%ustar_gustless(i,j)
432432
B_flux = buoy_flux(i,j)
433433
if (associated(fluxes%ustar_shelf) .and. associated(fluxes%frac_shelf_h)) then

0 commit comments

Comments
 (0)