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

C     * BASED ON "LGRIC" ROUTINE.
C     * PERFORMS LAGRANGIAN 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     * DEN(4,NN-3) CONTAINS THE INVERTED DENOMINATORS (SEE LGRDC). 
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 DEN(4,1),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.GT.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 CUBIC TO USE.
C     * NC IS ALSO THE LEFT POINT OF THE 4 THAT SURROUND X. 
C 
   90 CONTINUE
      DO 110 I=2,NN 
      K=I 
      IF(X.GT.S(I)) GO TO 120 
  110 CONTINUE
  120 NC=K-2
      IF(K.EQ. 2) NC=1
      IF(K.EQ.NN) NC=NC-1 
C 
C     * NOW EVALUATE THE LAGRANGIAN POLYNOMIAL AT POINT X.
C 
      X1=X-S(NC)
      X2=X-S(NC+1)
      X3=X-S(NC+2)
      X4=X-S(NC+3)
      VAL = X2*(X3*X4)*DEN(1,NC)*Y(NC)
     1     +X1*(X3*X4)*DEN(2,NC)*Y(NC+1)
     1     +(X1*X2)*X4*DEN(3,NC)*Y(NC+2)
     1     +(X1*X2)*X3*DEN(4,NC)*Y(NC+3)
  290 YIN(NV)=VAL 
  300 CONTINUE
C 
      RETURN
      END 
