      SUBROUTINE SCOMP (X,Y,A,B,C,N,XI,YI,NI,IERR)
C
C     ABSTRACT
C
C         SCOMP EVALUATES A CUBIC SPLINE AT THE ABSCISSAS IN XI.
C         IT IS ASSUMED THAT THE COEFFICIENTS OF THE POLYNOMIALS
C         WHICH FORM THE SPLINE ARE PROVIDED.
C
C     DESCRIPTION OF ARGUMENTS
C         THE USER MUST DIMENSION ALL ARRAYS APPEARING IN THE CALL LIST,
C         E.G.  X(N), Y(N), A(N), B(N), C(N), XI(NI), YI(NI)
C
C       --INPUT--
C
C         X   - ARRAY OF THE FIRST N ABSCISSAS (IN INCREASING ORDER)
C               THAT DEFINE THE SPLINE.
C         Y   - ARRAY OF THE FIRST N ORDINATES THAT DEFINE THE SPLINE.
C         A,B,C ARRAYS THAT CONTAIN THE COEFFICIENTS OF THE POLYNOMIALS
C               WHICH FORM THE SPLINE. IF I = 1,...,N  THEN THE SPLINE
C               HAS THE VALUE
C                    Y(I) + A(I)*DX + B(I)*DX**2 + C(I)*DX**3
C               FOR X(I) .LE. XX .LE. X(I+1).  HERE DX = XX-X(I).
C         N   - THE NUMBER OF POLYNOMIALS THAT DEFINE THE SPLINE.
C               THE ARRAYS X, Y, A, B, C  MUST BE DIMENSIONED AT
C               LEAST N.  N MUST BE GREATER THAN OR EQUAL TO 1.
C         XI  - THE ABSCISSA OR ARRAY OF ABSCISSAS (IN ARBITRARY ORDER)
C               AT WHICH THE SPLINE IS TO BE EVALUATED.
C         NI  - THE NUMBER OF ABSCISSAS AT WHICH THE SPLINE IS TO BE
C               EVALUATED.  IF NI IS GREATER THAN 1 THEN XI AND YI
C               MUST BE ARRAYS OF DIMENSION NI OR LARGER.
C               IT IS ASSUMED THAT NI IS GREATER THAN OR EQUAL TO 1.
C
C       --OUTPUT--
C
C         YI  - ARRAY OF VALUES OF THE SPLINE (ORDINATES) AT XI.
C         IERR- STATUS CODE
C               0  THE SPLINE WAS EVALUATED AT EACH ABSCISSA IN XI.
C               1  INPUT ERROR - NI IS NOT POSITIVE.
C
      DIMENSION X(N),Y(N),A(N),B(N),C(N),XI(NI),YI(NI)
C
C     CHECK INPUT
C
      IF (NI) 1,1,2
    1 IERR = 1
      RETURN
    2 IERR = 0
C
C     K IS INDEX ON VALUE OF XI BEING WORKED ON.  XX IS THAT VALUE.
C     I IS CURRENT INDEX INTO X ARRAY.
C
      K  = 1
      XX = XI(1)
      IF (XX.LT.X(1)) GO TO 90
      IF (XX.GE.X(N)) GO TO 80
      IL = 1
      IR = N
C
C     BISECTION SEARCH
C
   10 I  = (IL+IR)/2
      IF (I.EQ.IL) GO TO 100
      IF (XX-X(I)) 20,100,30
   20 IR = I
      GO TO 10
   30 IL = I
      GO TO 10
C
C     LINEAR FORWARD SEARCH
C
   50 IF (XX-X(I+1)) 100,60,60
   60 I  = I+1
      GO TO 50
C
C     XX IS GREATER THAN X(N) OR LESS THAN X(1)
C
   80 I  = N
      GO TO 100
   90 I  = 1
C
C     EVALUATION
C
  100 DX = XX - X(I)
      YI(K) = Y(I)+DX*(A(I)+DX*(B(I)+DX*C(I)))
C
C     NEXT POINT
C
      IF (K.GE.NI) RETURN
      K = K+1
      XX = XI(K)
      IF (XX.LT.X(1)) GO TO 90
      IF (XX.GE.X(N)) GO TO 80
      IF (XX-XI(K-1)) 110,100,50
  110 IL = 1
      IR = MIN0(I+1,N)
      GO TO 10
      END
