ocean_lateral_mix_t Derived Type

type, public :: ocean_lateral_mix_t


Inherits

type~~ocean_lateral_mix_t~~InheritsGraph type~ocean_lateral_mix_t ocean_lateral_mix_t type~scratch_3d_buffer_t scratch_3d_buffer_t type~ocean_lateral_mix_t->type~scratch_3d_buffer_t vort_corner

Inherited by

type~~ocean_lateral_mix_t~~InheritedByGraph type~ocean_lateral_mix_t ocean_lateral_mix_t type~ocean_state_t ocean_state_t type~ocean_state_t->type~ocean_lateral_mix_t lateral_mix type~ocean_engine_t ocean_engine_t type~ocean_engine_t->type~ocean_state_t state type~ocean_handle_t ocean_handle_t type~ocean_handle_t->type~ocean_state_t state type~ocean_handle_t->type~ocean_engine_t engine

Components

Type Visibility Attributes Name Initial
real(kind=wp), public :: ah_bg = 0.0_wp

Background harmonic viscosity (m^2/s), floored beneath the closure to avoid zero damping in laminar patches.

real(kind=wp), public, allocatable :: ah_face_x(:,:,:)

Harmonic viscosity at east faces (m^2/s), shape (nx+1, ny, nz_ml).

real(kind=wp), public, allocatable :: ah_face_y(:,:,:)

Harmonic viscosity at north faces (m^2/s), shape (nx, ny+1, nz_ml).

real(kind=wp), public :: ah_max = 1.0e4_wp

Upper clip on harmonic viscosity (m^2/s). Caps Leith spikes and enforces the viscous-CFL bound (nu·dt/dx² ≤ 0.5).

real(kind=wp), public :: c_leith = 1.0_wp

Leith dimensionless coefficient. Typical 1.0–2.0.

real(kind=wp), public :: c_leith_bi = 0.0_wp

Nondimensional biharmonic Leith constant for LMIX_LEITH_BIHARM (Griffies & Hallberg 2000). Default 0.0 is a no-op; selecting the closure with it 0.0 warns at startup.

real(kind=wp), public :: c_smag = 0.15_wp

Smagorinsky dimensionless coefficient (fallback).

integer, public :: closure = LMIX_NONE

Active closure tag. Default LMIX_NONE ⇒ scalar-nu_h behaviour, bit-identical.

logical, public :: is_init = .false.

True between init and destroy. Prefer this to allocated(...) — tracks GPU device attachment too.

real(kind=wp), public :: kh_vel_scale_live = 0.0_wp

Live velocity-scale viscosity coefficient (m/s). When positive, A_vel = kh_vel_scale_live · L_grid · |u| (L_grid = sqrt(dxT·dyT)) is max-combined into the per-face harmonic viscosity every step. Default 0 ⇒ never computed ⇒ bit-identical. State-dependent (evaluated per step); distinct from the kh_vel_scale background-floor knob set once at configure. MOM6 KH_VEL_SCALE (Kh = U·Δ).

logical, public :: no_slip = .false.

Lateral BC at coasts (shared with Coriolis). .false. (default) = free-slip: corner shear strain sh_xy (and the Leith corner vorticity) is multiplied by wet_q so a land corner adds nothing. .true. = no-slip: factor 2 - wet_q. All-wet ⇒ wet_q≡1 ⇒ bit-identical.

real(kind=wp), public :: nu4_bg = 0.0_wp

Background biharmonic viscosity floor (m⁴/s).

real(kind=wp), public, allocatable :: nu4_face_x(:,:,:)

Biharmonic viscosity at east faces (m⁴/s), shape (nx+1, ny, nz_ml). Populated only when smag_ah_active = .true..

real(kind=wp), public, allocatable :: nu4_face_y(:,:,:)

Biharmonic viscosity at north faces (m⁴/s), shape (nx, ny+1, nz_ml). Populated only when smag_ah_active = .true..

real(kind=wp), public :: nu4_max = 1.0e12_wp

Static upper clip on biharmonic viscosity (m⁴/s) applied when filling nu4_face_* — a cheap ceiling on the strain term. The true stability guard is the per-cell biharmonic-CFL clamp applied downstream in the biharmonic kernel.

integer, public :: nx_total = 0
integer, public :: ny_total = 0
integer, public :: nz_ml = 0
logical, public :: resoln_scaled_visc = .false.

Hallberg (2013) resolution scaling. When .true. AND the optional VarMix res_fn_u/v face fields are passed, the dynamic coefficients are multiplied by Res_fn ∈ [0,1] before the clamps (suppressed where the deformation radius is resolved). Default .false. ⇒ unscaled ⇒ bit-identical.

logical, public :: smag_ah_active = .false.

When true, compute_smag_ah fills nu4_face_x/y each step from the local strain rate; the biharmonic kernel reads them instead of the scalar nu_4. Independent of closure — Smag_KH (Laplacian) and Smag_AH (biharmonic) can both be on.

real(kind=wp), public :: smag_bi_const = 0.06_wp

Nondimensional biharmonic Smagorinsky constant (typical 0.015–0.06).

type(scratch_3d_buffer_t), public :: vort_corner

Relative vorticity at C-grid corners.


Type-Bound Procedures

procedure, public, non_overridable :: bytes => ocean_lateral_mix_bytes

  • private pure function ocean_lateral_mix_bytes(this) result(nbytes)

    Counted allocatable footprint of the lateral viscosity slot (0 when unallocated). One arr_bytes term per array — add a term here when a new allocatable joins the type.

    Arguments

    Type IntentOptional Attributes Name
    class(ocean_lateral_mix_t), intent(in) :: this

    Return Value integer(kind=int64)

procedure, public, non_overridable :: destroy => ocean_lateral_mix_destroy

procedure, public, non_overridable :: enter_data => ocean_lateral_mix_enter_data

procedure, public, non_overridable :: exit_data => ocean_lateral_mix_exit_data

procedure, public, non_overridable :: init => ocean_lateral_mix_init

  • private subroutine ocean_lateral_mix_init(this, grid, nz_ml)

    Allocate the face viscosity coefficients + corner-vorticity scratch. Default nz_ml = 1 preserves the barotropic-only constructor; pass nz_ml = ms%nz_ml for the multilayer driver.

    Arguments

    Type IntentOptional Attributes Name
    class(ocean_lateral_mix_t), intent(inout) :: this
    type(hgrid_t), intent(in) :: grid
    integer, intent(in), optional :: nz_ml

Source Code

   type :: ocean_lateral_mix_t
      logical :: is_init = .false.
         !! True between `init` and `destroy`.  Prefer this to
         !! `allocated(...)` — tracks GPU device attachment too.
      integer  :: closure = LMIX_NONE
         !! Active closure tag.  Default `LMIX_NONE` ⇒ scalar-`nu_h`
         !! behaviour, bit-identical.
      logical  :: no_slip = .false.
         !! Lateral BC at coasts (shared with Coriolis).  `.false.`
         !! (default) = free-slip: corner shear strain `sh_xy` (and the
         !! Leith corner vorticity) is multiplied by `wet_q` so a land
         !! corner adds nothing.  `.true.` = no-slip: factor `2 - wet_q`.
         !! All-wet ⇒ `wet_q≡1` ⇒ bit-identical.
      real(wp) :: c_leith = 1.0_wp
         !! Leith dimensionless coefficient.  Typical 1.0–2.0.
      real(wp) :: c_smag = 0.15_wp
         !! Smagorinsky dimensionless coefficient (fallback).
      real(wp) :: ah_bg = 0.0_wp
         !! Background harmonic viscosity (m^2/s), floored beneath the
         !! closure to avoid zero damping in laminar patches.
      real(wp) :: ah_max = 1.0e4_wp
         !! Upper clip on harmonic viscosity (m^2/s).  Caps Leith spikes
         !! and enforces the viscous-CFL bound (nu·dt/dx² ≤ 0.5).

      real(wp) :: kh_vel_scale_live = 0.0_wp
         !! Live velocity-scale viscosity coefficient (m/s).  When
         !! positive, `A_vel = kh_vel_scale_live · L_grid · |u|`
         !! (`L_grid = sqrt(dxT·dyT)`) is `max`-combined into the
         !! per-face harmonic viscosity every step.  Default 0 ⇒ never
         !! computed ⇒ bit-identical.  State-dependent (evaluated per
         !! step); distinct from the `kh_vel_scale` background-floor knob
         !! set once at configure.  MOM6 `KH_VEL_SCALE` (Kh = U·Δ).

      ! ---- Biharmonic Smagorinsky ----
      logical  :: smag_ah_active = .false.
         !! When true, `compute_smag_ah` fills `nu4_face_x/y` each step
         !! from the local strain rate; the biharmonic kernel reads them
         !! instead of the scalar `nu_4`.  Independent of `closure` —
         !! Smag_KH (Laplacian) and Smag_AH (biharmonic) can both be on.
      logical  :: resoln_scaled_visc = .false.
         !! Hallberg (2013) resolution scaling.  When `.true.` AND the
         !! optional VarMix `res_fn_u/v` face fields are passed, the
         !! dynamic coefficients are multiplied by `Res_fn ∈ [0,1]`
         !! before the clamps (suppressed where the deformation radius
         !! is resolved).  Default `.false.` ⇒ unscaled ⇒ bit-identical.
      real(wp) :: smag_bi_const = 0.06_wp
         !! Nondimensional biharmonic Smagorinsky constant (typical
         !! 0.015–0.06).
      real(wp) :: c_leith_bi = 0.0_wp
         !! Nondimensional biharmonic Leith constant for
         !! `LMIX_LEITH_BIHARM` (Griffies & Hallberg 2000).  Default 0.0
         !! is a no-op; selecting the closure with it 0.0 warns at startup.
      real(wp) :: nu4_bg = 0.0_wp
         !! Background biharmonic viscosity floor (m⁴/s).
      real(wp) :: nu4_max = 1.0e12_wp
         !! Static upper clip on biharmonic viscosity (m⁴/s) applied when
         !! filling `nu4_face_*` — a cheap ceiling on the strain term.
         !! The true stability guard is the per-cell biharmonic-CFL clamp
         !! applied downstream in the biharmonic kernel.

      ! ---- Cached extents ----
      integer :: nx_total = 0
      integer :: ny_total = 0
      integer :: nz_ml = 0

      ! ---- Face-located viscosity coefficients ----
      ! Recomputed every outer step (or per RK2 stage) from the local
      ! flow.  Shape matches u_face_x_layer / v_face_y_layer.
      real(wp), allocatable :: ah_face_x(:, :, :)
         !! Harmonic viscosity at east faces (m^2/s), shape
         !! `(nx+1, ny, nz_ml)`.
      real(wp), allocatable :: ah_face_y(:, :, :)
         !! Harmonic viscosity at north faces (m^2/s), shape
         !! `(nx, ny+1, nz_ml)`.
      real(wp), allocatable :: nu4_face_x(:, :, :)
         !! Biharmonic viscosity at east faces (m⁴/s), shape
         !! `(nx+1, ny, nz_ml)`.  Populated only when
         !! `smag_ah_active = .true.`.
      real(wp), allocatable :: nu4_face_y(:, :, :)
         !! Biharmonic viscosity at north faces (m⁴/s), shape
         !! `(nx, ny+1, nz_ml)`.  Populated only when
         !! `smag_ah_active = .true.`.

      ! ---- Vorticity-gradient scratch (Leith) ----
      ! ζ at corners, computed once per call from the face velocities.
      ! Shape `(nx+1, ny+1, nz_ml)`.
      type(scratch_3d_buffer_t) :: vort_corner
         !! Relative vorticity at C-grid corners.
   contains
      procedure, non_overridable :: init => ocean_lateral_mix_init
      procedure, non_overridable :: destroy => ocean_lateral_mix_destroy
      procedure, non_overridable :: enter_data => ocean_lateral_mix_enter_data
      procedure, non_overridable :: exit_data => ocean_lateral_mix_exit_data
      procedure, non_overridable :: bytes => ocean_lateral_mix_bytes
   end type ocean_lateral_mix_t