pure subroutine hvisc_add_aniso_coef(ah_t, ah_q, kh_aniso, n1n2, nx, ny, nz)
!! Add the Smith & McWilliams (2003) anisotropic direction-tensor
!! coefficients onto the co-located isotropic viscosities. The
!! tension (T-cell) coefficient gains `kh_aniso·(1−n1n2²)` and the
!! shear (Bu-corner) coefficient gains `kh_aniso·n1n2²`. For the
!! default grid-i direction `n1n2 = 0` ⇒ T gains `kh_aniso`, the
!! corner gains nothing — stronger damping of along-i tension.
!! The corner outer ring stays untouched (the divergence stencil
!! never reads it; `hvisc_avg_A_face` already zeroed it).
integer, intent(in) :: nx, ny, nz
real(wp), intent(inout) :: ah_t(nx, ny, nz), ah_q(nx + 1, ny + 1, nz)
real(wp), intent(in) :: kh_aniso, n1n2
integer :: i, j, k
real(wp) :: add_t, add_q
add_t = kh_aniso*(1.0_wp - n1n2*n1n2)
add_q = kh_aniso*(n1n2*n1n2)
do concurrent(k=1:nz, j=1:ny, i=1:nx)
ah_t(i, j, k) = ah_t(i, j, k) + add_t
end do
do concurrent(k=1:nz, j=2:ny, i=2:nx)
ah_q(i, j, k) = ah_q(i, j, k) + add_q
end do
end subroutine hvisc_add_aniso_coef