ocean_cavity_flux_init Subroutine

private subroutine ocean_cavity_flux_init(this, grid)

Allocate the slot. Gated on enable (latched by ocean_state_init_from_config before this runs), so a run without a cavity pays fourteen (1,1) placeholders.

Type Bound

ocean_cavity_flux_t

Arguments

Type IntentOptional Attributes Name
class(ocean_cavity_flux_t), intent(inout) :: this
type(hgrid_t), intent(in) :: grid

Variables

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

Source Code

   subroutine ocean_cavity_flux_init(this, grid)
      !! Allocate the slot.  Gated on `enable` (latched by
      !! `ocean_state_init_from_config` before this runs), so a run
      !! without a cavity pays fourteen `(1,1)` placeholders.
      class(ocean_cavity_flux_t), intent(inout) :: this
      type(hgrid_t), intent(in) :: grid
      integer :: nx, ny

      if (this%enable) then
         nx = grid%nx_total
         ny = grid%ny_total
      else
         nx = 1
         ny = 1
      end if

      allocate (this%f_cor(nx, ny), source=0.0_wp)
      allocate (this%active(nx, ny), source=0.0_wp)
      allocate (this%t_far(nx, ny), source=0.0_wp)
      allocate (this%s_far(nx, ny), source=0.0_wp)
      allocate (this%u_far(nx, ny), source=0.0_wp)
      allocate (this%v_far(nx, ny), source=0.0_wp)
      allocate (this%ustar(nx, ny), source=0.0_wp)
      allocate (this%t_b(nx, ny), source=0.0_wp)
      allocate (this%s_b(nx, ny), source=0.0_wp)
      allocate (this%melt(nx, ny), source=0.0_wp)
      allocate (this%q_ocean(nx, ny), source=0.0_wp)
      allocate (this%gamma_t(nx, ny), source=0.0_wp)
      allocate (this%gamma_s(nx, ny), source=0.0_wp)
      allocate (this%status(nx, ny), source=CAVITY_MELT_OK)
      ! `comp_scale` is a RATIO, so its inert value is 1, not 0 — a
      ! zero-initialised plane would annihilate every passive tracer's
      ! top layer the first time it was applied.
      allocate (this%comp_scale(nx, ny), source=1.0_wp)
      this%is_init = .true.
   end subroutine ocean_cavity_flux_init