ccc-----------------------------------------------/rfintrp
ccc	linear interpolation
ccc
      real*8 function rfintrp(x,fa,xa,n)
c
c returns rfintrp= f(x)
c fa(i) = f(xa(i))	set of n known values of x and f(x).
c xa	is assumed to be ordered from smallest to largest
c
c if the xa array is equally spaced, then the faster finteq1d routine
c can be used.  Note that this routine does zero extrapolation beyond
c the endpoints of xa, while finteq1d does do extrapolation...
c
C============
C idecl:  explicitize implicit INTEGER declarations:
      IMPLICIT NONE
      INTEGER n,j,lkupr_r8
C============
C idecl:  explicitize implicit REAL declarations:
      REAL*8 x
C============
      REAL*8 fa(n),xa(n)
 
20    j=lkupr_r8(x,xa,n)+1
 
      if(j .eq. 1) then
          rfintrp=fa(1)    !default for x<xa(1)
          return
      endif
 
      if(j .gt. n)then
          rfintrp=fa(n)    !default for x>xa(n)
          return
      endif
 
50    rfintrp=( fa(j-1)*(xa(j)-x) + fa(j)*(x-xa(j-1)) )
     1	 / (xa(j)-xa(j-1))
 
      return
      end
