C$TEST CSPQ
C TO RUN AS A MAIN PROGRAM REMOVE NEXT LINE
      SUBROUTINE CSPQ
C***********************************************************************
C
C  EXAMPLE OF USE OF THE PORT PROGRAM CSPFE
C
C***********************************************************************
       INTEGER I1MACH,J,IWRITE
      REAL X(9),Y(9),YP(9),YPP(9),BC(6),XX(4),YY(4),ERR(4),PI
C
      PI=4.0*ATAN(1.0)
C
C COMPUTE THE POINTS AT WHICH THE SPLINE IS TO BE FITTED
C
      DO 10 J=1,9
         X(J)=FLOAT(J-1)/8.0
   10    Y(J)=SIN(X(J)*PI/2.0)
C
C SET THE END CONDITIONS FOR THE INTERPOLATION
C (SPECIFY FIRST DERIVATIVE AT X=0, SECOND AT X=1)
C
      BC(1)=1.0
      BC(2)=0.0
      BC(3)=PI/2.0
      BC(4)=0.0
      BC(5)=1.0
      BC(6)=-X(9)*(PI/2.0)**2
C
C DO THE CUBIC SPLINE FIT
C
      CALL CSPFI(X,Y,9,BC,YP,YPP)
C
C SET THE POINTS AT WHICH TO INTERPOLATE
C
      XX(1)=0.1
      XX(2)=0.3
      XX(3)=0.6
      XX(4)=0.9
C
C DO THE INTERPOLATION
C
      CALL CSPFE(X,Y,YP,YPP,9,XX,YY,4)
C
C COMPUTE THE INTERPOLATION ERROR
C
      DO 20 K=1,4
   20    ERR(K)=YY(K)-SIN(XX(K)*PI/2.0)
C
C SET THE OUTPUT UNIT
C
      IWRITE=I1MACH(2)
C
      WRITE(IWRITE,9997)
 9997    FORMAT(2X,2HXX,10X,13HINTERPOLATION)
      WRITE(IWRITE,9998)
 9998    FORMAT(12X,5HVALUE,6X,5HERROR//)
C
      WRITE(IWRITE,9999) (XX(K),YY(K),ERR(K),K=1,4)
 9999    FORMAT(0PF6.3,0PF12.6,1PE12.3/)
C
      STOP
      END
