ocean_redi_t Derived Type

type, public :: ocean_redi_t

Redi continuous neutral-diffusion state. Defaults inert (enable=.false.) ⇒ bit-identical. Reads the prognostic T/S + EOS directly (recomputes its own interface dR/dT, dR/dS — does NOT consume GM slopes). Augments rdb_ocean_hdiff_tracer.


Inherited by

type~~ocean_redi_t~~InheritedByGraph type~ocean_redi_t ocean_redi_t type~ocean_state_t ocean_state_t type~ocean_state_t->type~ocean_redi_t redi 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 :: continuous = .true.

Continuous variant (the only one shipped). Discontinuous deferred (R4); a .false. value is rejected at configure.

logical, public :: enable = .false.

Master switch. Off => redi_calc_coeffs/redi_apply_flux no-op => bit-identity preserved.

logical, public :: is_init = .false.

True between init/destroy; gate on this, not on allocated.

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

Scalar Redi neutral diffusivity (m^2/s); the FALLBACK used when VarMix is off (0 => no flux). When VarMix is enabled its spatially-varying khtr_u/khtr_v override this per face.

real(kind=wp), public, allocatable :: khtr_u(:,:)
real(kind=wp), public, allocatable :: khtr_v(:,:)
integer, public :: nsurf = 0

2*nz_ml + 2 (the neutral-surface count of the continuous sweep).

integer, public :: nx_total = 0
integer, public :: ny_total = 0
integer, public :: nz_ml = 0
real(kind=wp), public, allocatable :: tr_snap(:,:,:)
integer, public, allocatable :: uKb(:,:)
integer, public, allocatable :: uKoL(:,:,:)
integer, public, allocatable :: uKoR(:,:,:)
integer, public, allocatable :: uKt(:,:)
real(kind=wp), public, allocatable :: uPoL(:,:,:)
real(kind=wp), public, allocatable :: uPoR(:,:,:)
real(kind=wp), public, allocatable :: uhEff(:,:,:)
integer, public, allocatable :: vKb(:,:)
integer, public, allocatable :: vKoL(:,:,:)
integer, public, allocatable :: vKoR(:,:,:)
integer, public, allocatable :: vKt(:,:)
real(kind=wp), public, allocatable :: vPoL(:,:,:)
real(kind=wp), public, allocatable :: vPoR(:,:,:)
real(kind=wp), public, allocatable :: vhEff(:,:,:)

Type-Bound Procedures

procedure, public, non_overridable :: bytes => ocean_redi_bytes

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

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

    Return Value integer(kind=int64)

procedure, public, non_overridable :: destroy => ocean_redi_destroy

procedure, public, non_overridable :: enter_data => ocean_redi_enter_data

procedure, public, non_overridable :: exit_data => ocean_redi_exit_data

procedure, public, non_overridable :: init => ocean_redi_init

  • private subroutine ocean_redi_init(this, grid, nz_ml)

    Allocate the Phase-A coefficient arrays. Always allocates (configure runs after init); off-state footprint is the six face-shaped (nsurf) coefficient arrays. Plain host allocation (no do concurrent before enter_data).

    Arguments

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

Source Code

   type :: ocean_redi_t
      !! Redi continuous neutral-diffusion state.  Defaults inert
      !! (`enable=.false.`) ⇒ bit-identical.  Reads the prognostic T/S + EOS
      !! directly (recomputes its own interface dR/dT, dR/dS — does NOT
      !! consume GM slopes).  Augments `rdb_ocean_hdiff_tracer`.
      logical :: is_init = .false.
         !! True between init/destroy; gate on this, not on `allocated`.
      logical :: enable = .false.
         !! Master switch.  Off => `redi_calc_coeffs`/`redi_apply_flux`
         !! no-op => bit-identity preserved.
      logical :: continuous = .true.
         !! Continuous variant (the only one shipped).  Discontinuous
         !! deferred (R4); a `.false.` value is rejected at configure.
      real(wp) :: khtr = 0.0_wp
         !! Scalar Redi neutral diffusivity (m^2/s); the FALLBACK used when
         !! VarMix is off (0 => no flux).  When VarMix is enabled its
         !! spatially-varying `khtr_u`/`khtr_v` override this per face.

      ! ---- Cached extents ----
      integer :: nx_total = 0
      integer :: ny_total = 0
      integer :: nz_ml = 0
      integer :: nsurf = 0
         !! 2*nz_ml + 2 (the neutral-surface count of the continuous sweep).

      ! ---- Phase-A device-resident coefficient arrays (per face) ----
      ! u-faces (nx+1,ny,nsurf); v-faces (nx,ny+1,nsurf).  Fractional
      ! positions PoL/PoR in [0,1], native-layer indices KoL/KoR (left/right
      ! column), and uhEff the harmonic-mean effective thickness of each of
      ! the nsurf-1 neutral sublayers.  KoL/KoR are stored TOP-DOWN (k=1
      ! surface); the only k-flip is the Phase-B scatter (native k = nz+1-Ko).
      real(wp), allocatable :: uPoL(:, :, :), uPoR(:, :, :)
      integer, allocatable :: uKoL(:, :, :), uKoR(:, :, :)
      real(wp), allocatable :: uhEff(:, :, :)
      real(wp), allocatable :: vPoL(:, :, :), vPoR(:, :, :)
      integer, allocatable :: vKoL(:, :, :), vKoR(:, :, :)
      real(wp), allocatable :: vhEff(:, :, :)
      ! ---- Per-face OPEN WINDOW (native, bottom-up layer range) ----
      ! `&vcoord_nml zfixed_closed_faces`: a face pairs only native layers
      ! `K*b..K*t` (module header).  Knob off ⇒ `1..nz` on every face.
      ! `K*t < K*b` marks a face with no open layer (inert).
      integer, allocatable :: uKb(:, :), uKt(:, :)
      integer, allocatable :: vKb(:, :), vKt(:, :)

      ! ---- Per-face neutral diffusivity KhTr (m^2/s) ----
      ! Filled each apply step from VarMix's `khtr_u`/`khtr_v` when enabled,
      ! else broadcast from the scalar `khtr` (VarMix-less ⇒ bit-identical).
      real(wp), allocatable :: khtr_u(:, :)
      real(wp), allocatable :: khtr_v(:, :)

      ! ---- Read-only tracer snapshot for the flux gather ----
      ! The double-visit flux reads NEIGHBOUR hTr AND writes its OWN — a
      ! do-concurrent read-write race against the live array.  `tr_snap` holds
      ! the pre-step hTr so the gather is order-independent on every backend.
      real(wp), allocatable :: tr_snap(:, :, :)
   contains
      procedure, non_overridable :: init => ocean_redi_init
      procedure, non_overridable :: destroy => ocean_redi_destroy
      procedure, non_overridable :: enter_data => ocean_redi_enter_data
      procedure, non_overridable :: exit_data => ocean_redi_exit_data
      procedure, non_overridable :: bytes => ocean_redi_bytes
   end type ocean_redi_t