      SUBROUTINE LINILREV(YIN,XC,NX,Y,S,NN,DL,DR)
C 
C     * AUG 03/94 - J.KOSHYK

C     * BASED ON "LINIL" ROUTINE.
C     * PERFORMS LINEAR INTERPOLATION AT POINTS IN XC(NX) 
C     * OF THE VARIABLE CONTAINED IN Y(NN), KNOWN AT THE 
C     * NN COORDINATES CONTAINED IN S(NN).
C     * COORDINATES IN S MUST DECREASE TO THE RIGHT (IE 1 TO NN). 
C     * DL,DR ARE EXTRAPOLATION DERIVATIVES FOR LEFT,RIGHT SIDES. 
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      REAL YIN(NX),XC(NX) 
      REAL S(NN),Y(NN)
C-------------------------------------------------------------------- 
C     * LOOP OVER ALL POINTS TO BE INTERPOLATED.
C 
      DO 300 NV=1,NX
      X=XC(NV)
C 
C     * EXTRAPOLATE TO THE LEFT (X.GT.S(1)).
C 
      IF(X.LT.S(1)) GO TO 80
      VAL=Y(1)+DL*(X-S(1))
      GO TO 290 
C 
C     * EXTRAPOLATE TO THE RIGHT (X.LT.S(NN)).
C 
   80 IF(X.GT.S(NN)) GO TO 90 
      VAL=Y(NN)+DR*(X-S(NN))
      GO TO 290 
C 
C     * INTERPOLATION.
C     * FIRST FIND WHICH INTERVAL TO USE. 
C 
   90 CONTINUE
      DO 110 I=2,NN 
      K=I-1 
      IF(X.GT.S(I)) GO TO 120 
  110 CONTINUE
C 
C     * NOW PERFORM THE LINEAR INTERPOLATION. 
C 
  120 SLOPE=(Y(K+1)-Y(K))/(S(K+1)-S(K)) 
      VAL=Y(K)+SLOPE*(X-S(K)) 
  290 YIN(NV)=VAL 
  300 CONTINUE
C 
      RETURN
      END 
