|
| 1 | +!> Top-level module for the MOM6 ocean model in coupled mode. |
| 2 | +module MOM_stochastics |
| 3 | + |
| 4 | +! This file is part of MOM6. See LICENSE.md for the license. |
| 5 | + |
| 6 | +! This is the top level module for the MOM6 ocean model. It contains routines |
| 7 | +! for initialization, update, and writing restart of stochastic physics. This |
| 8 | +! particular version wraps all of the calls for MOM6 in the calls that had |
| 9 | +! been used for MOM4. |
| 10 | +! |
| 11 | +use MOM_diag_mediator, only : register_diag_field, diag_ctrl, time_type |
| 12 | +use MOM_grid, only : ocean_grid_type |
| 13 | +use MOM_verticalGrid, only : verticalGrid_type |
| 14 | +use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe |
| 15 | +use MOM_error_handler, only : callTree_enter, callTree_leave |
| 16 | +use MOM_file_parser, only : get_param, log_version, close_param_file, param_file_type |
| 17 | +use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain |
| 18 | +use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain |
| 19 | +use MOM_domains, only : root_PE,num_PEs |
| 20 | +use MOM_coms, only : Get_PElist |
| 21 | +use stochastic_physics, only : init_stochastic_physics_ocn, run_stochastic_physics_ocn |
| 22 | + |
| 23 | +#include <MOM_memory.h> |
| 24 | + |
| 25 | +implicit none ; private |
| 26 | + |
| 27 | +public stochastics_init, update_stochastics |
| 28 | + |
| 29 | +!> This control structure holds parameters for the MOM_stochastics module |
| 30 | +type, public:: stochastic_CS |
| 31 | + logical :: do_sppt !< If true, stochastically perturb the diabatic |
| 32 | + logical :: pert_epbl !< If true, then randomly perturb the KE dissipation and genration terms |
| 33 | + integer :: id_sppt_wts = -1 !< Diagnostic id for SPPT |
| 34 | + integer :: id_epbl1_wts=-1 !< Diagnostic id for epbl generation perturbation |
| 35 | + integer :: id_epbl2_wts=-1 !< Diagnostic id for epbl dissipation perturbation |
| 36 | + ! stochastic patterns |
| 37 | + real, allocatable :: sppt_wts(:,:) !< Random pattern for ocean SPPT |
| 38 | + !! tendencies with a number between 0 and 2 |
| 39 | + real, allocatable :: epbl1_wts(:,:) !< Random pattern for K.E. generation |
| 40 | + real, allocatable :: epbl2_wts(:,:) !< Random pattern for K.E. dissipation |
| 41 | + type(diag_ctrl), pointer :: diag !< structure used to regulate timing of diagnostic output |
| 42 | + type(time_type), pointer :: Time !< Pointer to model time (needed for sponges) |
| 43 | +end type stochastic_CS |
| 44 | + |
| 45 | +contains |
| 46 | + |
| 47 | +!! This subroutine initializes the stochastics physics control structure. |
| 48 | +subroutine stochastics_init(dt, grid, GV, CS, param_file, diag, Time) |
| 49 | + real, intent(in) :: dt !< time step [T ~> s] |
| 50 | + type(ocean_grid_type), intent(in) :: grid !< horizontal grid information |
| 51 | + type(verticalGrid_type), intent(in) :: GV !< vertical grid structure |
| 52 | + type(stochastic_CS), pointer, intent(inout):: CS !< stochastic control structure |
| 53 | + type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters |
| 54 | + type(diag_ctrl), target, intent(inout) :: diag !< structure to regulate diagnostic output |
| 55 | + type(time_type), target :: Time !< model time |
| 56 | + ! Local variables |
| 57 | + integer,allocatable :: pelist(:) ! list of pes for this instance of the ocean |
| 58 | + integer :: mom_comm ! list of pes for this instance of the ocean |
| 59 | + integer :: num_procs ! number of processors to pass to stochastic physics |
| 60 | + integer :: iret ! return code from stochastic physics |
| 61 | + integer :: me ! my pe |
| 62 | + integer :: pe_zero ! root pe |
| 63 | + integer :: nx ! number of x-points including halo |
| 64 | + integer :: ny ! number of x-points including halo |
| 65 | + |
| 66 | +! This include declares and sets the variable "version". |
| 67 | +#include "version_variable.h" |
| 68 | + character(len=40) :: mdl = "ocean_stochastics_init" ! This module's name. |
| 69 | + |
| 70 | + call callTree_enter("ocean_model_stochastic_init(), MOM_stochastics.F90") |
| 71 | + if (associated(CS)) then |
| 72 | + call MOM_error(WARNING, "MOM_stochastics_init called with an "// & |
| 73 | + "associated control structure.") |
| 74 | + return |
| 75 | + else ; allocate(CS) ; endif |
| 76 | + |
| 77 | + CS%diag => diag |
| 78 | + CS%Time => Time |
| 79 | + |
| 80 | + ! Read all relevant parameters and write them to the model log. |
| 81 | + call log_version(param_file, mdl, version, "") |
| 82 | + |
| 83 | +! get number of processors and PE list for stocasthci physics initialization |
| 84 | + call get_param(param_file, mdl, "DO_SPPT", CS%do_sppt, & |
| 85 | + "If true, then stochastically perturb the thermodynamic "//& |
| 86 | + "tendemcies of T,S, amd h. Amplitude and correlations are "//& |
| 87 | + "controlled by the nam_stoch namelist in the UFS model only.", & |
| 88 | + default=.false.) |
| 89 | + call get_param(param_file, mdl, "PERT_EPBL", CS%pert_epbl, & |
| 90 | + "If true, then stochastically perturb the kinetic energy "//& |
| 91 | + "production and dissipation terms. Amplitude and correlations are "//& |
| 92 | + "controlled by the nam_stoch namelist in the UFS model only.", & |
| 93 | + default=.false.) |
| 94 | + if (CS%do_sppt .OR. CS%pert_epbl) then |
| 95 | + num_procs=num_PEs() |
| 96 | + allocate(pelist(num_procs)) |
| 97 | + call Get_PElist(pelist,commID = mom_comm) |
| 98 | + pe_zero=root_PE() |
| 99 | + nx = grid%ied - grid%isd + 1 |
| 100 | + ny = grid%jed - grid%jsd + 1 |
| 101 | + call init_stochastic_physics_ocn(dt,grid%geoLonT,grid%geoLatT,nx,ny,GV%ke, & |
| 102 | + CS%pert_epbl,CS%do_sppt,pe_zero,mom_comm,iret) |
| 103 | + if (iret/=0) then |
| 104 | + call MOM_error(FATAL, "call to init_stochastic_physics_ocn failed") |
| 105 | + return |
| 106 | + endif |
| 107 | + |
| 108 | + if (CS%do_sppt) allocate(CS%sppt_wts(grid%isd:grid%ied,grid%jsd:grid%jed)) |
| 109 | + if (CS%pert_epbl) then |
| 110 | + allocate(CS%epbl1_wts(grid%isd:grid%ied,grid%jsd:grid%jed)) |
| 111 | + allocate(CS%epbl2_wts(grid%isd:grid%ied,grid%jsd:grid%jed)) |
| 112 | + endif |
| 113 | + endif |
| 114 | + CS%id_sppt_wts = register_diag_field('ocean_model', 'sppt_pattern', CS%diag%axesT1, Time, & |
| 115 | + 'random pattern for sppt', 'None') |
| 116 | + CS%id_epbl1_wts = register_diag_field('ocean_model', 'epbl1_wts', CS%diag%axesT1, Time, & |
| 117 | + 'random pattern for KE generation', 'None') |
| 118 | + CS%id_epbl2_wts = register_diag_field('ocean_model', 'epbl2_wts', CS%diag%axesT1, Time, & |
| 119 | + 'random pattern for KE dissipation', 'None') |
| 120 | + |
| 121 | + if (is_root_pe()) & |
| 122 | + write(*,'(/12x,a/)') '=== COMPLETED MOM STOCHASTIC INITIALIZATION =====' |
| 123 | + |
| 124 | + call callTree_leave("ocean_model_init(") |
| 125 | + return |
| 126 | +end subroutine stochastics_init |
| 127 | + |
| 128 | +!> update_ocean_model uses the forcing in Ice_ocean_boundary to advance the |
| 129 | +!! ocean model's state from the input value of Ocean_state (which must be for |
| 130 | +!! time time_start_update) for a time interval of Ocean_coupling_time_step, |
| 131 | +!! returning the publicly visible ocean surface properties in Ocean_sfc and |
| 132 | +!! storing the new ocean properties in Ocean_state. |
| 133 | +subroutine update_stochastics(CS) |
| 134 | + type(stochastic_CS), intent(inout) :: CS !< diabatic control structure |
| 135 | + call callTree_enter("update_stochastics(), MOM_stochastics.F90") |
| 136 | + |
| 137 | +! update stochastic physics patterns before running next time-step |
| 138 | + call run_stochastic_physics_ocn(CS%sppt_wts,CS%epbl1_wts,CS%epbl2_wts) |
| 139 | + |
| 140 | + return |
| 141 | +end subroutine update_stochastics |
| 142 | + |
| 143 | +end module MOM_stochastics |
| 144 | + |
0 commit comments