pure subroutine fill_h_layer_ghosts(h_layer, nx_total, ny_total, nz, &
i_w, i_e, j_s, j_n, nghost, &
bc_w, bc_e, bc_s, bc_n)
!! Zero-gradient fill of h_layer ghosts at open-ish edges.
integer, intent(in) :: nx_total, ny_total, nz, nghost
real(wp), intent(inout) :: h_layer(nx_total, ny_total, nz)
integer, intent(in) :: i_w, i_e, j_s, j_n
integer, intent(in) :: bc_w, bc_e, bc_s, bc_n
integer :: i, j, k, g
! West ghosts: copy first interior column (i_w) into ghost columns
if (is_open_ish(bc_w)) then
do concurrent(k=1:nz, j=1:ny_total, g=1:nghost)
h_layer(g, j, k) = h_layer(i_w, j, k)
end do
end if
! East ghosts
if (is_open_ish(bc_e)) then
do concurrent(k=1:nz, j=1:ny_total, g=1:nghost)
h_layer(nx_total - g + 1, j, k) = h_layer(i_e, j, k)
end do
end if
! South ghosts
if (is_open_ish(bc_s)) then
do concurrent(k=1:nz, j=1:nghost, i=1:nx_total)
h_layer(i, j, k) = h_layer(i, j_s, k)
end do
end if
! North ghosts
if (is_open_ish(bc_n)) then
do concurrent(k=1:nz, g=1:nghost, i=1:nx_total)
h_layer(i, ny_total - g + 1, k) = h_layer(i, j_n, k)
end do
end if
end subroutine fill_h_layer_ghosts