scratch_3d_buffer_t Derived Type

type, public :: scratch_3d_buffer_t


Inherited by

type~~scratch_3d_buffer_t~~InheritedByGraph type~scratch_3d_buffer_t scratch_3d_buffer_t type~continuity_t continuity_t type~continuity_t->type~scratch_3d_buffer_t h_face_left_x, h_face_right_x, h_face_left_y, h_face_right_y, mt_h_new, mt_grounded, pd_theta type~coriolis_adv_t coriolis_adv_t type~coriolis_adv_t->type~scratch_3d_buffer_t q_corner, ke_centre, pv_flux_x, pv_flux_y, mass_flux_u, mass_flux_v type~ocean_bottom_drag_t ocean_bottom_drag_t type~ocean_bottom_drag_t->type~scratch_3d_buffer_t du_drag, dv_drag, lambda_side_u, lambda_side_v type~ocean_epbl_t ocean_epbl_t type~ocean_epbl_t->type~scratch_3d_buffer_t t0, s0, dpe_t, dpe_s, dcolht_t, dcolht_s, ctke_sw type~ocean_hdiff_tracer_t ocean_hdiff_tracer_t type~ocean_hdiff_tracer_t->type~scratch_3d_buffer_t T_centre, F_x_face, F_y_face type~ocean_horizontal_viscosity_t ocean_horizontal_viscosity_t type~ocean_horizontal_viscosity_t->type~scratch_3d_buffer_t du_visc, dv_visc, lap_u, lap_v, str_xx, str_xy, ah_t, ah_q type~ocean_lateral_mix_t ocean_lateral_mix_t type~ocean_lateral_mix_t->type~scratch_3d_buffer_t vort_corner type~ocean_pressure_force_t ocean_pressure_force_t type~ocean_pressure_force_t->type~scratch_3d_buffer_t p_edge, z_centre, mont_M, rho_insitu, dpdx_face, dpdy_face, e_face, pa, intz_dpa, intx_pa, inty_pa, intx_dpa, inty_dpa, conc_T, conc_S, recon_T_t, recon_T_b, recon_S_t, recon_S_b type~ocean_surface_stress_t ocean_surface_stress_t type~ocean_surface_stress_t->type~scratch_3d_buffer_t du_stress, dv_stress type~ocean_top_drag_t ocean_top_drag_t type~ocean_top_drag_t->type~scratch_3d_buffer_t du_drag, dv_drag type~ocean_vdiff_t ocean_vdiff_t type~ocean_vdiff_t->type~scratch_3d_buffer_t a_diag_t, b_diag_t, c_diag_t, rhs_t, a_diag_u, b_diag_u, c_diag_u, rhs_u, a_diag_v, b_diag_v, c_diag_v, rhs_v, kv_scalar_buf type~ocean_vertical_advection_t ocean_vertical_advection_t type~ocean_vertical_advection_t->type~scratch_3d_buffer_t F_face type~ocean_state_t ocean_state_t type~ocean_state_t->type~continuity_t continuity type~ocean_state_t->type~coriolis_adv_t coriolis_adv type~ocean_state_t->type~ocean_bottom_drag_t bdrag type~ocean_state_t->type~ocean_epbl_t epbl type~ocean_state_t->type~ocean_hdiff_tracer_t hdiff_tracer type~ocean_state_t->type~ocean_horizontal_viscosity_t hvisc type~ocean_state_t->type~ocean_lateral_mix_t lateral_mix type~ocean_state_t->type~ocean_pressure_force_t pressure_force type~ocean_state_t->type~ocean_surface_stress_t surface_stress type~ocean_state_t->type~ocean_top_drag_t tdrag type~ocean_state_t->type~ocean_vdiff_t vdiff type~ocean_state_t->type~ocean_vertical_advection_t vert_advect 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 :: data(:,:,:)

The scratch storage. Access in a kernel as slot%scratch%data(i, j, k). Note: this is a single derived type (not array-of-derived-types), so the !$acc indirection bug from the array-of-DT pattern does not apply.

logical, public :: is_init = .false.

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

integer, public :: n1 = 0

First-dim size, typically stride (or stride+1 on face-located buffers).

integer, public :: n2 = 0

Second-dim size, typically stride.

integer, public :: n3 = 0

Third-dim size, typically nz_ml (or nz_ml+1 for layer-interface buffers).

character(len=32), public :: name = ""

Human-readable tag for diagnostics + debug guard messages (“kpp_bulk_ri_scratch”, “ppm_h_face_left_x”, …).


Type-Bound Procedures

procedure, public, non_overridable :: bytes => scratch_3d_buffer_bytes

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

    Counted allocatable footprint of the 3D scratch buffer slot (0 when unallocated).

    Arguments

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

    Return Value integer(kind=int64)

procedure, public, non_overridable :: destroy => scratch_3d_buffer_destroy

procedure, public, non_overridable :: enter_data => scratch_3d_buffer_enter_data

  • private subroutine scratch_3d_buffer_enter_data(this)

    Type-bound wrapper — keeps buf%enter_data() call sites working. Delegates to the non-polymorphic impl so the OpenMP map base is the heap object (see the impl + the public-decl comment above).

    Arguments

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

procedure, public, non_overridable :: exit_data => scratch_3d_buffer_exit_data

procedure, public, non_overridable :: init => scratch_3d_buffer_init

  • private subroutine scratch_3d_buffer_init(this, n1, n2, n3, name)

    Allocate the host-side storage at (n1, n2, n3), zero-filled. GPU attachment is a separate step via enter_data — init runs before the device exists in the typical init-then-enter-data sequence.

    Arguments

    Type IntentOptional Attributes Name
    class(scratch_3d_buffer_t), intent(inout) :: this
    integer, intent(in) :: n1
    integer, intent(in) :: n2
    integer, intent(in) :: n3
    character(len=*), intent(in), optional :: name

Source Code

   type :: scratch_3d_buffer_t
      logical :: is_init = .false.
         !! True between `init` and `destroy`.  Prefer this to
         !! `allocated(this%data)` — tracks GPU device attachment too.

      ! ---- Declared shape ----
      integer :: n1 = 0
         !! First-dim size, typically `stride` (or `stride+1` on
         !! face-located buffers).
      integer :: n2 = 0
         !! Second-dim size, typically `stride`.
      integer :: n3 = 0
         !! Third-dim size, typically `nz_ml` (or `nz_ml+1` for
         !! layer-interface buffers).

      ! ---- Payload ----
      real(wp), allocatable :: data(:, :, :)
         !! The scratch storage.  Access in a kernel as
         !! `slot%scratch%data(i, j, k)`.  Note: this is a *single*
         !! derived type (not array-of-derived-types), so the
         !! `!$acc` indirection bug from the array-of-DT pattern
         !! does not apply.

      ! ---- Optional name ----
      character(len=32) :: name = ""
         !! Human-readable tag for diagnostics + debug guard
         !! messages ("kpp_bulk_ri_scratch", "ppm_h_face_left_x", ...).
   contains
      procedure, non_overridable :: init => scratch_3d_buffer_init
      procedure, non_overridable :: destroy => scratch_3d_buffer_destroy
      procedure, non_overridable :: enter_data => scratch_3d_buffer_enter_data
      procedure, non_overridable :: exit_data => scratch_3d_buffer_exit_data
      ! Phase 6+: procedure :: assert_finite — debug-mode invariant
      procedure, non_overridable :: bytes => scratch_3d_buffer_bytes
   end type scratch_3d_buffer_t