Fill ghost faces of a 2D x-face field (e.g. bt_ubt, shape nx_total+1). Also copies the west physical-wall face value onto the east physical-wall face (belt-and-braces seam invariant, §1.1 property b). nx_face = nx_total + 1.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(inout) | :: | fld(nx_face,ny_total) |
x-face field, shape (nx_total+1, ny_total). |
||
| integer, | intent(in) | :: | nx_face | |||
| integer, | intent(in) | :: | ny_total | |||
| integer, | intent(in) | :: | nx_phys | |||
| integer, | intent(in) | :: | ny_phys | |||
| integer, | intent(in) | :: | nghost | |||
| logical, | intent(in) | :: | wrap_x | |||
| logical, | intent(in) | :: | wrap_y |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| integer, | private | :: | i_e | ||||
| integer, | private | :: | i_w | ||||
| integer, | private | :: | j |
pure subroutine ocean_periodic_wrap_face_x_2d(fld, nx_face, ny_total, & nx_phys, ny_phys, nghost, & wrap_x, wrap_y) !! Fill ghost faces of a 2D x-face field (e.g. bt_ubt, shape nx_total+1). !! Also copies the west physical-wall face value onto the east physical-wall !! face (belt-and-braces seam invariant, §1.1 property b). !! nx_face = nx_total + 1. integer, intent(in) :: nx_face, ny_total, nx_phys, ny_phys, nghost real(wp), intent(inout) :: fld(nx_face, ny_total) !! x-face field, shape (nx_total+1, ny_total). logical, intent(in) :: wrap_x logical, intent(in) :: wrap_y integer :: i, j integer :: i_w, i_e i_w = nghost + 1 ! west physical-wall face index i_e = nghost + nx_phys + 1 ! east physical-wall face index ! X-wrap (including belt-and-braces seam copy) in its own DC loop, ! then Y-wrap in a separate loop to avoid cross-iteration data dependencies. if (wrap_x) then do concurrent(j=1:ny_total, i=1:nx_face) ! West ghost faces i=1..nghost ← interior face i+nx_phys if (i <= nghost) then fld(i, j) = fld(i + nx_phys, j) end if ! East ghost faces i=nx_phys+nghost+2..nx_face ← interior face i-nx_phys if (i > nx_phys + nghost + 1) then fld(i, j) = fld(i - nx_phys, j) end if ! Belt-and-braces: copy west wall face onto east wall face. ! Ensures property (b) even if a kernel breaks expression symmetry. if (i == i_e) fld(i, j) = fld(i_w, j) end do end if if (wrap_y) then do concurrent(j=1:ny_total, i=1:nx_face) if (j <= nghost) then fld(i, j) = fld(i, j + ny_phys) end if if (j > ny_phys + nghost) then fld(i, j) = fld(i, j - ny_phys) end if end do end if end subroutine ocean_periodic_wrap_face_x_2d