pure subroutine ocean_slopes_mask_open_column(nx, ny, nz, open_u, open_v, &
slope_x, slope_y, n2_u, n2_v)
!! Zero slope / N² at every interior interface `K` that is NOT
!! strictly inside its face's open column, i.e. unless both layers it
!! separates (`K` above, `K-1` below) are open at that face
!! (`&vcoord_nml zfixed_closed_faces`). Assigned under a test, never
!! multiplied by the 0/1 mask, so a non-finite value formed against a
!! filler cannot survive as `NaN·0`.
integer, intent(in) :: nx, ny, nz
real(wp), intent(in) :: open_u(nx + 1, ny, nz)
real(wp), intent(in) :: open_v(nx, ny + 1, nz)
real(wp), intent(inout) :: slope_x(nx + 1, ny, nz + 1)
real(wp), intent(inout) :: slope_y(nx, ny + 1, nz + 1)
real(wp), intent(inout) :: n2_u(nx + 1, ny, nz + 1)
real(wp), intent(inout) :: n2_v(nx, ny + 1, nz + 1)
integer :: i, j, k
do concurrent(k=2:nz, j=1:ny, i=1:nx + 1)
if (open_u(i, j, k) < 0.5_wp .or. open_u(i, j, k - 1) < 0.5_wp) then
slope_x(i, j, k) = 0.0_wp
n2_u(i, j, k) = 0.0_wp
end if
end do
do concurrent(k=2:nz, j=1:ny + 1, i=1:nx)
if (open_v(i, j, k) < 0.5_wp .or. open_v(i, j, k - 1) < 0.5_wp) then
slope_y(i, j, k) = 0.0_wp
n2_v(i, j, k) = 0.0_wp
end if
end do
end subroutine ocean_slopes_mask_open_column