c $Header: /usr/people/flittner/radtran/tomrad/pv2.2/src/RCS/findex.f,v 2.22 2000/08/30 16:38:09 flittner Exp $ subroutine findex(xa,n,x,klo,khi) c c given an array of values in order, find the index of the 2 pts that stradle x c c last modified: August 5, 1997...def c purpose: add tollerance for comparisons. This is in the const.inc file. c implicit none c the rcs revision # character*20 rcsrev parameter (rcsrev='$Revision: 2.22 $') c include 'consts.cmn' integer n,klo,khi,k real*8 xa(n),x c c check to see if the data is increasing in the independent variable c or decreasing c klo = 1 khi = n if(xa(khi).gt.xa(klo))then if(x-xa(1).lt.smallx)then klo=1 khi=2 return else if(xa(n)-x.lt.smallx)then klo=n-1 khi=n return endif 10 continue if (khi-klo .gt. 1) then k = (khi+klo)/2 if (abs(x-xa(k)).lt.smallx) then klo = k khi = klo+1 return else if (x-xa(k).lt.smallx) then khi = k else klo = k endif goto 10 endif else if(x-xa(n).lt.smallx)then klo=n-1 khi=n return else if(xa(1)-x.lt.smallx)then klo=1 khi=2 return endif 15 continue if (khi-klo.gt. 1) then k = (khi+klo)/2 if (abs(x-xa(k)).lt.smallx) then klo = k khi = klo+1 return else if (x-xa(k).lt.smallx) then klo = k else khi = k endif goto 15 endif endif return end