barotropic_workstate_init Subroutine

private subroutine barotropic_workstate_init(this, grid, nz_ml)

Allocate the 2D barotropic-substep arrays. Pass nz_ml to also allocate the split-driver slow-tendency accumulators; omit when only the 2D barotropic substep is needed (unit tests).

Type Bound

barotropic_workstate_t

Arguments

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

Called by

proc~~barotropic_workstate_init~~CalledByGraph proc~barotropic_workstate_init barotropic_workstate_t%barotropic_workstate_init proc~ocean_dyn_init ocean_dyn_t%ocean_dyn_init proc~ocean_dyn_init->proc~barotropic_workstate_init

Variables

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

Source Code

   subroutine barotropic_workstate_init(this, grid, nz_ml)
      !! Allocate the 2D barotropic-substep arrays.  Pass `nz_ml` to also
      !! allocate the split-driver slow-tendency accumulators; omit
      !! when only the 2D barotropic substep is needed (unit tests).
      class(barotropic_workstate_t), intent(inout) :: this
      type(hgrid_t), intent(in) :: grid
      integer, intent(in), optional :: nz_ml
      integer :: nx, ny, nz

      nx = grid%nx_total
      ny = grid%ny_total

      allocate (this%bt_eta(nx, ny), source=0.0_wp)
      allocate (this%bt_H_ref(nx, ny), source=0.0_wp)
      allocate (this%bt_ubt(nx + 1, ny), source=0.0_wp)
      allocate (this%bt_vbt(nx, ny + 1), source=0.0_wp)
      allocate (this%eta_sum(nx, ny), source=0.0_wp)
      allocate (this%ubt_sum(nx + 1, ny), source=0.0_wp)
      allocate (this%vbt_sum(nx, ny + 1), source=0.0_wp)
      allocate (this%uhbt_sum(nx + 1, ny), source=0.0_wp)
      allocate (this%vhbt_sum(nx, ny + 1), source=0.0_wp)
      allocate (this%bt_uhbt(nx + 1, ny), source=0.0_wp)
      allocate (this%bt_vhbt(nx, ny + 1), source=0.0_wp)
      allocate (this%bt_ubt_end(nx + 1, ny), source=0.0_wp)
      allocate (this%bt_vbt_end(nx, ny + 1), source=0.0_wp)
      allocate (this%bt_eta_end(nx, ny), source=0.0_wp)
      allocate (this%bt_zeta_corner(nx + 1, ny + 1), source=0.0_wp)
      allocate (this%bt_ke_centre(nx, ny), source=0.0_wp)
      allocate (this%bt_eta_new(nx, ny), source=0.0_wp)
      allocate (this%cor_ref_u(nx + 1, ny), source=0.0_wp)
      allocate (this%cor_ref_v(nx, ny + 1), source=0.0_wp)
      allocate (this%bt_ubt_prev(nx + 1, ny), source=0.0_wp)
      allocate (this%bt_vbt_prev(nx, ny + 1), source=0.0_wp)

      if (present(nz_ml)) then
         nz = nz_ml
         allocate (this%F_slow_u(nx + 1, ny, nz), source=0.0_wp)
         allocate (this%F_slow_v(nx, ny + 1, nz), source=0.0_wp)
         allocate (this%F_bt_u(nx + 1, ny), source=0.0_wp)
         allocate (this%F_bt_v(nx, ny + 1), source=0.0_wp)
         allocate (this%F_bt_u_fast(nx + 1, ny), source=0.0_wp)
         allocate (this%F_bt_v_fast(nx, ny + 1), source=0.0_wp)
         allocate (this%ubt_at_n(nx + 1, ny), source=0.0_wp)
         allocate (this%vbt_at_n(nx, ny + 1), source=0.0_wp)
         allocate (this%pbce(nx, ny, nz), source=0.0_wp)
         allocate (this%gtot_E(nx, ny), source=0.0_wp)
         allocate (this%gtot_W(nx, ny), source=0.0_wp)
         allocate (this%gtot_N(nx, ny), source=0.0_wp)
         allocate (this%gtot_S(nx, ny), source=0.0_wp)
         allocate (this%e_anom(nx, ny), source=0.0_wp)
         allocate (this%eta_PF(nx, ny), source=0.0_wp)
         allocate (this%visc_rem_u(nx + 1, ny, nz), source=1.0_wp)
         allocate (this%visc_rem_v(nx, ny + 1, nz), source=1.0_wp)
      end if

      ! bt_rem_u/v are referenced unconditionally (no-op when ≡ 1);
      ! allocate outside the nz_ml block so barotropic-only unit tests
      ! still get them.
      allocate (this%bt_rem_u(nx + 1, ny), source=1.0_wp)
      allocate (this%bt_rem_v(nx, ny + 1), source=1.0_wp)
      allocate (this%av_rem_u(nx + 1, ny), source=1.0_wp)
      allocate (this%av_rem_v(nx, ny + 1), source=1.0_wp)

      ! BT_cont_type coefficient packs are allocated lazily by the
      ! driver after the namelist toggle is read.

      this%is_init = .true.
   end subroutine barotropic_workstate_init