build_z_ctr Subroutine

public pure subroutine build_z_ctr(h_layer, nz_ml, z_top, z_ctr)

Layer-centre GEOPOTENTIAL depths (positive-down from the z = 0 datum) from a column of layer thicknesses. Bottom-up: k=1 bed, k=nz_ml surface. z_ctr(k) = z_top + sum_{k'=k+1..nz_ml} h(k') + 0.5*h(k).

z_top is the depth of the TOP of the water column: 0 in the open ocean (the free-surface datum), z_draft(i,j) under an ice shelf. Passing 0 reproduces the pre-cavity arithmetic bit-for-bit — above starts at z_top and the very first addition is 0 + 0.5*h, the same expression as before.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: h_layer(nz_ml)
integer, intent(in) :: nz_ml
real(kind=wp), intent(in) :: z_top
real(kind=wp), intent(out) :: z_ctr(nz_ml)

Called by

proc~~build_z_ctr~~CalledByGraph proc~build_z_ctr build_z_ctr proc~seed_ts_from_zfile seed_ts_from_zfile proc~seed_ts_from_zfile->proc~build_z_ctr proc~seed_ts_linear_z seed_ts_linear_z proc~seed_ts_linear_z->proc~build_z_ctr proc~seed_zinit_overlay seed_zinit_overlay proc~seed_zinit_overlay->proc~seed_ts_from_zfile proc~seed_zinit_overlay->proc~seed_ts_linear_z proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_zinit_overlay proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: above
integer, private :: k

Source Code

   pure subroutine build_z_ctr(h_layer, nz_ml, z_top, z_ctr)
      !! Layer-centre GEOPOTENTIAL depths (positive-down from the `z = 0`
      !! datum) from a column of layer thicknesses.  Bottom-up: k=1 bed,
      !! k=nz_ml surface.
      !! `z_ctr(k) = z_top + sum_{k'=k+1..nz_ml} h(k') + 0.5*h(k)`.
      !!
      !! `z_top` is the depth of the TOP of the water column: `0` in the
      !! open ocean (the free-surface datum), `z_draft(i,j)` under an ice
      !! shelf.  Passing `0` reproduces the pre-cavity arithmetic
      !! bit-for-bit — `above` starts at `z_top` and the very first
      !! addition is `0 + 0.5*h`, the same expression as before.
      integer, intent(in) :: nz_ml
      real(wp), intent(in) :: h_layer(nz_ml)
      real(wp), intent(in) :: z_top
      real(wp), intent(out) :: z_ctr(nz_ml)

      integer :: k
      real(wp) :: above

      ! Accumulate from the surface (k=nz_ml) downward.  `above` holds
      ! the depth of the top of layer k: the column-top depth plus the
      ! total thickness of all layers shallower than k.
      above = z_top
      do k = nz_ml, 1, -1
         z_ctr(k) = above + 0.5_wp*h_layer(k)
         above = above + h_layer(k)
      end do
   end subroutine build_z_ctr