subroutine wave_drag_roughness_proxy(b, wet_T, nx, ny, nghost, kappa, n_bot, h2_max, r_h)
!! `form="roughness_proxy"` filler — a DOCUMENTED PLACEHOLDER for
!! Jayne & St Laurent (2001)'s subgrid `<h^2>`, not a substitute for
!! it (that needs PR-14's file reader or PR-30's field-valued
!! roughness). Estimates the subgrid topographic-height variance from
!! the RESOLVED 2-delta bathymetry increment:
!! <h^2>_proxy(i,j) = 1/4*[(b(i+1,j)-b(i-1,j))^2 + (b(i,j+1)-b(i,j-1))^2]
!! then `r_H = 1/2*kappa*min(<h^2>_proxy, h2_max)*N_bot`. `b` is
!! bottom elevation, positive UP (`rdb_barotropic_state.F90`) —
!! differences are sign-independent. Zero on land (`wet_T==0`) and on
!! the ghost ring (the 2-delta stencil is unavailable there; a
!! formula-bathymetry path that leaves ghosts unfilled would
!! otherwise manufacture a spurious cliff at the ghost seam — CLAUDE.md
!! "Formula bathymetry setters must fill ghost rows").
integer, intent(in) :: nx, ny, nghost
real(wp), intent(in) :: b(nx, ny), wet_T(nx, ny)
real(wp), intent(in) :: kappa, n_bot, h2_max
real(wp), intent(inout) :: r_h(nx, ny)
integer :: i, j
real(wp) :: h2
r_h = 0.0_wp
do j = nghost + 1, ny - nghost
do i = nghost + 1, nx - nghost
if (wet_T(i, j) <= 0.0_wp) cycle
h2 = 0.25_wp*((b(i + 1, j) - b(i - 1, j))**2 + (b(i, j + 1) - b(i, j - 1))**2)
r_h(i, j) = 0.5_wp*kappa*min(h2, h2_max)*n_bot
end do
end do
end subroutine wave_drag_roughness_proxy