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.
| Type | Intent | Optional | 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) |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private | :: | above | ||||
| integer, | private | :: | k |
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