pure subroutine evp_wrap_corner_impl(fld, nx_face, ny_face, nx_phys, ny_phys, nghost, &
wrap_x, wrap_y)
!! Periodic ghost-wrap for a corner-staggered field (e.g. `str_s`),
!! shape (nx_total+1, ny_total+1). No corner-wrap helper exists in
!! `rdb_ocean_periodic` (only centre/face_x/face_y) — this is the
!! EVP-local twin, same two-pass (x-then-y) structure.
integer, intent(in) :: nx_face, ny_face, nx_phys, ny_phys, nghost
real(wp), intent(inout) :: fld(nx_face, ny_face)
logical, intent(in) :: wrap_x, wrap_y
integer :: i, j
integer :: i_w, i_e, j_s, j_n
i_w = nghost + 1
i_e = nghost + nx_phys + 1
j_s = nghost + 1
j_n = nghost + ny_phys + 1
if (wrap_x) then
do concurrent(j=1:ny_face, i=1:nx_face)
if (i <= nghost) then
fld(i, j) = fld(i + nx_phys, j)
end if
if (i > nx_phys + nghost + 1) then
fld(i, j) = fld(i - nx_phys, j)
end if
if (i == i_e) fld(i, j) = fld(i_w, j)
end do
end if
if (wrap_y) then
do concurrent(j=1:ny_face, i=1:nx_face)
if (j <= nghost) then
fld(i, j) = fld(i, j + ny_phys)
end if
if (j > ny_phys + nghost + 1) then
fld(i, j) = fld(i, j - ny_phys)
end if
if (j == j_n) fld(i, j) = fld(i, j_s)
end do
end if
end subroutine evp_wrap_corner_impl