module nbspline_mod

  use iso_c_binding, only: fp => c_double
  use physconst_mod, only: thmin=>zero,thmax=>twopi
  !  module to hold single precision r(theta,xi) z(theta,xi)
  !  splines -- interior and exterior regions
  !  setup routine:  nbspline.f90
  !  evaluation routine:  nbmomry.f90

  implicit none
  private :: fp
  save
  integer nxi,nth
  real(fp), dimension(:), allocatable :: xi   ! radial coordinate
  real(fp), dimension(:), allocatable :: th   ! poloidal coordinate

  !  (array dimensioning added to pass lf95 argument checks w/vectorized
  !  spline routines)

  real(fp) hxi(1),hxii(1),hth(1),hthi(1),xspani,thspani   ! spacing parameters
  integer :: nbsii(1),nbsjj(1)

  integer nbrk                 ! index xi(nbrk) ~ bdy
  real(fp) xi_brk                  ! bdy xi value

  ! it is assumed that one of the xi values will be at the boundary

  integer nint                 ! no. of points inside bdy, counting bdy
  integer next                 ! no. of points outside bdy, counting bdy

  ! spline data arrays: (r,z) internal & external

  real(fp), dimension(:,:,:), allocatable :: rspl,rsplx,zspl,zsplx

  ! spline data arrays: (1/b) and [j] with analytic continuation

  real(fp), dimension(:,:,:), allocatable :: bspl,jspl

  ! even spacing flags

  integer klinx,klinth,klinxx,klinthx


end module nbspline_mod
