      real*8 FUNCTION rfinteq1d(x,fa,x1,deltax,nmax)

C
C FUNCTIONAL DESCRIPTION:
C
C    Linear interpolation of f(x) on an equally spaced 1d x grid.
C    This is a pretty fast routine, but it could be made slightly
C    faster by precomputing an array of deltaf's.
C
C    Linear extrapolation is used for values of x less than x1 or
C    greater than xN=x1+(nmax-1)*deltax.  If no extrapolation is
C    desired, you should add points to either end to force the
C    extrapolation to be zero.
C
C    Written by Greg Hammett, 2-Sep-1988, for use in FPP.
C
C SUBROUTINE ARGUMENTS:
C
C    x	  find the value of f(x) at this value of x (input).
C    fa	  array of values of f(i) at x(i) (input).
C	    x(i) = x1 + (i-1) * deltax
C
C    x1	  (input) first value of x.
C    deltax (input) spacing between x values.
C    nmax length of f and delta f arrays.
C
C IMPLICIT INPUTS:
C
C    none
C
C IMPLICIT OUTPUTS:
C
C    none
C
C FUNCTION VALUE:
C
C    Interpolated value of f at x
C
C SIDE EFFECTS:
C
C    none
C
C

C============
C idecl:  explicitize implicit INTEGER declarations:
!
      IMPLICIT NONE
      REAL*8, PARAMETER :: ONE = 1.0d0
!
      INTEGER nmax,n
C============
C idecl:  explicitize implicit REAL declarations:
      REAL*8 x1,deltax,x,zn,wgt
C============
      REAL*8 fa(nmax)

      zn=ONE+(x-x1)/deltax
      n=zn

      if(n .lt. 1)then
          n=1
      endif
      if(n .ge. nmax)then
          n=nmax-1
      endif

      wgt=zn-n
      rfinteq1d=fa(n)+(fa(n+1)-fa(n))*wgt

      return
      END
! 11May2001 fgtok -s r8_precision.sub "r8con.csh conversion"
! 11May2001 fgtok
