Skip to content

Commit

Permalink
remove stochastics container
Browse files Browse the repository at this point in the history
  • Loading branch information
pjpegion committed Feb 4, 2021
1 parent 6e3ea1b commit d984a7e
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 83 deletions.
37 changes: 15 additions & 22 deletions config_src/nuopc_driver/mom_ocean_model_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ module MOM_ocean_model_nuopc
use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_init
use MOM_tracer_flow_control, only : call_tracer_flux_init
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : surface, stochastic_pattern
use MOM_variables, only : surface
use MOM_verticalGrid, only : verticalGrid_type
use MOM_ice_shelf, only : initialize_ice_shelf, shelf_calc_flux, ice_shelf_CS
use MOM_ice_shelf, only : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
use coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type
use coupler_types_mod, only : coupler_type_spawn, coupler_type_write_chksums
use coupler_types_mod, only : coupler_type_initialized, coupler_type_copy_data
use coupler_types_mod, only : coupler_type_set_diags, coupler_type_send_data
use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain
use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain,mpp_get_pelist
use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain
use fms_mod, only : stdout
use mpp_mod, only : mpp_chksum
Expand All @@ -62,7 +62,7 @@ module MOM_ocean_model_nuopc
use MOM_surface_forcing_nuopc, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
use MOM_surface_forcing_nuopc, only : ice_ocean_boundary_type, surface_forcing_CS
use MOM_surface_forcing_nuopc, only : forcing_save_restart
use MOM_domains, only : root_PE,PE_here,Get_PElist,num_PEs
use MOM_domains, only : root_PE,PE_here,num_PEs
use stochastic_physics, only : init_stochastic_physics_ocn, run_stochastic_physics_ocn

#include <MOM_memory.h>
Expand Down Expand Up @@ -191,7 +191,6 @@ module MOM_ocean_model_nuopc
!! timesteps are taken per thermodynamic step.
type(surface) :: sfc_state !< A structure containing pointers to
!! the ocean surface state fields.
type(stochastic_pattern) :: stochastics !< A structure containing pointers to
type(ocean_grid_type), pointer :: &
grid => NULL() !< A pointer to a grid structure containing metrics
!! and related information.
Expand Down Expand Up @@ -254,7 +253,6 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
!! If HFrz <= 0 (default), melt potential will not be computed.
logical :: use_melt_pot!< If true, allocate melt_potential array
! stochastic physics
integer,allocatable :: pelist(:) ! list of pes for this instance of the ocean
integer :: mom_comm ! list of pes for this instance of the ocean
integer :: num_procs ! number of processors to pass to stochastic physics
integer :: iret ! return code from stochastic physics
Expand Down Expand Up @@ -441,8 +439,7 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
default=.false.)
if (OS%do_sppt .OR. OS%pert_epbl) then
num_procs=num_PEs()
allocate(pelist(num_procs))
call Get_PElist(pelist,commID = mom_comm)
call mpp_get_pelist(Ocean_sfc%domain, mom_comm)
me=PE_here()
master=root_PE()

Expand All @@ -455,10 +452,10 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
return
endif

if (OS%do_sppt) allocate(OS%stochastics%sppt_wts(OS%grid%isd:OS%grid%ied,OS%grid%jsd:OS%grid%jed))
if (OS%do_sppt) allocate(OS%fluxes%sppt_wts(OS%grid%isd:OS%grid%ied,OS%grid%jsd:OS%grid%jed))
if (OS%pert_epbl) then
allocate(OS%stochastics%t_rp1(OS%grid%isd:OS%grid%ied,OS%grid%jsd:OS%grid%jed))
allocate(OS%stochastics%t_rp2(OS%grid%isd:OS%grid%ied,OS%grid%jsd:OS%grid%jed))
allocate(OS%fluxes%epbl1_wts(OS%grid%isd:OS%grid%ied,OS%grid%jsd:OS%grid%jed))
allocate(OS%fluxes%epbl2_wts(OS%grid%isd:OS%grid%ied,OS%grid%jsd:OS%grid%jed))
endif
endif
call close_param_file(param_file)
Expand Down Expand Up @@ -632,7 +629,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &

! update stochastic physics patterns before running next time-step
if (OS%do_sppt .OR. OS%pert_epbl ) then
call run_stochastic_physics_ocn(OS%stochastics%sppt_wts,OS%stochastics%t_rp1,OS%stochastics%t_rp2)
call run_stochastic_physics_ocn(OS%fluxes%sppt_wts,OS%fluxes%epbl1_wts,OS%fluxes%epbl2_wts)
endif

if (OS%offline_tracer_mode) then
Expand All @@ -641,12 +638,11 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
! The call sequence is being orchestrated from outside of update_ocean_model.
call step_MOM(OS%forces, OS%fluxes, OS%sfc_state, Time1, dt_coupling, OS%MOM_CSp, &
Waves=OS%Waves, do_dynamics=do_thermo, do_thermodynamics=do_dyn, &
reset_therm=Ocn_fluxes_used, stochastics=OS%stochastics)
reset_therm=Ocn_fluxes_used)
!### What to do with these? , start_cycle=(n==1), end_cycle=.false., cycle_length=dt_coupling)

elseif (OS%single_step_call) then
call step_MOM(OS%forces, OS%fluxes, OS%sfc_state, Time1, dt_coupling, OS%MOM_CSp, Waves=OS%Waves, &
stochastics=OS%stochastics)
call step_MOM(OS%forces, OS%fluxes, OS%sfc_state, Time1, dt_coupling, OS%MOM_CSp, Waves=OS%Waves)
else
n_max = 1 ; if (dt_coupling > OS%dt) n_max = ceiling(dt_coupling/OS%dt - 0.001)
dt_dyn = dt_coupling / real(n_max)
Expand All @@ -671,19 +667,16 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
dtdia = dt_dyn*min(nts,n_max-(n-1))
call step_MOM(OS%forces, OS%fluxes, OS%sfc_state, Time2, dtdia, OS%MOM_CSp, &
Waves=OS%Waves, do_dynamics=.false., do_thermodynamics=.true., &
start_cycle=(n==1), end_cycle=.false., cycle_length=dt_coupling, &
stochastics=OS%stochastics)
start_cycle=(n==1), end_cycle=.false., cycle_length=dt_coupling)
endif

call step_MOM(OS%forces, OS%fluxes, OS%sfc_state, Time2, dt_dyn, OS%MOM_CSp, &
Waves=OS%Waves, do_dynamics=.true., do_thermodynamics=.false., &
start_cycle=.false., end_cycle=(n==n_max), cycle_length=dt_coupling, &
stochastics=OS%stochastics)
start_cycle=.false., end_cycle=(n==n_max), cycle_length=dt_coupling)
else
call step_MOM(OS%forces, OS%fluxes, OS%sfc_state, Time2, dt_dyn, OS%MOM_CSp, &
Waves=OS%Waves, do_dynamics=.true., do_thermodynamics=.false., &
start_cycle=(n==1), end_cycle=.false., cycle_length=dt_coupling, &
stochastics=OS%stochastics)
start_cycle=(n==1), end_cycle=.false., cycle_length=dt_coupling)

step_thermo = .false.
if (thermo_does_span_coupling) then
Expand All @@ -700,8 +693,8 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
Time2 = Time2 - set_time(int(floor((dtdia - dt_dyn) + 0.5)))
call step_MOM(OS%forces, OS%fluxes, OS%sfc_state, Time2, dtdia, OS%MOM_CSp, &
Waves=OS%Waves, do_dynamics=.false., do_thermodynamics=.true., &
start_cycle=.false., end_cycle=(n==n_max), cycle_length=dt_coupling, &
stochastics=OS%stochastics)
start_cycle=.false., end_cycle=(n==n_max), cycle_length=dt_coupling)

endif
endif

Expand Down
15 changes: 5 additions & 10 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ module MOM
!! occur inside of diabatic.
subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS, &
Waves, do_dynamics, do_thermodynamics, start_cycle, &
end_cycle, cycle_length, reset_therm, stochastics)
end_cycle, cycle_length, reset_therm)
type(mech_forcing), target, intent(inout) :: forces_in !< A structure with the driving mechanical forces
type(forcing), target, intent(inout) :: fluxes_in !< A structure with pointers to themodynamic,
!! tracer and mass exchange forcing fields
Expand All @@ -443,7 +443,6 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
logical, optional, intent(in) :: reset_therm !< This indicates whether the running sums of
!! thermodynamic quantities should be reset.
!! If missing, this is like start_cycle.
type(stochastic_pattern), optional, intent(in) :: stochastics !< random patternss for stochastics

! local variables
type(ocean_grid_type), pointer :: G => NULL() ! pointer to a structure containing
Expand Down Expand Up @@ -704,8 +703,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS

! Apply diabatic forcing, do mixing, and regrid.
call step_MOM_thermo(CS, G, GV, US, u, v, h, CS%tv, fluxes, dtdia, &
end_time_thermo, .true., Waves=Waves, &
stochastics=stochastics)
end_time_thermo, .true., Waves=Waves)
CS%time_in_thermo_cycle = CS%time_in_thermo_cycle + dtdia

! The diabatic processes are now ahead of the dynamics by dtdia.
Expand Down Expand Up @@ -803,8 +801,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS

! Apply diabatic forcing, do mixing, and regrid.
call step_MOM_thermo(CS, G, GV, US, u, v, h, CS%tv, fluxes, dtdia, &
Time_local, .false., Waves=Waves, &
stochastics=stochastics)
Time_local, .false., Waves=Waves)
CS%time_in_thermo_cycle = CS%time_in_thermo_cycle + dtdia

if ((CS%t_dyn_rel_thermo==0.0) .and. .not.do_dyn) then
Expand Down Expand Up @@ -1212,7 +1209,7 @@ end subroutine step_MOM_tracer_dyn
!> MOM_step_thermo orchestrates the thermodynamic time stepping and vertical
!! remapping, via calls to diabatic (or adiabatic) and ALE_main.
subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
Time_end_thermo, update_BBL, Waves, stochastics)
Time_end_thermo, update_BBL, Waves)
type(MOM_control_struct), intent(inout) :: CS !< Master MOM control structure
type(ocean_grid_type), intent(inout) :: G !< ocean grid structure
type(verticalGrid_type), intent(inout) :: GV !< ocean vertical grid structure
Expand All @@ -1225,7 +1222,6 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
intent(inout) :: h !< layer thickness [H ~> m or kg m-2]
type(thermo_var_ptrs), intent(inout) :: tv !< A structure pointing to various thermodynamic variables
type(forcing), intent(inout) :: fluxes !< pointers to forcing fields
type(stochastic_pattern), intent(in) :: stochastics !< surface ocean state
real, intent(in) :: dtdia !< The time interval over which to advance [T ~> s]
type(time_type), intent(in) :: Time_end_thermo !< End of averaging interval for thermo diags
logical, intent(in) :: update_BBL !< If true, calculate the bottom boundary layer properties.
Expand Down Expand Up @@ -1288,8 +1284,7 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
call cpu_clock_begin(id_clock_diabatic)

call diabatic(u, v, h, tv, CS%Hml, fluxes, CS%visc, CS%ADp, CS%CDp, dtdia, &
Time_end_thermo, G, GV, US, CS%diabatic_CSp, OBC=CS%OBC, Waves=Waves, &
stochastics=stochastics)
Time_end_thermo, G, GV, US, CS%diabatic_CSp, OBC=CS%OBC, Waves=Waves)
fluxes%fluxes_used = .true.

if (showCallTree) call callTree_waypoint("finished diabatic (step_MOM_thermo)")
Expand Down
4 changes: 4 additions & 0 deletions src/core/MOM_forcing_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ module MOM_forcing_type
!! exactly 0 away from shelves or on land.
real, pointer, dimension(:,:) :: iceshelf_melt => NULL() !< Ice shelf melt rate (positive)
!! or freezing (negative) [R Z T-1 ~> kg m-2 s-1]
! stochastic patterns
real, allocatable :: sppt_wts(:,:) !< Random pattern for ocean SPPT
real, allocatable :: epbl1_wts(:,:) !< Random pattern for K.E. generation
real, allocatable :: epbl2_wts(:,:) !< Random pattern for K.E. dissipation

! Scalars set by surface forcing modules
real :: vPrecGlobalAdj = 0. !< adjustment to restoring vprec to zero out global net [kg m-2 s-1]
Expand Down
5 changes: 0 additions & 5 deletions src/core/MOM_variables.F90
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,6 @@ module MOM_variables

!> Container for information about the summed layer transports
!! and how they will vary as the barotropic velocity is changed.
type, public :: stochastic_pattern
real, allocatable :: sppt_wts(:,:) !< Random pattern for ocean SPPT
real, allocatable :: t_rp1(:,:) !< Random pattern for K.E. generation
real, allocatable :: t_rp2(:,:) !< Random pattern for K.E. dissipation
end type stochastic_pattern
type, public :: BT_cont_type
real, allocatable :: FA_u_EE(:,:) !< The effective open face area for zonal barotropic transport
!! drawing from locations far to the east [H L ~> m2 or kg m-1].
Expand Down
2 changes: 1 addition & 1 deletion src/framework/MOM_domains.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module MOM_domains

public :: MOM_domains_init, MOM_infra_init, MOM_infra_end, get_domain_extent, get_domain_extent_dsamp2
public :: MOM_define_domain, MOM_define_io_domain, clone_MOM_domain
public :: pass_var, pass_vector, PE_here, root_PE, num_PEs, Get_PElist
public :: pass_var, pass_vector, PE_here, root_PE, num_PEs
public :: pass_var_start, pass_var_complete, fill_symmetric_edges, broadcast
public :: pass_vector_start, pass_vector_complete
public :: global_field_sum, sum_across_PEs, min_across_PEs, max_across_PEs
Expand Down
Loading

0 comments on commit d984a7e

Please sign in to comment.