!+ Subroutine to return the complex refractive -1.
!
! Method:
!	The real and imaginary parts of the refractive -1 are
!	represented as cubic splines.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      FUNCTION REFRACTIVE_INDEX(IERR, WAVELENGTH_POINT, N_REFRACT
     &   , WAVELENGTH
     &   , RE_REFRACT, IM_REFRACT, D2_RE_REFRACT, D2_IM_REFRACT)
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADERS.
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/error.pcf'
!
!     DUMMY ARGUMENTS
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
      INTEGER	!, INTENT(IN)
     &     N_REFRACT
!             NUMBER OF WAVELENGTHS
      COMPLEX*16	!, INTENT(OUT)
     &     REFRACTIVE_INDEX
!             VALUE OF REFRACTIVE INDEX
      REAL*8	!, INTENT(IN)
     &     WAVELENGTH_POINT
!             EVALUATION POINT
     &   , WAVELENGTH(NPD_REFRACT)
!             ARRAY OF WAVELENGTHS
     &   , RE_REFRACT(NPD_REFRACT)
!             REAL PARTS OF INDEX
     &   , IM_REFRACT(NPD_REFRACT)
!             IMAGINARY PARTS OF INDEX
     &   , D2_RE_REFRACT(NPD_REFRACT)
!             REAL SECOND DERIVATIVE
     &   , D2_IM_REFRACT(NPD_REFRACT)
!             IMAGINARY SECOND DERIVATIVE
!
!     LOCAL VARIABLES
      REAL*8
     &     RE_REFRACT_INDEX
!             INTERPOLATED REAL PART
     &   , IM_REFRACT_INDEX
!             INTERPOLATED IMAGINARY PART
!
!     SUBROUTINES CALLED:
      EXTERNAL
     &     SPLINE_EVALUATE
!
!
!
      CALL SPLINE_EVALUATE(IERR, N_REFRACT, WAVELENGTH, RE_REFRACT
     &   , D2_RE_REFRACT, WAVELENGTH_POINT, RE_REFRACT_INDEX)
      IF (IERR.NE.I_NORMAL) THEN
         IF (IERR.EQ.I_ERR_RANGE) THEN
            WRITE(IU_ERR, '(/A, 1PE12.5, A, /A)')
     &         '+++ WARNING: WAVELENGTH ', WAVELENGTH, ' m IS '
     &         //'OUTSIDE THE RANGE OF REFRACTIVE INDICES.'
     &         , 'A VALUE OF 1.0 WILL BE ASSUMED.'
            RE_REFRACT_INDEX=1.0D+00
            IERR=I_NORMAL
         ELSE
            IERR=I_ERR_FATAL
            RETURN
         ENDIF
      ENDIF
!
      CALL SPLINE_EVALUATE(IERR, N_REFRACT, WAVELENGTH, IM_REFRACT
     &   , D2_IM_REFRACT, WAVELENGTH_POINT, IM_REFRACT_INDEX)
      IF (IERR.NE.I_NORMAL) THEN
         IF (IERR.EQ.I_ERR_RANGE) THEN
            IM_REFRACT_INDEX=0.0D+00
            IERR=I_NORMAL
         ELSE
            IERR=I_ERR_FATAL
            RETURN
         ENDIF
      ENDIF
      REFRACTIVE_INDEX=DCMPLX(RE_REFRACT_INDEX, IM_REFRACT_INDEX)
!
!
      RETURN
      END
