      SUBROUTINE RFACIN(DEP,SVP,GRAD,FINT,NP,MX)
C
C     THIS SUBROUTINE GENERATES THE COEFFICIENTS GRAD AND FINT 
C     IN A PIECEWISE LINEAR REPRESENTATION OF THE SQUARE OF THE 
C     INDEX OF REFRACTION.
C
C     N(Z)**2 = GRAD(I)*Z + FINT(I), I=1,NP
C
      IMPLICIT REAL*8 (A-H,O-Z)
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
      DIMENSION DEP(MX),SVP(MX),GRAD(MX),FINT(MX)
C
      NPM1=NP-1
      DO 100 I=1,NPM1
C
      IF(SVP(I) .NE. SVP(I+1)) THEN
      THICK=DEP(I+1)-DEP(I)
      DNS=(CB/SVP(I+1))**2-(CB/SVP(I))**2
      GRAD(I)=DNS/THICK
      ELSE
      GRAD(I)=0.0E0
      END IF
C
      FINT(I)=(CB/SVP(I))**2-GRAD(I)*DEP(I)
  100 CONTINUE
C
C     THE GRADIENT IN THE LAST LAYER (NPM1) WILL BE USED TO 
C     EXTRAPOLATE VALUES BELOW THE LAST POINT ON THE PROFILE
C
      GRAD(NP)=GRAD(NPM1)
      FINT(NP)=(CB/SVP(NP))**2-GRAD(NP)*DEP(NP)
C
      RETURN
      END
