ocean_sponge_init Subroutine

private subroutine ocean_sponge_init(this, grid, nz_ml, n_tracers)

Allocate the maps + reference-state arrays. Call ONLY when this%enable (the gated-closure convention, mirroring epbl/kshear/…) — the caller sets enable before calling, and ocean_state_init only reaches this when this%enable is .true. (see rdb_ocean_state.F90). ref_tracer is sized at max(n_tracers, 1) so an as-yet-empty tracer registry never trips a zero-extent allocate.

Type Bound

ocean_sponge_t

Arguments

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

Variables

Type Visibility Attributes Name Initial
integer, private :: nx
integer, private :: ny

Source Code

   subroutine ocean_sponge_init(this, grid, nz_ml, n_tracers)
      !! Allocate the maps + reference-state arrays. Call ONLY when
      !! `this%enable` (the gated-closure convention, mirroring
      !! epbl/kshear/...) — the caller sets `enable` before calling, and
      !! `ocean_state_init` only reaches this when `this%enable` is
      !! `.true.` (see `rdb_ocean_state.F90`). `ref_tracer` is sized at
      !! `max(n_tracers, 1)` so an as-yet-empty tracer registry never
      !! trips a zero-extent allocate.
      class(ocean_sponge_t), intent(inout) :: this
      type(hgrid_t), intent(in) :: grid
      integer, intent(in) :: nz_ml
      integer, intent(in) :: n_tracers

      integer :: nx, ny

      nx = grid%nx_total
      ny = grid%ny_total
      this%n_tracers = n_tracers
      allocate (this%idamp_h(nx, ny), source=0.0_wp)
      allocate (this%idamp_u(nx + 1, ny), source=0.0_wp)
      allocate (this%idamp_v(nx, ny + 1), source=0.0_wp)
      allocate (this%ref_tracer(nx, ny, nz_ml, max(n_tracers, 1)), source=0.0_wp)
      allocate (this%u_ref(nx + 1, ny, nz_ml), source=0.0_wp)
      allocate (this%v_ref(nx, ny + 1, nz_ml), source=0.0_wp)
      allocate (this%z_top(nx, ny), source=0.0_wp)
      this%is_init = .true.
   end subroutine ocean_sponge_init