subroutine barotropic_state_init(this, grid)
!! Allocate every C-grid barotropic array zero-filled. East-face arrays
!! are (nx+1, ny), north-face (nx, ny+1). Scalars (manning_n, coriolis_f)
!! are populated by `state_init_from_config` afterwards.
class(barotropic_state_t), intent(inout) :: this
type(hgrid_t), intent(in) :: grid
integer :: nx, ny
nx = grid%nx_total
ny = grid%ny_total
! Cell-centred scalars
allocate (this%h(nx, ny), source=0.0_wp)
allocate (this%b(nx, ny), source=0.0_wp)
allocate (this%flux_h(nx, ny), source=0.0_wp)
! East-face arrays: extra column, face index i runs 1..nx+1.
allocate (this%u_face_x(nx + 1, ny), source=0.0_wp)
allocate (this%hu_face_x(nx + 1, ny), source=0.0_wp)
allocate (this%mass_flux_x(nx + 1, ny), source=0.0_wp)
! North-face arrays: extra row, face index j runs 1..ny+1.
allocate (this%v_face_y(nx, ny + 1), source=0.0_wp)
allocate (this%hv_face_y(nx, ny + 1), source=0.0_wp)
allocate (this%mass_flux_y(nx, ny + 1), source=0.0_wp)
! RK2 save buffers
allocate (this%h0(nx, ny), source=0.0_wp)
allocate (this%u_face_x0(nx + 1, ny), source=0.0_wp)
allocate (this%v_face_y0(nx, ny + 1), source=0.0_wp)
this%is_init = .true.
end subroutine barotropic_state_init