Fill the north halo of a 2D x-face (Cu) field. Sign-flipped by
default (negate absent / .true., the true-vector contract —
wind stress, velocity). negate=.false. copies instead: for a
SCALAR carried on a u-face (e.g. the viscous remnant visc_rem_u
— a fraction, not a flux component), the 180-degree fold rotation
still swaps which side of the seam the value sits on, but the
value itself does not change sign (see fold_north_corner_2d’s
negate for the matching corner-stagger contract).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(inout) | :: | u(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), | optional | :: | negate |
|
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | fsum | ||||
| integer, | private | :: | i | ||||
| integer, | private | :: | j | ||||
| integer, | private | :: | j_lo | ||||
| integer, | private | :: | jsum | ||||
| real(kind=wp), | private | :: | sgn |
pure subroutine fold_north_u_face_2d(u, nx_face, ny_total, & nx_phys, ny_phys, nghost, negate) !! Fill the north halo of a 2D x-face (Cu) field. Sign-flipped by !! default (`negate` absent / `.true.`, the true-vector contract — !! wind stress, velocity). `negate=.false.` copies instead: for a !! SCALAR carried on a u-face (e.g. the viscous remnant `visc_rem_u` !! — a fraction, not a flux component), the 180-degree fold rotation !! still swaps which side of the seam the value sits on, but the !! value itself does not change sign (see `fold_north_corner_2d`'s !! `negate` for the matching corner-stagger contract). integer, intent(in) :: nx_face, ny_total, nx_phys, ny_phys, nghost real(wp), intent(inout) :: u(nx_face, ny_total) !! x-face field, shape (nx_total+1, ny_total). logical, intent(in), optional :: negate !! `.true.` (default) = true-vector component; `.false.` = scalar. integer :: i, j, fsum, jsum, j_lo real(wp) :: sgn sgn = -1.0_wp if (present(negate)) then if (.not. negate) sgn = 1.0_wp end if fsum = 2*nghost + nx_phys + 2 jsum = 2*nghost + 2*ny_phys + 1 j_lo = nghost + ny_phys + 1 do concurrent(j=j_lo:ny_total, i=1:nx_face) u(i, j) = sgn*u(fsum - i, jsum - j) end do end subroutine fold_north_u_face_2d