@@ -43,7 +43,7 @@ module MOM_ocean_model_nuopc
4343use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_init
4444use MOM_tracer_flow_control, only : call_tracer_flux_init
4545use MOM_unit_scaling, only : unit_scale_type
46- use MOM_variables, only : surface
46+ use MOM_variables, only : surface, stochastic_pattern
4747use MOM_verticalGrid, only : verticalGrid_type
4848use MOM_ice_shelf, only : initialize_ice_shelf, shelf_calc_flux, ice_shelf_CS
4949use MOM_ice_shelf, only : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
@@ -62,6 +62,8 @@ module MOM_ocean_model_nuopc
6262use MOM_surface_forcing_nuopc, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
6363use MOM_surface_forcing_nuopc, only : ice_ocean_boundary_type, surface_forcing_CS
6464use MOM_surface_forcing_nuopc, only : forcing_save_restart
65+ use MOM_domains, only : root_PE,PE_here,Get_PElist,num_PEs
66+ use stochastic_physics, only : init_stochastic_physics_ocn, run_stochastic_physics_ocn
6567
6668#include < MOM_memory.h>
6769
@@ -187,6 +189,7 @@ module MOM_ocean_model_nuopc
187189 ! ! timesteps are taken per thermodynamic step.
188190 type (surface) :: sfc_state ! < A structure containing pointers to
189191 ! ! the ocean surface state fields.
192+ type (stochastic_pattern) :: stochastics ! < A structure containing pointers to
190193 type (ocean_grid_type), pointer :: &
191194 grid = > NULL () ! < A pointer to a grid structure containing metrics
192195 ! ! and related information.
@@ -248,6 +251,13 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
248251 ! ! min(HFrz, OBLD), where OBLD is the boundary layer depth.
249252 ! ! If HFrz <= 0 (default), melt potential will not be computed.
250253 logical :: use_melt_pot! < If true, allocate melt_potential array
254+ ! stochastic physics
255+ integer ,allocatable :: pelist(:) ! list of pes for this instance of the ocean
256+ integer :: mom_comm ! list of pes for this instance of the ocean
257+ integer :: num_procs ! number of processors to pass to stochastic physics
258+ integer :: iret ! return code from stochastic physics
259+ integer :: me ! my pe
260+ integer :: master ! root pe
251261
252262! This include declares and sets the variable "version".
253263#include " version_variable.h"
@@ -416,6 +426,21 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
416426
417427 endif
418428
429+ num_procs= num_PEs()
430+ allocate (pelist(num_procs))
431+ call Get_PElist(pelist,commID = mom_comm)
432+ me= PE_here()
433+ master= root_PE()
434+
435+ call init_stochastic_physics_ocn(OS% dt_therm,OS% grid% geoLonT,OS% grid% geoLatT,OS% grid% ied- OS% grid% isd+1 ,OS% grid% jed- OS% grid% jsd+1 ,OS% grid% ke,&
436+ OS% stochastics% pert_epbl,OS% stochastics% do_sppt,master,mom_comm,iret)
437+ print * ,' after init_stochastic_physics_ocn' ,OS% stochastics% pert_epbl,OS% stochastics% do_sppt
438+
439+ if (OS% stochastics% do_sppt) allocate (OS% stochastics% sppt_wts(OS% grid% isd:OS% grid% ied,OS% grid% jsd:OS% grid% jed))
440+ if (OS% stochastics% pert_epbl) then
441+ allocate (OS% stochastics% t_rp1(OS% grid% isd:OS% grid% ied,OS% grid% jsd:OS% grid% jed))
442+ allocate (OS% stochastics% t_rp2(OS% grid% isd:OS% grid% ied,OS% grid% jsd:OS% grid% jed))
443+ endif
419444 call close_param_file(param_file)
420445 call diag_mediator_close_registration(OS% diag)
421446
@@ -585,17 +610,23 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
585610 call disable_averaging(OS% diag)
586611 Master_time = OS% Time ; Time1 = OS% Time
587612
613+ ! update stochastic physics patterns before running next time-step
614+ print * ,' before call to stoch' ,OS% stochastics% do_sppt .OR. OS% stochastics% pert_epbl
615+ if (OS% stochastics% do_sppt .OR. OS% stochastics% pert_epbl ) then
616+ call run_stochastic_physics_ocn(OS% stochastics% sppt_wts,OS% stochastics% t_rp1,OS% stochastics% t_rp2)
617+ endif
618+
588619 if (OS% offline_tracer_mode) then
589620 call step_offline(OS% forces, OS% fluxes, OS% sfc_state, Time1, dt_coupling, OS% MOM_CSp)
590621 elseif ((.not. do_thermo) .or. (.not. do_dyn)) then
591622 ! The call sequence is being orchestrated from outside of update_ocean_model.
592- call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, Time1, dt_coupling, OS% MOM_CSp, &
623+ call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, OS % stochastics, Time1, dt_coupling, OS% MOM_CSp, &
593624 Waves= OS% Waves, do_dynamics= do_thermo, do_thermodynamics= do_dyn, &
594625 reset_therm= Ocn_fluxes_used)
595626 ! ### What to do with these? , start_cycle=(n==1), end_cycle=.false., cycle_length=dt_coupling)
596627
597628 elseif (OS% single_step_call) then
598- call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, Time1, dt_coupling, OS% MOM_CSp, Waves= OS% Waves)
629+ call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, OS % stochastics, Time1, dt_coupling, OS% MOM_CSp, Waves= OS% Waves)
599630 else
600631 n_max = 1 ; if (dt_coupling > OS% dt) n_max = ceiling (dt_coupling/ OS% dt - 0.001 )
601632 dt_dyn = dt_coupling / real (n_max)
@@ -618,16 +649,16 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
618649 " THERMO_SPANS_COUPLING and DIABATIC_FIRST." )
619650 if (modulo (n-1 ,nts)==0 ) then
620651 dtdia = dt_dyn* min (nts,n_max- (n-1 ))
621- call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, Time2, dtdia, OS% MOM_CSp, &
652+ call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, OS % stochastics, Time2, dtdia, OS% MOM_CSp, &
622653 Waves= OS% Waves, do_dynamics= .false. , do_thermodynamics= .true. , &
623654 start_cycle= (n== 1 ), end_cycle= .false. , cycle_length= dt_coupling)
624655 endif
625656
626- call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, Time2, dt_dyn, OS% MOM_CSp, &
657+ call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, OS % stochastics, Time2, dt_dyn, OS% MOM_CSp, &
627658 Waves= OS% Waves, do_dynamics= .true. , do_thermodynamics= .false. , &
628659 start_cycle= .false. , end_cycle= (n== n_max), cycle_length= dt_coupling)
629660 else
630- call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, Time2, dt_dyn, OS% MOM_CSp, &
661+ call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, OS % stochastics, Time2, dt_dyn, OS% MOM_CSp, &
631662 Waves= OS% Waves, do_dynamics= .true. , do_thermodynamics= .false. , &
632663 start_cycle= (n== 1 ), end_cycle= .false. , cycle_length= dt_coupling)
633664
@@ -644,7 +675,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
644675 if (step_thermo) then
645676 ! Back up Time2 to the start of the thermodynamic segment.
646677 Time2 = Time2 - set_time(int (floor ((dtdia - dt_dyn) + 0.5 )))
647- call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, Time2, dtdia, OS% MOM_CSp, &
678+ call step_MOM(OS% forces, OS% fluxes, OS% sfc_state, OS % stochastics, Time2, dtdia, OS% MOM_CSp, &
648679 Waves= OS% Waves, do_dynamics= .false. , do_thermodynamics= .true. , &
649680 start_cycle= .false. , end_cycle= (n== n_max), cycle_length= dt_coupling)
650681 endif
0 commit comments