ccc-----------------------------------------------/fpintrp
ccc	linear interpolation
ccc
      real function fpintrp_r4(x,fa,xa,n)
c
c returns fpintrp= 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============
      IMPLICIT NONE
      INTEGER n,j,lkupr
      REAL x
      REAL fa(n),xa(n)
 
20    j=lkupr(x,xa,n)+1
 
      if(j .eq. 1) then
          fpintrp_r4=fa(1)    !default for x<xa(1)
          return
      endif
 
      if(j .gt. n)then
          fpintrp_r4=fa(n)    !default for x>xa(n)
          return
      endif
 
50    fpintrp_r4=( fa(j-1)*(xa(j)-x) + fa(j)*(x-xa(j-1)) )
     1	 / (xa(j)-xa(j-1))
 
      return
      end
