%N spline %F $MIR/src/subs/spline.for
%D Setup for cubic spline interpolation
%P pjt
%: interpolation
%B
      subroutine spline (n, x, y, b, c, d)
      implicit none
      integer n
      double precision x(n), y(n), b(n), c(n), d(n)

  The coefficients b(i), c(i), and d(i), i=1,2,...,n are computed
  for a cubic interpolating spline

    s(x) = y(i) + b(i)*(x-x(i)) + c(i)*(x-x(i))**2 + d(i)*(x-x(i))**3

    for  x(i) .le. x .le. x(i+1)

  input..

    n = the number of data points or knots (n.ge.2)
    x = the abscissas of the knots in strictly increasing order
    y = the ordinates of the knots

  output..

    b, c, d  = arrays of spline coefficients as defined above.

  using  p  to denote differentiation,

    y(i) = s(x(i))
    b(i) = sp(x(i))
    c(i) = spp(x(i))/2
    d(i) = sppp(x(i))/6  (derivative from the right)

  the accompanying function subprogram  ``seval''  can be used
  to evaluate the spline.

  Origin: spline routines from Forsyth et al. (see netlib - 1992)
