subroutine ocean_hvisc_init(this, grid, nz_ml)
!! Allocate the two tendency scratch buffers. Same
!! optional-`nz_ml` pattern as the other ocean kernels — default
!! 1 keeps the barotropic-only constructor valid; pass `nz_ml`
!! to size for the multilayer driver.
class(ocean_horizontal_viscosity_t), intent(inout) :: this
type(hgrid_t), intent(in) :: grid
integer, intent(in), optional :: nz_ml
integer :: nx, ny, nz
nx = grid%nx_total
ny = grid%ny_total
nz = 1
if (present(nz_ml)) nz = nz_ml
call this%du_visc%init(nx + 1, ny, nz, "ocean_hvisc_du_visc")
call this%dv_visc%init(nx, ny + 1, nz, "ocean_hvisc_dv_visc")
call this%lap_u%init(nx + 1, ny, nz, "ocean_hvisc_lap_u")
call this%lap_v%init(nx, ny + 1, nz, "ocean_hvisc_lap_v")
call this%str_xx%init(nx, ny, nz, "ocean_hvisc_str_xx")
call this%str_xy%init(nx + 1, ny + 1, nz, "ocean_hvisc_str_xy")
call this%ah_t%init(nx, ny, nz, "ocean_hvisc_ah_t")
call this%ah_q%init(nx + 1, ny + 1, nz, "ocean_hvisc_ah_q")
allocate (this%ke_diss(nx, ny), source=0.0_wp)
this%is_init = .true.
end subroutine ocean_hvisc_init