pure subroutine evp_sh_ds_impl(dx_dyBu, dy_dxBu, idxCu, idyCv, mask_q, ui, vi, sh_ds, nx, ny)
!! sh_Ds at corners (:1045-1050) — requirement (4): the SINGLE
!! scalar no-slip factor `(2-mask_q)` on the WHOLE combined strain.
!! Computed over the interior+1 ring (ic,jc in [1,nx+1]x[1,ny+1] —
!! the full corner array; out-of-band neighbours contribute 0 via
!! zero ghost velocities at the hard array edges, never per-term
!! mirroring).
integer, intent(in) :: nx, ny
real(wp), intent(in) :: dx_dyBu(nx + 1, ny + 1), dy_dxBu(nx + 1, ny + 1)
real(wp), intent(in) :: idxCu(nx + 1, ny), idyCv(nx, ny + 1)
real(wp), intent(in) :: mask_q(nx + 1, ny + 1)
real(wp), intent(in) :: ui(nx + 1, ny), vi(nx, ny + 1)
real(wp), intent(out) :: sh_ds(nx + 1, ny + 1)
integer :: ic, jc
real(wp) :: du_term, dv_term
do concurrent(jc=1:ny + 1, ic=1:nx + 1) local(du_term, dv_term)
du_term = 0.0_wp
if (jc <= ny .and. jc >= 1) then
du_term = ui(ic, jc)*idxCu(ic, jc)
end if
if (jc - 1 >= 1 .and. jc - 1 <= ny) then
du_term = du_term - ui(ic, jc - 1)*idxCu(ic, jc - 1)
end if
dv_term = 0.0_wp
if (ic <= nx .and. ic >= 1) then
dv_term = vi(ic, jc)*idyCv(ic, jc)
end if
if (ic - 1 >= 1 .and. ic - 1 <= nx) then
dv_term = dv_term - vi(ic - 1, jc)*idyCv(ic - 1, jc)
end if
sh_ds(ic, jc) = (2.0_wp - mask_q(ic, jc))*(dx_dyBu(ic, jc)*du_term + &
dy_dxBu(ic, jc)*dv_term)
end do
end subroutine evp_sh_ds_impl