MOM6
MOM_variables.F90
Go to the documentation of this file.
1 !> Provides transparent structures with groups of MOM6 variables and supporting routines
3 
4 ! This file is part of MOM6. See LICENSE.md for the license.
5 
6 use mom_domains, only : mom_domain_type, get_domain_extent, group_pass_type
7 use mom_debugging, only : hchksum
8 use mom_error_handler, only : mom_error, fatal
9 use mom_grid, only : ocean_grid_type
10 use mom_eos, only : eos_type
11 
12 use coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type
13 use coupler_types_mod, only : coupler_type_spawn, coupler_type_destructor
14 
15 implicit none ; private
16 
17 #include <MOM_memory.h>
18 
21 
22 ! A note on unit descriptions in comments: MOM6 uses units that can be rescaled for dimensional
23 ! consistency testing. These are noted in comments with units like Z, H, L, and T, along with
24 ! their mks counterparts with notation like "a velocity [Z T-1 ~> m s-1]". If the units
25 ! vary with the Boussinesq approximation, the Boussinesq variant is given first.
26 
27 !> A structure for creating arrays of pointers to 3D arrays
28 type, public :: p3d
29  real, dimension(:,:,:), pointer :: p => null() !< A pointer to a 3D array
30 end type p3d
31 !> A structure for creating arrays of pointers to 2D arrays
32 type, public :: p2d
33  real, dimension(:,:), pointer :: p => null() !< A pointer to a 2D array
34 end type p2d
35 
36 !> Pointers to various fields which may be used describe the surface state of MOM, and which
37 !! will be returned to a the calling program
38 type, public :: surface
39  real, allocatable, dimension(:,:) :: &
40  sst, & !< The sea surface temperature [degC].
41  sss, & !< The sea surface salinity [ppt ~> psu or gSalt/kg].
42  sfc_density, & !< The mixed layer density [kg m-3].
43  hml, & !< The mixed layer depth [m].
44  u, & !< The mixed layer zonal velocity [m s-1].
45  v, & !< The mixed layer meridional velocity [m s-1].
46  sea_lev, & !< The sea level [m]. If a reduced surface gravity is
47  !! used, that is compensated for in sea_lev.
48  melt_potential, & !< Instantaneous amount of heat that can be used to melt sea ice [J m-2].
49  !! This is computed w.r.t. surface freezing temperature.
50  ocean_mass, & !< The total mass of the ocean [kg m-2].
51  ocean_heat, & !< The total heat content of the ocean in [degC kg m-2].
52  ocean_salt, & !< The total salt content of the ocean in [kgSalt m-2].
53  taux_shelf, & !< The zonal stresses on the ocean under shelves [Pa].
54  tauy_shelf, & !< The meridional stresses on the ocean under shelves [Pa].
55  tempxpme, & !< The net inflow of water into the ocean times the temperature at which this
56  !! inflow occurs during the call to step_MOM [degC kg m-2].
57  salt_deficit, & !< The salt needed to maintain the ocean column at a minimum
58  !! salinity of 0.01 PSU over the call to step_MOM [kgSalt m-2].
59  internal_heat !< Any internal or geothermal heat sources that are applied to the ocean
60  !! integrated over the call to step_MOM [degC kg m-2].
61  logical :: t_is_cont = .false. !< If true, the temperature variable SST is actually the
62  !! conservative temperature in [degC].
63  logical :: s_is_abss = .false. !< If true, the salinity variable SSS is actually the
64  !! absolute salinity in [g/kg].
65  real, pointer, dimension(:,:) :: frazil => null()
66  !< The energy needed to heat the ocean column to the freezing point during the call
67  !! to step_MOM [J m-2].
68  type(coupler_2d_bc_type) :: tr_fields !< A structure that may contain an
69  !! array of named fields describing tracer-related quantities.
70  !### NOTE: ALL OF THE ARRAYS IN TR_FIELDS USE THE COUPLER'S INDEXING CONVENTION AND HAVE NO
71  !### HALOS! THIS IS DONE TO CONFORM TO THE TREATMENT IN MOM4, BUT I DON'T LIKE IT! -RWH
72  logical :: arrays_allocated = .false. !< A flag that indicates whether the surface type
73  !! has had its memory allocated.
74 end type surface
75 
76 !> Pointers to an assortment of thermodynamic fields that may be available, including
77 !! potential temperature, salinity, heat capacity, and the equation of state control structure.
78 type, public :: thermo_var_ptrs
79  ! If allocated, the following variables have nz layers.
80  real, pointer :: t(:,:,:) => null() !< Potential temperature [degC].
81  real, pointer :: s(:,:,:) => null() !< Salnity [PSU] or [gSalt/kg], generically [ppt].
82  type(eos_type), pointer :: eqn_of_state => null() !< Type that indicates the
83  !! equation of state to use.
84  real :: p_ref !< The coordinate-density reference pressure [Pa].
85  !! This is the pressure used to calculate Rml from
86  !! T and S when eqn_of_state is associated.
87  real :: c_p !< The heat capacity of seawater [J degC-1 kg-1].
88  !! When conservative temperature is used, this is
89  !! constant and exactly 3991.86795711963 J degC-1 kg-1.
90  logical :: t_is_cont = .false. !< If true, the temperature variable tv%T is
91  !! actually the conservative temperature [degC].
92  logical :: s_is_abss = .false. !< If true, the salinity variable tv%S is
93  !! actually the absolute salinity in units of [gSalt/kg].
94  real :: min_salinity = 0.01 !< The minimum value of salinity when BOUND_SALINITY=True [ppt].
95  !! The default is 0.01 for backward compatibility but should be 0.
96  ! These arrays are accumulated fluxes for communication with other components.
97  real, dimension(:,:), pointer :: frazil => null()
98  !< The energy needed to heat the ocean column to the
99  !! freezing point since calculate_surface_state was2
100  !! last called [J m-2].
101  real, dimension(:,:), pointer :: salt_deficit => null()
102  !< The salt needed to maintain the ocean column
103  !! at a minimum salinity of MIN_SALINITY since the last time
104  !! that calculate_surface_state was called, [ppt R Z ~> gSalt m-2].
105  real, dimension(:,:), pointer :: tempxpme => null()
106  !< The net inflow of water into the ocean times the
107  !! temperature at which this inflow occurs since the
108  !! last call to calculate_surface_state [degC R Z ~> degC kg m-2].
109  !! This should be prescribed in the forcing fields, but
110  !! as it often is not, this is a useful heat budget diagnostic.
111  real, dimension(:,:), pointer :: internal_heat => null()
112  !< Any internal or geothermal heat sources that
113  !! have been applied to the ocean since the last call to
114  !! calculate_surface_state [degC kg m-2].
115 end type thermo_var_ptrs
116 
117 !> Pointers to all of the prognostic variables allocated in MOM_variables.F90 and MOM.F90.
118 !!
119 !! It is useful for sending these variables for diagnostics, and in preparation for ensembles
120 !! later on. All variables have the same names as the local (public) variables
121 !! they refer to in MOM.F90.
122 type, public :: ocean_internal_state
123  real, pointer, dimension(:,:,:) :: &
124  t => null(), & !< Pointer to the temperature state variable [degC]
125  s => null(), & !< Pointer to the salinity state variable [ppt ~> PSU or g/kg]
126  u => null(), & !< Pointer to the zonal velocity [L T-1 ~> m s-1]
127  v => null(), & !< Pointer to the meridional velocity [L T-1 ~> m s-1]
128  h => null() !< Pointer to the layer thicknesses [H ~> m or kg m-2]
129  real, pointer, dimension(:,:,:) :: &
130  uh => null(), & !< Pointer to zonal transports [H L2 T-1 ~> m3 s-1 or kg s-1]
131  vh => null() !< Pointer to meridional transports [H L2 T-1 ~> m3 s-1 or kg s-1]
132  real, pointer, dimension(:,:,:) :: &
133  cau => null(), & !< Pointer to the zonal Coriolis and Advective acceleration [L T-2 ~> m s-2]
134  cav => null(), & !< Pointer to the meridional Coriolis and Advective acceleration [L T-2 ~> m s-2]
135  pfu => null(), & !< Pointer to the zonal Pressure force acceleration [L T-2 ~> m s-2]
136  pfv => null(), & !< Pointer to the meridional Pressure force acceleration [L T-2 ~> m s-2]
137  diffu => null(), & !< Pointer to the zonal acceleration due to lateral viscosity [L T-2 ~> m s-2]
138  diffv => null(), & !< Pointer to the meridional acceleration due to lateral viscosity [L T-2 ~> m s-2]
139  pbce => null(), & !< Pointer to the baroclinic pressure force dependency on free surface movement
140  !! [L2 T-2 H-1 ~> m s-2 or m4 kg-1 s-2]
141  u_accel_bt => null(), & !< Pointer to the zonal barotropic-solver acceleration [L T-2 ~> m s-2]
142  v_accel_bt => null() !< Pointer to the meridional barotropic-solver acceleration [L T-2 ~> m s-2]
143  real, pointer, dimension(:,:,:) :: &
144  u_av => null(), & !< Pointer to zonal velocity averaged over the timestep [L T-1 ~> m s-1]
145  v_av => null(), & !< Pointer to meridional velocity averaged over the timestep [L T-1 ~> m s-1]
146  u_prev => null(), & !< Pointer to zonal velocity at the end of the last timestep [L T-1 ~> m s-1]
147  v_prev => null() !< Pointer to meridional velocity at the end of the last timestep [L T-1 ~> m s-1]
148 end type ocean_internal_state
149 
150 !> Pointers to arrays with accelerations, which can later be used for derived diagnostics, like energy balances.
151 type, public :: accel_diag_ptrs
152 
153  ! Each of the following fields has nz layers.
154  real, pointer, dimension(:,:,:) :: &
155  diffu => null(), & !< Zonal acceleration due to along isopycnal viscosity [L T-2 ~> m s-2]
156  diffv => null(), & !< Meridional acceleration due to along isopycnal viscosity [L T-2 ~> m s-2]
157  cau => null(), & !< Zonal Coriolis and momentum advection accelerations [L T-2 ~> m s-2]
158  cav => null(), & !< Meridional Coriolis and momentum advection accelerations [L T-2 ~> m s-2]
159  pfu => null(), & !< Zonal acceleration due to pressure forces [L T-2 ~> m s-2]
160  pfv => null(), & !< Meridional acceleration due to pressure forces [L T-2 ~> m s-2]
161  du_dt_visc => null(), &!< Zonal acceleration due to vertical viscosity [L T-2 ~> m s-2]
162  dv_dt_visc => null(), &!< Meridional acceleration due to vertical viscosity [L T-2 ~> m s-2]
163  du_dt_dia => null(), & !< Zonal acceleration due to diapycnal mixing [L T-2 ~> m s-2]
164  dv_dt_dia => null() !< Meridional acceleration due to diapycnal mixing [L T-2 ~> m s-2]
165  real, pointer, dimension(:,:,:) :: du_other => null()
166  !< Zonal velocity changes due to any other processes that are
167  !! not due to any explicit accelerations [L T-1 ~> m s-1].
168  real, pointer, dimension(:,:,:) :: dv_other => null()
169  !< Meridional velocity changes due to any other processes that are
170  !! not due to any explicit accelerations [L T-1 ~> m s-1].
171 
172  ! These accelerations are sub-terms included in the accelerations above.
173  real, pointer :: gradkeu(:,:,:) => null() !< gradKEu = - d/dx(u2) [L T-2 ~> m s-2]
174  real, pointer :: gradkev(:,:,:) => null() !< gradKEv = - d/dy(u2) [L T-2 ~> m s-2]
175  real, pointer :: rv_x_v(:,:,:) => null() !< rv_x_v = rv * v at u [L T-2 ~> m s-2]
176  real, pointer :: rv_x_u(:,:,:) => null() !< rv_x_u = rv * u at v [L T-2 ~> m s-2]
177 
178 end type accel_diag_ptrs
179 
180 !> Pointers to arrays with transports, which can later be used for derived diagnostics, like energy balances.
181 type, public :: cont_diag_ptrs
182 
183 ! Each of the following fields has nz layers.
184  real, pointer, dimension(:,:,:) :: &
185  uh => null(), & !< Resolved zonal layer thickness fluxes, [H L2 T-1 ~> m3 s-1 or kg s-1]
186  vh => null(), & !< Resolved meridional layer thickness fluxes, [H L2 T-1 ~> m3 s-1 or kg s-1]
187  uhgm => null(), & !< Isopycnal height diffusion induced zonal volume fluxes [H L2 T-1 ~> m3 s-1 or kg s-1]
188  vhgm => null() !< Isopycnal height diffusion induced meridional volume fluxes [H L2 T-1 ~> m3 s-1 or kg s-1]
189 
190 ! Each of the following fields is found at nz+1 interfaces.
191  real, pointer :: diapyc_vel(:,:,:) => null() !< The net diapycnal velocity [H s-1 ~> m s-1 or kg m-2 s-1]
192 
193 end type cont_diag_ptrs
194 
195 !> Vertical viscosities, drag coefficients, and related fields.
196 type, public :: vertvisc_type
197  real :: prandtl_turb !< The Prandtl number for the turbulent diffusion
198  !! that is captured in Kd_shear [nondim].
199  real, pointer, dimension(:,:) :: &
200  bbl_thick_u => null(), & !< The bottom boundary layer thickness at the u-points [Z ~> m].
201  bbl_thick_v => null(), & !< The bottom boundary layer thickness at the v-points [Z ~> m].
202  kv_bbl_u => null(), & !< The bottom boundary layer viscosity at the u-points [Z2 T-1 ~> m2 s-1].
203  kv_bbl_v => null(), & !< The bottom boundary layer viscosity at the v-points [Z2 T-1 ~> m2 s-1].
204  ustar_bbl => null() !< The turbulence velocity in the bottom boundary layer at h points [Z T-1 ~> m s-1].
205  real, pointer, dimension(:,:) :: tke_bbl => null()
206  !< A term related to the bottom boundary layer source of turbulent kinetic
207  !! energy, currently in [Z3 T-3 ~> m3 s-3], but may at some time be changed
208  !! to [kg Z3 m-3 T-3 ~> W m-2].
209  real, pointer, dimension(:,:) :: &
210  taux_shelf => null(), & !< The zonal stresses on the ocean under shelves [R Z L T-2 ~> Pa].
211  tauy_shelf => null() !< The meridional stresses on the ocean under shelves [R Z L T-2 ~> Pa].
212  real, pointer, dimension(:,:) :: tbl_thick_shelf_u => null()
213  !< Thickness of the viscous top boundary layer under ice shelves at u-points [Z ~> m].
214  real, pointer, dimension(:,:) :: tbl_thick_shelf_v => null()
215  !< Thickness of the viscous top boundary layer under ice shelves at v-points [Z ~> m].
216  real, pointer, dimension(:,:) :: kv_tbl_shelf_u => null()
217  !< Viscosity in the viscous top boundary layer under ice shelves at u-points [Z2 T-1 ~> m2 s-1].
218  real, pointer, dimension(:,:) :: kv_tbl_shelf_v => null()
219  !< Viscosity in the viscous top boundary layer under ice shelves at v-points [Z2 T-1 ~> m2 s-1].
220  real, pointer, dimension(:,:) :: nkml_visc_u => null()
221  !< The number of layers in the viscous surface mixed layer at u-points [nondim].
222  !! This is not an integer because there may be fractional layers, and it is stored in
223  !! terms of layers, not depth, to facilitate the movement of the viscous boundary layer
224  !! with the flow.
225  real, pointer, dimension(:,:) :: nkml_visc_v => null()
226  !< The number of layers in the viscous surface mixed layer at v-points [nondim].
227  real, pointer, dimension(:,:) :: &
228  mld => null() !< Instantaneous active mixing layer depth [H ~> m or kg m-2].
229  real, pointer, dimension(:,:,:) :: &
230  ray_u => null(), & !< The Rayleigh drag velocity to be applied to each layer at u-points [Z T-1 ~> m s-1].
231  ray_v => null() !< The Rayleigh drag velocity to be applied to each layer at v-points [Z T-1 ~> m s-1].
232  real, pointer, dimension(:,:,:) :: kd_extra_t => null()
233  !< The extra diffusivity of temperature due to double diffusion relative to the
234  !! diffusivity of density [Z2 T-1 ~> m2 s-1].
235  real, pointer, dimension(:,:,:) :: kd_extra_s => null()
236  !< The extra diffusivity of salinity due to double diffusion relative to the
237  !! diffusivity of density [Z2 T-1 ~> m2 s-1].
238  ! One of Kd_extra_T and Kd_extra_S is always 0. Kd_extra_S is positive for salt fingering;
239  ! Kd_extra_T is positive for double diffusive convection. They are only allocated if
240  ! DOUBLE_DIFFUSION is true.
241  real, pointer, dimension(:,:,:) :: kd_shear => null()
242  !< The shear-driven turbulent diapycnal diffusivity at the interfaces between layers
243  !! in tracer columns [Z2 T-1 ~> m2 s-1].
244  real, pointer, dimension(:,:,:) :: kv_shear => null()
245  !< The shear-driven turbulent vertical viscosity at the interfaces between layers
246  !! in tracer columns [Z2 T-1 ~> m2 s-1].
247  real, pointer, dimension(:,:,:) :: kv_shear_bu => null()
248  !< The shear-driven turbulent vertical viscosity at the interfaces between layers in
249  !! corner columns [Z2 T-1 ~> m2 s-1].
250  real, pointer, dimension(:,:,:) :: kv_slow => null()
251  !< The turbulent vertical viscosity component due to "slow" processes (e.g., tidal,
252  !! background, convection etc) [Z2 T-1 ~> m2 s-1].
253  real, pointer, dimension(:,:,:) :: tke_turb => null()
254  !< The turbulent kinetic energy per unit mass at the interfaces [Z2 T-2 ~> m2 s-2].
255  !! This may be at the tracer or corner points
256 end type vertvisc_type
257 
258 !> Container for information about the summed layer transports
259 !! and how they will vary as the barotropic velocity is changed.
260 type, public :: bt_cont_type
261  real, allocatable :: fa_u_ee(:,:) !< The effective open face area for zonal barotropic transport
262  !! drawing from locations far to the east [H L ~> m2 or kg m-1].
263  real, allocatable :: fa_u_e0(:,:) !< The effective open face area for zonal barotropic transport
264  !! drawing from nearby to the east [H L ~> m2 or kg m-1].
265  real, allocatable :: fa_u_w0(:,:) !< The effective open face area for zonal barotropic transport
266  !! drawing from nearby to the west [H L ~> m2 or kg m-1].
267  real, allocatable :: fa_u_ww(:,:) !< The effective open face area for zonal barotropic transport
268  !! drawing from locations far to the west [H L ~> m2 or kg m-1].
269  real, allocatable :: ubt_ww(:,:) !< uBT_WW is the barotropic velocity [L T-1 ~> m s-1], beyond which the marginal
270  !! open face area is FA_u_WW. uBT_WW must be non-negative.
271  real, allocatable :: ubt_ee(:,:) !< uBT_EE is a barotropic velocity [L T-1 ~> m s-1], beyond which the marginal
272  !! open face area is FA_u_EE. uBT_EE must be non-positive.
273  real, allocatable :: fa_v_nn(:,:) !< The effective open face area for meridional barotropic transport
274  !! drawing from locations far to the north [H L ~> m2 or kg m-1].
275  real, allocatable :: fa_v_n0(:,:) !< The effective open face area for meridional barotropic transport
276  !! drawing from nearby to the north [H L ~> m2 or kg m-1].
277  real, allocatable :: fa_v_s0(:,:) !< The effective open face area for meridional barotropic transport
278  !! drawing from nearby to the south [H L ~> m2 or kg m-1].
279  real, allocatable :: fa_v_ss(:,:) !< The effective open face area for meridional barotropic transport
280  !! drawing from locations far to the south [H L ~> m2 or kg m-1].
281  real, allocatable :: vbt_ss(:,:) !< vBT_SS is the barotropic velocity, [L T-1 ~> m s-1], beyond which the marginal
282  !! open face area is FA_v_SS. vBT_SS must be non-negative.
283  real, allocatable :: vbt_nn(:,:) !< vBT_NN is the barotropic velocity, [L T-1 ~> m s-1], beyond which the marginal
284  !! open face area is FA_v_NN. vBT_NN must be non-positive.
285  real, allocatable :: h_u(:,:,:) !< An effective thickness at zonal faces [H ~> m or kg m-2].
286  real, allocatable :: h_v(:,:,:) !< An effective thickness at meridional faces [H ~> m or kg m-2].
287  type(group_pass_type) :: pass_polarity_bt !< Structure for polarity group halo updates
288  type(group_pass_type) :: pass_fa_uv !< Structure for face area group halo updates
289 end type bt_cont_type
290 
291 contains
292 
293 !> Allocates the fields for the surface (return) properties of
294 !! the ocean model. Unused fields are unallocated.
295 subroutine allocate_surface_state(sfc_state, G, use_temperature, do_integrals, &
296  gas_fields_ocn, use_meltpot, use_iceshelves)
297  type(ocean_grid_type), intent(in) :: g !< ocean grid structure
298  type(surface), intent(inout) :: sfc_state !< ocean surface state type to be allocated.
299  logical, optional, intent(in) :: use_temperature !< If true, allocate the space for thermodynamic variables.
300  logical, optional, intent(in) :: do_integrals !< If true, allocate the space for vertically
301  !! integrated fields.
302  type(coupler_1d_bc_type), &
303  optional, intent(in) :: gas_fields_ocn !< If present, this type describes the ocean
304  !! ocean and surface-ice fields that will participate
305  !! in the calculation of additional gas or other
306  !! tracer fluxes, and can be used to spawn related
307  !! internal variables in the ice model.
308  logical, optional, intent(in) :: use_meltpot !< If true, allocate the space for melt potential
309  logical, optional, intent(in) :: use_iceshelves !< If true, allocate the space for the stresses
310  !! under ice shelves.
311 
312  ! local variables
313  logical :: use_temp, alloc_integ, use_melt_potential, alloc_iceshelves
314  integer :: is, ie, js, je, isd, ied, jsd, jed
315  integer :: isdb, iedb, jsdb, jedb
316 
317  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
318  isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
319  isdb = g%isdB ; iedb = g%iedB; jsdb = g%jsdB ; jedb = g%jedB
320 
321  use_temp = .true. ; if (present(use_temperature)) use_temp = use_temperature
322  alloc_integ = .true. ; if (present(do_integrals)) alloc_integ = do_integrals
323  use_melt_potential = .false. ; if (present(use_meltpot)) use_melt_potential = use_meltpot
324  alloc_iceshelves = .false. ; if (present(use_iceshelves)) alloc_iceshelves = use_iceshelves
325 
326  if (sfc_state%arrays_allocated) return
327 
328  if (use_temp) then
329  allocate(sfc_state%SST(isd:ied,jsd:jed)) ; sfc_state%SST(:,:) = 0.0
330  allocate(sfc_state%SSS(isd:ied,jsd:jed)) ; sfc_state%SSS(:,:) = 0.0
331  else
332  allocate(sfc_state%sfc_density(isd:ied,jsd:jed)) ; sfc_state%sfc_density(:,:) = 0.0
333  endif
334  allocate(sfc_state%sea_lev(isd:ied,jsd:jed)) ; sfc_state%sea_lev(:,:) = 0.0
335  allocate(sfc_state%Hml(isd:ied,jsd:jed)) ; sfc_state%Hml(:,:) = 0.0
336  allocate(sfc_state%u(isdb:iedb,jsd:jed)) ; sfc_state%u(:,:) = 0.0
337  allocate(sfc_state%v(isd:ied,jsdb:jedb)) ; sfc_state%v(:,:) = 0.0
338 
339  if (use_melt_potential) then
340  allocate(sfc_state%melt_potential(isd:ied,jsd:jed)) ; sfc_state%melt_potential(:,:) = 0.0
341  endif
342 
343  if (alloc_integ) then
344  ! Allocate structures for the vertically integrated ocean_mass, ocean_heat, and ocean_salt.
345  allocate(sfc_state%ocean_mass(isd:ied,jsd:jed)) ; sfc_state%ocean_mass(:,:) = 0.0
346  if (use_temp) then
347  allocate(sfc_state%ocean_heat(isd:ied,jsd:jed)) ; sfc_state%ocean_heat(:,:) = 0.0
348  allocate(sfc_state%ocean_salt(isd:ied,jsd:jed)) ; sfc_state%ocean_salt(:,:) = 0.0
349  allocate(sfc_state%TempxPmE(isd:ied,jsd:jed)) ; sfc_state%TempxPmE(:,:) = 0.0
350  allocate(sfc_state%salt_deficit(isd:ied,jsd:jed)) ; sfc_state%salt_deficit(:,:) = 0.0
351  allocate(sfc_state%internal_heat(isd:ied,jsd:jed)) ; sfc_state%internal_heat(:,:) = 0.0
352  endif
353  endif
354 
355  if (alloc_iceshelves) then
356  allocate(sfc_state%taux_shelf(isdb:iedb,jsd:jed)) ; sfc_state%taux_shelf(:,:) = 0.0
357  allocate(sfc_state%tauy_shelf(isd:ied,jsdb:jedb)) ; sfc_state%tauy_shelf(:,:) = 0.0
358  endif
359 
360  if (present(gas_fields_ocn)) &
361  call coupler_type_spawn(gas_fields_ocn, sfc_state%tr_fields, &
362  (/is,is,ie,ie/), (/js,js,je,je/), as_needed=.true.)
363 
364  sfc_state%arrays_allocated = .true.
365 
366 end subroutine allocate_surface_state
367 
368 !> Deallocates the elements of a surface state type.
369 subroutine deallocate_surface_state(sfc_state)
370  type(surface), intent(inout) :: sfc_state !< ocean surface state type to be deallocated here.
371 
372  if (.not.sfc_state%arrays_allocated) return
373 
374  if (allocated(sfc_state%melt_potential)) deallocate(sfc_state%melt_potential)
375  if (allocated(sfc_state%SST)) deallocate(sfc_state%SST)
376  if (allocated(sfc_state%SSS)) deallocate(sfc_state%SSS)
377  if (allocated(sfc_state%sfc_density)) deallocate(sfc_state%sfc_density)
378  if (allocated(sfc_state%sea_lev)) deallocate(sfc_state%sea_lev)
379  if (allocated(sfc_state%Hml)) deallocate(sfc_state%Hml)
380  if (allocated(sfc_state%u)) deallocate(sfc_state%u)
381  if (allocated(sfc_state%v)) deallocate(sfc_state%v)
382  if (allocated(sfc_state%ocean_mass)) deallocate(sfc_state%ocean_mass)
383  if (allocated(sfc_state%ocean_heat)) deallocate(sfc_state%ocean_heat)
384  if (allocated(sfc_state%ocean_salt)) deallocate(sfc_state%ocean_salt)
385  if (allocated(sfc_state%salt_deficit)) deallocate(sfc_state%salt_deficit)
386 
387  call coupler_type_destructor(sfc_state%tr_fields)
388 
389  sfc_state%arrays_allocated = .false.
390 
391 end subroutine deallocate_surface_state
392 
393 !> Allocates the arrays contained within a BT_cont_type and initializes them to 0.
394 subroutine alloc_bt_cont_type(BT_cont, G, alloc_faces)
395  type(bt_cont_type), pointer :: bt_cont !< The BT_cont_type whose elements will be allocated
396  type(ocean_grid_type), intent(in) :: g !< The ocean's grid structure
397  logical, optional, intent(in) :: alloc_faces !< If present and true, allocate
398  !! memory for effective face thicknesses.
399 
400  integer :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
401  isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
402  isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
403 
404  if (associated(bt_cont)) call mom_error(fatal, &
405  "alloc_BT_cont_type called with an associated BT_cont_type pointer.")
406 
407  allocate(bt_cont)
408  allocate(bt_cont%FA_u_WW(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_WW(:,:) = 0.0
409  allocate(bt_cont%FA_u_W0(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_W0(:,:) = 0.0
410  allocate(bt_cont%FA_u_E0(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_E0(:,:) = 0.0
411  allocate(bt_cont%FA_u_EE(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_EE(:,:) = 0.0
412  allocate(bt_cont%uBT_WW(isdb:iedb,jsd:jed)) ; bt_cont%uBT_WW(:,:) = 0.0
413  allocate(bt_cont%uBT_EE(isdb:iedb,jsd:jed)) ; bt_cont%uBT_EE(:,:) = 0.0
414 
415  allocate(bt_cont%FA_v_SS(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_SS(:,:) = 0.0
416  allocate(bt_cont%FA_v_S0(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_S0(:,:) = 0.0
417  allocate(bt_cont%FA_v_N0(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_N0(:,:) = 0.0
418  allocate(bt_cont%FA_v_NN(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_NN(:,:) = 0.0
419  allocate(bt_cont%vBT_SS(isd:ied,jsdb:jedb)) ; bt_cont%vBT_SS(:,:) = 0.0
420  allocate(bt_cont%vBT_NN(isd:ied,jsdb:jedb)) ; bt_cont%vBT_NN(:,:) = 0.0
421 
422  if (present(alloc_faces)) then ; if (alloc_faces) then
423  allocate(bt_cont%h_u(isdb:iedb,jsd:jed,1:g%ke)) ; bt_cont%h_u(:,:,:) = 0.0
424  allocate(bt_cont%h_v(isd:ied,jsdb:jedb,1:g%ke)) ; bt_cont%h_v(:,:,:) = 0.0
425  endif ; endif
426 
427 end subroutine alloc_bt_cont_type
428 
429 !> Deallocates the arrays contained within a BT_cont_type.
430 subroutine dealloc_bt_cont_type(BT_cont)
431  type(bt_cont_type), pointer :: bt_cont !< The BT_cont_type whose elements will be deallocated.
432 
433  if (.not.associated(bt_cont)) return
434 
435  deallocate(bt_cont%FA_u_WW) ; deallocate(bt_cont%FA_u_W0)
436  deallocate(bt_cont%FA_u_E0) ; deallocate(bt_cont%FA_u_EE)
437  deallocate(bt_cont%uBT_WW) ; deallocate(bt_cont%uBT_EE)
438 
439  deallocate(bt_cont%FA_v_SS) ; deallocate(bt_cont%FA_v_S0)
440  deallocate(bt_cont%FA_v_N0) ; deallocate(bt_cont%FA_v_NN)
441  deallocate(bt_cont%vBT_SS) ; deallocate(bt_cont%vBT_NN)
442 
443  if (allocated(bt_cont%h_u)) deallocate(bt_cont%h_u)
444  if (allocated(bt_cont%h_v)) deallocate(bt_cont%h_v)
445 
446  deallocate(bt_cont)
447 
448 end subroutine dealloc_bt_cont_type
449 
450 !> Diagnostic checksums on various elements of a thermo_var_ptrs type for debugging.
451 subroutine mom_thermovar_chksum(mesg, tv, G)
452  character(len=*), intent(in) :: mesg !< A message that appears in the checksum lines
453  type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables
454  type(ocean_grid_type), intent(in) :: g !< The ocean's grid structure
455 
456  ! Note that for the chksum calls to be useful for reproducing across PE
457  ! counts, there must be no redundant points, so all variables use is..ie
458  ! and js...je as their extent.
459  if (associated(tv%T)) &
460  call hchksum(tv%T, mesg//" tv%T", g%HI)
461  if (associated(tv%S)) &
462  call hchksum(tv%S, mesg//" tv%S", g%HI)
463  if (associated(tv%frazil)) &
464  call hchksum(tv%frazil, mesg//" tv%frazil", g%HI)
465  if (associated(tv%salt_deficit)) &
466  call hchksum(tv%salt_deficit, mesg//" tv%salt_deficit", g%HI, scale=g%US%R_to_kg_m3*g%US%Z_to_m)
467  if (associated(tv%TempxPmE)) &
468  call hchksum(tv%TempxPmE, mesg//" tv%TempxPmE", g%HI, scale=g%US%R_to_kg_m3*g%US%Z_to_m)
469 end subroutine mom_thermovar_chksum
470 
471 end module mom_variables
mom_domains::get_domain_extent
subroutine, public get_domain_extent(Domain, isc, iec, jsc, jec, isd, ied, jsd, jed, isg, ieg, jsg, jeg, idg_offset, jdg_offset, symmetric, local_indexing, index_offset)
Returns various data that has been stored in a MOM_domain_type.
Definition: MOM_domains.F90:1769
mom_variables::allocate_surface_state
subroutine, public allocate_surface_state(sfc_state, G, use_temperature, do_integrals, gas_fields_ocn, use_meltpot, use_iceshelves)
Allocates the fields for the surface (return) properties of the ocean model. Unused fields are unallo...
Definition: MOM_variables.F90:297
mom_variables::surface
Pointers to various fields which may be used describe the surface state of MOM, and which will be ret...
Definition: MOM_variables.F90:38
mom_variables::alloc_bt_cont_type
subroutine, public alloc_bt_cont_type(BT_cont, G, alloc_faces)
Allocates the arrays contained within a BT_cont_type and initializes them to 0.
Definition: MOM_variables.F90:395
mom_variables::thermo_var_ptrs
Pointers to an assortment of thermodynamic fields that may be available, including potential temperat...
Definition: MOM_variables.F90:78
mom_variables::p2d
A structure for creating arrays of pointers to 2D arrays.
Definition: MOM_variables.F90:32
mom_eos
Provides subroutines for quantities specific to the equation of state.
Definition: MOM_EOS.F90:2
mom_variables::deallocate_surface_state
subroutine, public deallocate_surface_state(sfc_state)
Deallocates the elements of a surface state type.
Definition: MOM_variables.F90:370
mom_variables::bt_cont_type
Container for information about the summed layer transports and how they will vary as the barotropic ...
Definition: MOM_variables.F90:260
mom_eos::eos_type
A control structure for the equation of state.
Definition: MOM_EOS.F90:91
mom_variables::vertvisc_type
Vertical viscosities, drag coefficients, and related fields.
Definition: MOM_variables.F90:196
mom_domains
Describes the decomposed MOM domain and has routines for communications across PEs.
Definition: MOM_domains.F90:2
mom_variables
Provides transparent structures with groups of MOM6 variables and supporting routines.
Definition: MOM_variables.F90:2
mom_variables::mom_thermovar_chksum
subroutine, public mom_thermovar_chksum(mesg, tv, G)
Diagnostic checksums on various elements of a thermo_var_ptrs type for debugging.
Definition: MOM_variables.F90:452
mom_variables::cont_diag_ptrs
Pointers to arrays with transports, which can later be used for derived diagnostics,...
Definition: MOM_variables.F90:181
mom_variables::accel_diag_ptrs
Pointers to arrays with accelerations, which can later be used for derived diagnostics,...
Definition: MOM_variables.F90:151
mom_grid
Provides the ocean grid type.
Definition: MOM_grid.F90:2
mom_debugging
Provides checksumming functions for debugging.
Definition: MOM_debugging.F90:7
mom_variables::dealloc_bt_cont_type
subroutine, public dealloc_bt_cont_type(BT_cont)
Deallocates the arrays contained within a BT_cont_type.
Definition: MOM_variables.F90:431
mom_variables::p3d
A structure for creating arrays of pointers to 3D arrays.
Definition: MOM_variables.F90:28
mom_error_handler::mom_error
subroutine, public mom_error(level, message, all_print)
This provides a convenient interface for writing an mpp_error message with run-time filter based on a...
Definition: MOM_error_handler.F90:72
mom_domains::mom_domain_type
The MOM_domain_type contains information about the domain decompositoin.
Definition: MOM_domains.F90:99
mom_variables::ocean_internal_state
Pointers to all of the prognostic variables allocated in MOM_variables.F90 and MOM....
Definition: MOM_variables.F90:122
mom_error_handler
Routines for error handling and I/O management.
Definition: MOM_error_handler.F90:2
mom_grid::ocean_grid_type
Ocean grid type. See mom_grid for details.
Definition: MOM_grid.F90:26