ocean_slopes_t Derived Type

type, public :: ocean_slopes_t


Inherited by

type~~ocean_slopes_t~~InheritedByGraph type~ocean_slopes_t ocean_slopes_t type~ocean_state_t ocean_state_t type~ocean_state_t->type~ocean_slopes_t slopes 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, allocatable :: bathy(:,:)

Bed depth D below the z = 0 datum (m, positive down), (nx, ny) INCLUDING ghosts — the slot’s own copy of barotropic%b, taken by set_bathymetry after the periodic wrap + halo exchange and before enter_data. The bed datum of e_int; see the module docstring.

logical, public :: bathy_set = .false.

True once set_bathymetry has filled bathy. An enabled ocean_slopes_compute fails loud without it: a silent zero datum is exactly the bathymetry-as-slope defect.

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

Geopotential interface height (m, positive up from z = 0), (nx, ny, nz+1): e_int(:,:,1) = −bathy (bed), then bottom-up cumulative + h_layer; (:,:,nz+1) = column top.

logical, public :: enable = .false.

Master switch (&ocean_slopes_nml enable). Default off ⇒ ocean_slopes_compute no-ops ⇒ bit-identical.

logical, public :: is_init = .false.

True between init and destroy. Guard on this, never on allocated(...) (host pointer only; misses GPU mapping).

real(kind=wp), public :: kd_smooth = 1.0e-6_wp

Vertical diffusivity (m²/s) used by vert_fill_TS to fill massless layers. Multiplied by dt for the smoothing kappa·dt.

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

Minimum layer thickness (m) used to floor h in the N² vertical-difference denominator, so vanished layers don’t produce a spurious N² spike.

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

Brunt-Väisälä N² at u-faces (s⁻²), shape (nx+1, ny, nz+1).

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

Brunt-Väisälä N² at v-faces (s⁻²), shape (nx, ny+1, nz+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³) for the N² scaling g/ρ₀.

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

Massless-layer-filled salinity scratch, (nx, ny, nz).

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

Isopycnal slope at u-faces, shape (nx+1, ny, nz+1).

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

Isopycnal slope at v-faces, shape (nx, ny+1, nz+1).

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

Massless-layer-filled temperature scratch, (nx, ny, nz).


Type-Bound Procedures

procedure, public, non_overridable :: bytes => ocean_slopes_bytes

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

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

    Return Value integer(kind=int64)

procedure, public, non_overridable :: destroy => ocean_slopes_destroy

procedure, public, non_overridable :: enter_data => ocean_slopes_enter_data

  • private subroutine ocean_slopes_enter_data(this)

    Poly TBP delegating to a type(...)-arg _impl (AMD-crash rule: bare polymorphic copyin(this) maps the stack descriptor → AMD libomptarget cross-slot overlap crash).

    Arguments

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

procedure, public, non_overridable :: exit_data => ocean_slopes_exit_data

procedure, public, non_overridable :: init => ocean_slopes_init

  • private subroutine ocean_slopes_init(this, grid, nz_ml)

    Allocate the slope / N² outputs + the vert-fill T/S scratch + the interface-height buffer. Default nz_ml = 1 preserves the barotropic-only constructor; pass nz_ml = ms%nz_ml for the multilayer driver. Setup code uses plain host allocation (no do concurrent before enter_data).

    Arguments

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

procedure, public, non_overridable :: set_bathymetry => ocean_slopes_set_bathymetry

  • private subroutine ocean_slopes_set_bathymetry(this, b)

    Copy the bed depth b (m, positive down, (nx_total, ny_total) incl. ghosts) into this%bathy on the host. Call it with the WRAPPED + halo-exchanged barotropic%b (the seam faces read the ghosts) and BEFORE enter_data (the device copy is taken from the host values); to refresh after enter_data the caller issues !$acc update device(this%bathy) itself. No-op on an uninitialised slot.

    Arguments

    Type IntentOptional Attributes Name
    class(ocean_slopes_t), intent(inout) :: this
    real(kind=wp), intent(in) :: b(:,:)

Source Code

   type :: ocean_slopes_t
      logical :: is_init = .false.
         !! True between `init` and `destroy`.  Guard on this, never on
         !! `allocated(...)` (host pointer only; misses GPU mapping).
      logical :: enable = .false.
         !! Master switch (`&ocean_slopes_nml enable`).  Default off ⇒
         !! `ocean_slopes_compute` no-ops ⇒ bit-identical.
      real(wp) :: kd_smooth = 1.0e-6_wp
         !! Vertical diffusivity (m²/s) used by `vert_fill_TS` to fill
         !! massless layers.  Multiplied by `dt` for the smoothing
         !! `kappa·dt`.
      real(wp) :: min_dz_for_n2 = 1.0_wp
         !! Minimum layer thickness (m) used to floor `h` in the N²
         !! vertical-difference denominator, so vanished layers don't
         !! produce a spurious N² spike.
      real(wp) :: rho0 = 1035.0_wp
         !! Reference density (kg/m³) for the N² scaling `g/ρ₀`.

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

      ! ---- Outputs (interface-located) ----
      real(wp), allocatable :: slope_x(:, :, :)
         !! Isopycnal slope at u-faces, shape `(nx+1, ny, nz+1)`.
      real(wp), allocatable :: slope_y(:, :, :)
         !! Isopycnal slope at v-faces, shape `(nx, ny+1, nz+1)`.
      real(wp), allocatable :: n2_u(:, :, :)
         !! Brunt-Väisälä N² at u-faces (s⁻²), shape `(nx+1, ny, nz+1)`.
      real(wp), allocatable :: n2_v(:, :, :)
         !! Brunt-Väisälä N² at v-faces (s⁻²), shape `(nx, ny+1, nz+1)`.

      ! ---- Vert-filled T/S scratch + interface height ----
      real(wp), allocatable :: t_fill(:, :, :)
         !! Massless-layer-filled temperature scratch, `(nx, ny, nz)`.
      real(wp), allocatable :: s_fill(:, :, :)
         !! Massless-layer-filled salinity scratch, `(nx, ny, nz)`.
      real(wp), allocatable :: e_int(:, :, :)
         !! Geopotential interface height (m, positive up from `z = 0`),
         !! `(nx, ny, nz+1)`: `e_int(:,:,1) = −bathy` (bed), then bottom-up
         !! cumulative `+ h_layer`; `(:,:,nz+1)` = column top.

      ! ---- Static geometry ----
      real(wp), allocatable :: bathy(:, :)
         !! Bed depth `D` below the `z = 0` datum (m, positive down),
         !! `(nx, ny)` INCLUDING ghosts — the slot's own copy of
         !! `barotropic%b`, taken by `set_bathymetry` after the periodic
         !! wrap + halo exchange and before `enter_data`.  The bed datum of
         !! `e_int`; see the module docstring.
      logical :: bathy_set = .false.
         !! True once `set_bathymetry` has filled `bathy`.  An enabled
         !! `ocean_slopes_compute` fails loud without it: a silent zero
         !! datum is exactly the bathymetry-as-slope defect.
   contains
      procedure, non_overridable :: init => ocean_slopes_init
      procedure, non_overridable :: set_bathymetry => ocean_slopes_set_bathymetry
      procedure, non_overridable :: destroy => ocean_slopes_destroy
      procedure, non_overridable :: enter_data => ocean_slopes_enter_data
      procedure, non_overridable :: exit_data => ocean_slopes_exit_data
      procedure, non_overridable :: bytes => ocean_slopes_bytes
   end type ocean_slopes_t