Skip to content

Commit 0a62737

Browse files
authored
Merge branch 'ocn_stoch' into dev/emc_merge
2 parents 3cad1ba + c2aa2a8 commit 0a62737

6 files changed

Lines changed: 59 additions & 6 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
@@ -298,6 +298,8 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
298298

299299
call safe_alloc_ptr(fluxes%p_surf ,isd,ied,jsd,jed)
300300
call safe_alloc_ptr(fluxes%p_surf_full,isd,ied,jsd,jed)
301+
print*,'allocate fluxes%t_rp'
302+
call safe_alloc_ptr(fluxes%t_rp,isd,ied,jsd,jed)
301303
if (CS%use_limited_P_SSH) then
302304
fluxes%p_surf_SSH => fluxes%p_surf
303305
else

src/core/MOM.F90

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module MOM
2929
use MOM_domains, only : To_All, Omit_corners, CGRID_NE, SCALAR_PAIR
3030
use MOM_domains, only : create_group_pass, do_group_pass, group_pass_type
3131
use MOM_domains, only : start_group_pass, complete_group_pass, Omit_Corners
32+
use MOM_domains, only : root_PE,PE_here,Get_PElist,num_PEs
3233
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING, is_root_pe
3334
use MOM_error_handler, only : MOM_set_verbosity, callTree_showQuery
3435
use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint
@@ -141,6 +142,7 @@ module MOM
141142
use MOM_offline_main, only : offline_fw_fluxes_into_ocean, offline_fw_fluxes_out_ocean
142143
use MOM_offline_main, only : offline_advection_layer, offline_transport_end
143144
use MOM_ALE, only : ale_offline_tracer_final, ALE_main_offline
145+
use stochastic_physics, only : init_stochastic_physics_ocn,run_stochastic_physics_ocn
144146

145147
implicit none ; private
146148

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

231235
type(time_type), pointer :: Time !< pointer to the ocean clock
232236
real :: dt !< (baroclinic) dynamics time step [T ~> s]
@@ -757,6 +761,9 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
757761
enddo ; enddo
758762
endif
759763

764+
print*,'calling run_stochastic_physics_ocn',CS%do_stochy
765+
if (CS%do_stochy) call run_stochastic_physics_ocn(forces%t_rp)
766+
760767
call step_MOM_dynamics(forces, CS%p_surf_begin, CS%p_surf_end, dt, &
761768
dt_therm_here, bbl_time_int, CS, &
762769
Time_local, Waves=Waves)
@@ -904,7 +911,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
904911
if (CS%time_in_thermo_cycle > 0.0) then
905912
call enable_averages(CS%time_in_thermo_cycle, Time_local, CS%diag)
906913
call post_surface_thermo_diags(CS%sfc_IDs, G, GV, US, CS%diag, CS%time_in_thermo_cycle, &
907-
sfc_state_diag, CS%tv, ssh, CS%ave_ssh_ibc)
914+
sfc_state_diag, CS%tv, ssh,fluxes%t_rp, CS%ave_ssh_ibc)
908915
endif
909916
call disable_averaging(CS%diag)
910917
call cpu_clock_end(id_clock_diagnostics)
@@ -1672,6 +1679,11 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
16721679
integer :: nkml, nkbl, verbosity, write_geom
16731680
integer :: dynamics_stencil ! The computational stencil for the calculations
16741681
! in the dynamic core.
1682+
integer,allocatable :: pelist(:) ! list of pes for this instance of the ocean
1683+
integer :: num_procs
1684+
! model
1685+
integer :: me ! my pe
1686+
integer :: master ! root pe
16751687
real :: conv2watt, conv2salt
16761688
real :: RL2_T2_rescale, Z_rescale, QRZ_rescale ! Unit conversion factors
16771689
character(len=48) :: flux_units, S_flux_units
@@ -2328,6 +2340,17 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
23282340
call copy_dyngrid_to_MOM_grid(dG_in, G_in, US)
23292341
call destroy_dyn_horgrid(dG_in)
23302342

2343+
num_procs=num_PEs()
2344+
allocate(pelist(num_procs))
2345+
call Get_PElist(pelist)
2346+
me=PE_here()
2347+
master=root_PE()
2348+
2349+
!call init_stochastic_physics_ocn(CS%dt_therm,G,me,master,pelist,CS%do_stochy)
2350+
print*,'callling init_stochastic_physics_ocn',maxval(G%geoLatT)
2351+
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)
2352+
print*,'back from init_stochastic_physics_ocn',CS%do_stochy
2353+
23312354
! Set a few remaining fields that are specific to the ocean grid type.
23322355
call set_first_direction(G, first_direction)
23332356
! 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
@@ -141,6 +141,8 @@ module MOM_forcing_type
141141
!< Pressure at the top ocean interface [R L2 T-2 ~> Pa] that is used in corrections to the sea surface
142142
!! height field that is passed back to the calling routines.
143143
!! p_surf_SSH may point to p_surf or to p_surf_full.
144+
real, pointer, dimension(:,:) :: t_rp => NULL()
145+
!< random pattern at t-points
144146
logical :: accumulate_p_surf = .false. !< If true, the surface pressure due to the atmosphere
145147
!! and various types of ice needs to be accumulated, and the
146148
!! surface pressure explicitly reset to zero at the driver level
@@ -238,6 +240,8 @@ module MOM_forcing_type
238240
!! u-points [L4 Z-1 T-1 ~> m3 s-1]
239241
rigidity_ice_v => NULL() !< Depth-integrated lateral viscosity of ice shelves or sea ice at
240242
!! v-points [L4 Z-1 T-1 ~> m3 s-1]
243+
real, pointer, dimension(:,:) :: t_rp => NULL()
244+
!< random pattern at t-points
241245
real :: dt_force_accum = -1.0 !< The amount of time over which the mechanical forcing fluxes
242246
!! have been averaged [s].
243247
logical :: net_mass_src_set = .false. !< If true, an estimate of net_mass_src has been provided.
@@ -2078,6 +2082,12 @@ subroutine copy_common_forcing_fields(forces, fluxes, G, skip_pres)
20782082

20792083
do_pres = .true. ; if (present(skip_pres)) do_pres = .not.skip_pres
20802084

2085+
if (associated(forces%t_rp) .and. associated(fluxes%t_rp)) then
2086+
do j=js,je ; do i=is,ie
2087+
fluxes%t_rp(i,j) = forces%t_rp(i,j)
2088+
enddo ; enddo
2089+
endif
2090+
20812091
if (associated(forces%ustar) .and. associated(fluxes%ustar)) then
20822092
do j=js,je ; do i=is,ie
20832093
fluxes%ustar(i,j) = forces%ustar(i,j)
@@ -3021,6 +3031,7 @@ subroutine allocate_mech_forcing_by_group(G, forces, stress, ustar, shelf, &
30213031
call myAlloc(forces%p_surf,isd,ied,jsd,jed, press)
30223032
call myAlloc(forces%p_surf_full,isd,ied,jsd,jed, press)
30233033
call myAlloc(forces%net_mass_src,isd,ied,jsd,jed, press)
3034+
call myAlloc(forces%t_rp,isd,ied,jsd,jed, press)
30243035

30253036
call myAlloc(forces%rigidity_ice_u,IsdB,IedB,jsd,jed, shelf)
30263037
call myAlloc(forces%rigidity_ice_v,isd,ied,JsdB,JedB, shelf)
@@ -3176,6 +3187,7 @@ subroutine deallocate_forcing_type(fluxes)
31763187
if (associated(fluxes%seaice_melt)) deallocate(fluxes%seaice_melt)
31773188
if (associated(fluxes%salt_flux)) deallocate(fluxes%salt_flux)
31783189
if (associated(fluxes%p_surf_full)) deallocate(fluxes%p_surf_full)
3190+
if (associated(fluxes%t_rp)) deallocate(fluxes%t_rp)
31793191
if (associated(fluxes%p_surf)) deallocate(fluxes%p_surf)
31803192
if (associated(fluxes%TKE_tidal)) deallocate(fluxes%TKE_tidal)
31813193
if (associated(fluxes%ustar_tidal)) deallocate(fluxes%ustar_tidal)
@@ -3200,6 +3212,7 @@ subroutine deallocate_mech_forcing(forces)
32003212
if (associated(forces%ustar)) deallocate(forces%ustar)
32013213
if (associated(forces%p_surf)) deallocate(forces%p_surf)
32023214
if (associated(forces%p_surf_full)) deallocate(forces%p_surf_full)
3215+
if (associated(forces%t_rp)) deallocate(forces%t_rp)
32033216
if (associated(forces%net_mass_src)) deallocate(forces%net_mass_src)
32043217
if (associated(forces%rigidity_ice_u)) deallocate(forces%rigidity_ice_u)
32053218
if (associated(forces%rigidity_ice_v)) deallocate(forces%rigidity_ice_v)

src/diagnostics/MOM_diagnostics.F90

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ module MOM_diagnostics
169169
integer :: id_salt_deficit = -1
170170
integer :: id_Heat_PmE = -1
171171
integer :: id_intern_heat = -1
172-
!>@}
172+
! stochastic pattern
173+
integer :: id_t_rp = -1
174+
!!@}
173175
end type surface_diag_IDs
174176

175177

@@ -1197,7 +1199,7 @@ end subroutine post_surface_dyn_diags
11971199
!> This routine posts diagnostics of various ocean surface and integrated
11981200
!! quantities at the time the ocean state is reported back to the caller
11991201
subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv, &
1200-
ssh, ssh_ibc)
1202+
ssh, t_rp, ssh_ibc)
12011203
type(surface_diag_IDs), intent(in) :: IDs !< A structure with the diagnostic IDs.
12021204
type(ocean_grid_type), intent(in) :: G !< ocean grid structure
12031205
type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
@@ -1208,6 +1210,8 @@ subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv
12081210
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables
12091211
real, dimension(SZI_(G),SZJ_(G)), &
12101212
intent(in) :: ssh !< Time mean surface height without corrections for ice displacement [m]
1213+
real, dimension(SZI_(G),SZJ_(G)), &
1214+
intent(in) :: t_rp!< random pattern for stochastic proceeses
12111215
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: ssh_ibc !< Time mean surface height with corrections
12121216
!! for ice displacement and the inverse barometer [m]
12131217

@@ -1332,6 +1336,11 @@ subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv
13321336
call post_data(IDs%id_sss_sq, work_2d, diag, mask=G%mask2dT)
13331337
endif
13341338

1339+
if (IDs%id_t_rp > 0) then
1340+
!call post_data(IDs%id_t_rp, t_rp, diag, mask=G%mask2dT)
1341+
call post_data(IDs%id_t_rp, t_rp, diag)
1342+
endif
1343+
13351344
call coupler_type_send_data(sfc_state%tr_fields, get_diag_time_end(diag))
13361345

13371346
end subroutine post_surface_thermo_diags
@@ -1833,6 +1842,9 @@ subroutine register_surface_diags(Time, G, US, IDs, diag, tv)
18331842
IDs%id_intern_heat = register_diag_field('ocean_model', 'internal_heat', diag%axesT1, Time,&
18341843
'Heat flux into ocean from geothermal or other internal sources', &
18351844
'W m-2', conversion=US%QRZ_T_to_W_m2)
1845+
IDs%id_t_rp = register_diag_field('ocean_model', 'random_pattern', diag%axesT1, Time, &
1846+
'random pattern for stochastics', 'None')
1847+
18361848

18371849
end subroutine register_surface_diags
18381850

src/framework/MOM_domains.F90

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

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

6+
67
use MOM_array_transform, only : rotate_array
7-
use MOM_coms, only : PE_here, root_PE, num_PEs, MOM_infra_init, MOM_infra_end
8+
use MOM_coms, only : PE_here, root_PE, num_PEs, MOM_infra_init, MOM_infra_end, Get_PElist
9+
10+
use MOM_coms, only : PE_here, root_PE, num_PEs, MOM_infra_init, MOM_infra_end, Get_PElist
811
use MOM_coms, only : broadcast, sum_across_PEs, min_across_PEs, max_across_PEs
912
use MOM_cpu_clock, only : cpu_clock_begin, cpu_clock_end
1013
use MOM_error_handler, only : MOM_error, MOM_mesg, NOTE, WARNING, FATAL, is_root_pe
@@ -35,7 +38,7 @@ module MOM_domains
3538

3639
public :: MOM_domains_init, MOM_infra_init, MOM_infra_end, get_domain_extent, get_domain_extent_dsamp2
3740
public :: MOM_define_domain, MOM_define_io_domain, clone_MOM_domain
38-
public :: pass_var, pass_vector, PE_here, root_PE, num_PEs
41+
public :: pass_var, pass_vector, PE_here, root_PE, num_PEs, Get_PElist
3942
public :: pass_var_start, pass_var_complete, fill_symmetric_edges, broadcast
4043
public :: pass_vector_start, pass_vector_complete
4144
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
@@ -435,7 +435,7 @@ subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, dt, Kd_int, G, GV, US, CS
435435
do K=1,nz+1 ; Kd(K) = 0.0 ; enddo
436436

437437
! Make local copies of surface forcing and process them.
438-
u_star = fluxes%ustar(i,j)
438+
u_star = fluxes%ustar(i,j)*(fluxes%t_rp(i,j))
439439
u_star_Mean = fluxes%ustar_gustless(i,j)
440440
B_flux = buoy_flux(i,j)
441441
if (associated(fluxes%ustar_shelf) .and. associated(fluxes%frac_shelf_h)) then

0 commit comments

Comments
 (0)