ocean_gm_t Derived Type

type, public :: ocean_gm_t

Gent-McWilliams thickness-diffusion state. All fields default to the inert (enable=.false.) configuration so an ocean run that never sets &ocean_gm_nml is bit-identical.


Inherited by

type~~ocean_gm_t~~InheritedByGraph type~ocean_gm_t ocean_gm_t type~ocean_state_t ocean_state_t type~ocean_state_t->type~ocean_gm_t gm 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
logical, public :: enable = .false.

Master switch. Off => gm_compute_transports and continuity_gm_apply are no-ops => bit-identity preserved. Requires the slopes slot (&ocean_slopes_nml enable); the loud invariant is checked at configure (configure_ocean_gm).

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

Potential-energy release -1/4 Sum_k rho0 KH Slope^2 N^2 h (W/m^2-ish; >= 0 for a stable tilted column), (nx,ny). CARRIED state: filled after the dynamics of step n, read by meke_step at the top of step n+1, so it is in the restart registry (gm_src).

logical, public :: is_init = .false.

True between init and destroy; gate on this (never on allocated, which misses the GPU mapping).

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

Thickness-diffusion coefficient KhTh (m^2/s); constant-filled into the 2D face fields (production 1e2-1e3).

real(kind=wp), public :: khth_max_cfl = 0.1_wp

Fraction of the diffusive CFL the face KH may use: KH = min(khth, 0.25*max_cfl/(dt*(idxCu^2+idyCv^2))).

real(kind=wp), public :: khth_slope_max = 0.01_wp

Slope magnitude (nondim) above which the safe-streamfunction blend takes over (slope_max).

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

Thickness diffusivity at u-faces (m^2/s), (nx+1,ny).

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

Thickness diffusivity at v-faces (m^2/s), (nx,ny+1).

integer, public :: nx_total = 0
integer, public :: ny_total = 0
integer, public :: nz_ml = 0
real(kind=wp), public :: rho0 = 1035.0_wp

Reference density (kg/m^3) for the gm_src PE-release scaling.

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

GM x-face transport (m^3/s), (nx+1,ny,nz). Filled every outer step from the post-dynamics thickness and applied at once by continuity_gm_apply.

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

GM y-face transport (m^3/s), (nx,ny+1,nz).


Type-Bound Procedures

procedure, public, non_overridable :: bytes => ocean_gm_bytes

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

    Counted allocatable footprint of the GM 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_gm_t), intent(in) :: this

    Return Value integer(kind=int64)

procedure, public, non_overridable :: destroy => ocean_gm_destroy

  • private subroutine ocean_gm_destroy(this)

    Arguments

    Type IntentOptional Attributes Name
    class(ocean_gm_t), intent(inout) :: this

procedure, public, non_overridable :: enter_data => ocean_gm_enter_data

procedure, public, non_overridable :: exit_data => ocean_gm_exit_data

procedure, public, non_overridable :: init => ocean_gm_init

  • private subroutine ocean_gm_init(this, grid, nz_ml)

    Allocate the 2D face KhTh fields, per-layer face transports, and the gm_src PE-release diagnostic. Always allocates (configure runs after init); host allocation (no do concurrent before enter_data).

    Arguments

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

Source Code

   type :: ocean_gm_t
      !! Gent-McWilliams thickness-diffusion state.  All fields default to
      !! the inert (`enable=.false.`) configuration so an ocean run that
      !! never sets `&ocean_gm_nml` is bit-identical.
      logical :: is_init = .false.
         !! True between `init` and `destroy`; gate on this (never on
         !! `allocated`, which misses the GPU mapping).
      logical :: enable = .false.
         !! Master switch.  Off => `gm_compute_transports` and
         !! `continuity_gm_apply` are no-ops => bit-identity preserved.  Requires the
         !! slopes slot (`&ocean_slopes_nml enable`); the loud invariant is
         !! checked at configure (`configure_ocean_gm`).
      real(wp) :: khth = 0.0_wp
         !! Thickness-diffusion coefficient KhTh (m^2/s); constant-filled
         !! into the 2D face fields (production 1e2-1e3).
      real(wp) :: khth_max_cfl = 0.1_wp
         !! Fraction of the diffusive CFL the face KH may use:
         !! `KH = min(khth, 0.25*max_cfl/(dt*(idxCu^2+idyCv^2)))`.
      real(wp) :: khth_slope_max = 0.01_wp
         !! Slope magnitude (nondim) above which the safe-streamfunction
         !! blend takes over (`slope_max`).
      real(wp) :: rho0 = 1035.0_wp
         !! Reference density (kg/m^3) for the `gm_src` PE-release scaling.

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

      ! ---- 2D face KhTh fields (CFL-clamped) ----
      real(wp), allocatable :: khth_u(:, :)
         !! Thickness diffusivity at u-faces (m^2/s), `(nx+1,ny)`.
      real(wp), allocatable :: khth_v(:, :)
         !! Thickness diffusivity at v-faces (m^2/s), `(nx,ny+1)`.

      ! ---- Per-layer GM bolus transports (faces) ----
      ! k=1 bed, k=nz surface.  Sum_k over each face is ~0 (closed
      ! overturning).  Step-internal: filled from the current h and spent
      ! by `continuity_gm_apply` in the same outer step (not restart state).
      real(wp), allocatable :: uhD(:, :, :)
         !! GM x-face transport (m^3/s), `(nx+1,ny,nz)`.  Filled every outer
         !! step from the post-dynamics thickness and applied at once by
         !! `continuity_gm_apply`.
      real(wp), allocatable :: vhD(:, :, :)
         !! GM y-face transport (m^3/s), `(nx,ny+1,nz)`.

      ! ---- 2D GM PE-release source (for MEKE) ----
      real(wp), allocatable :: gm_src(:, :)
         !! Potential-energy release `-1/4 Sum_k rho0 KH Slope^2 N^2 h`
         !! (W/m^2-ish; >= 0 for a stable tilted column), `(nx,ny)`.
         !! CARRIED state: filled after the dynamics of step n, read by
         !! `meke_step` at the top of step n+1, so it is in the restart
         !! registry (`gm_src`).
   contains
      procedure, non_overridable :: init => ocean_gm_init
      procedure, non_overridable :: destroy => ocean_gm_destroy
      procedure, non_overridable :: enter_data => ocean_gm_enter_data
      procedure, non_overridable :: exit_data => ocean_gm_exit_data
      procedure, non_overridable :: bytes => ocean_gm_bytes
   end type ocean_gm_t