subroutine tides_configure_astronomy(this, cat_idx, nconst, dref, dnodal, &
add_nodal, nx, ny)
!! Allocate the active-constituent arrays + 2D fields and fill the
!! catalog copies + astronomy (phase0, nodal f/u) at the reference
!! and nodal reference day numbers. Host-side setup (before
!! enter_data). `cat_idx(1:nconst)` are catalog indices
!! (1..TIDES_CATALOG_SIZE).
class(ocean_tides_t), intent(inout) :: this
integer, intent(in) :: nconst
integer, intent(in) :: cat_idx(nconst)
real(wp), intent(in) :: dref, dnodal
logical, intent(in) :: add_nodal
integer, intent(in) :: nx, ny
real(wp) :: v_all(TIDES_CATALOG_SIZE)
real(wp) :: f_all(TIDES_CATALOG_SIZE), u_all(TIDES_CATALOG_SIZE)
integer :: c, ic
this%nconst = nconst
if (allocated(this%species_c)) deallocate (this%species_c)
allocate (this%species_c(nconst))
allocate (this%omega_c(nconst), this%amp_c(nconst), this%love_c(nconst))
allocate (this%phase0(nconst), this%f_nodal(nconst), this%u_nodal(nconst))
allocate (this%amp_cos(nconst), this%amp_sin(nconst))
call equilibrium_arguments(dref, v_all)
call nodal_fu(dnodal, add_nodal, f_all, u_all)
do c = 1, nconst
ic = cat_idx(c)
this%species_c(c) = TIDE_SPECIES(ic)
this%omega_c(c) = TIDE_OMEGA(ic)
this%amp_c(c) = TIDE_AMP(ic)
this%love_c(c) = TIDE_LOVE(ic)
this%phase0(c) = v_all(ic)
this%f_nodal(c) = f_all(ic)
this%u_nodal(c) = u_all(ic)
this%amp_cos(c) = 0.0_wp
this%amp_sin(c) = 0.0_wp
end do
if (allocated(this%cos_struct)) deallocate (this%cos_struct)
allocate (this%cos_struct(nx, ny, 3), source=0.0_wp)
allocate (this%sin_struct(nx, ny, 3), source=0.0_wp)
allocate (this%eta_eq(nx, ny), source=0.0_wp)
allocate (this%eta_sal(nx, ny), source=0.0_wp)
allocate (this%eta_forcing(nx, ny), source=0.0_wp)
end subroutine tides_configure_astronomy