C+ C NAME: C nrSplInt C PURPOSE: C Calculate fnc-value in X using cubic spline interpolation C CATEGORY: C Math: interpolation and extrapolation C CALLING SEQUENCE: subroutine nrSplInt(N,XA,YA,Y2A,X,Y) C INPUTS: C N integer # points C XA(N) real x-coordinates C YA(N) real fnc-values C Y2A(N) real 2nd derivatives C (output from subroutine nrSpline) C X real x-coordinate where fnc-value is required C OUTPUTS: C Y real interpolated fnc-value in point X C CALLS: C Say C PROCEDURE: C See Numerical Recipes, par. 3.4, p. 89 C MODIFICATION HISTORY: C JUN-1993, Paul Hick (UCSD) C- integer N real XA (N) real YA (N) real Y2A(N) real X real Y KLO = 1 KHI = N do while (KHI-KLO .gt. 1) K = (KHI+KLO)/2 if (XA(K) .gt. X) then KHI = K else KLO = K end if end do H = XA(KHI)-XA(KLO) if (H .eq. 0) call Say('nrSplInt','E','Stop','Identical elements in array XA') A = (XA(KHI)-X)/H B = (X-XA(KLO))/H Y = A*YA(KLO)+B*YA(KHI)+((A**3-A)*Y2A(KLO)+(B**3-B)*Y2A(KHI))*(H*H)/6. return end