c_ --------------------------------------------------------------------- c_ RCS lines preceded by "c_ " c_ --------------------------------------------------------------------- c_ c_ $Source: /home/orr/WWW/Abiotic/boundcond/RCS/locate.f,v $ c_ $Revision: 1.1 $ c_ $Date: 1999/04/26 13:52:31 $ ; $State: Exp $ c_ $Author: orr $ ; $Locker: $ c_ c_ --------------------------------------------------------------------- c_ $Log: locate.f,v $ c_ Revision 1.1 1999/04/26 13:52:31 orr c_ Initial revision c_ c_ --------------------------------------------------------------------- c_ SUBROUTINE locate(xx,n,x,j) c From Numerical recipes: c ----------------------- c Given an array XX of length N, and a given value of X, returns a c value of J such that X is between XX(J) and XX(J+1). XX must be c monotonic, either increasing or decreasing. J=0 or J=N is c returned to indicate that X is out of range. DIMENSION xx(n) jl=0 ju=n+1 10 IF(ju-jl.gt.1)THEN jm=(ju+jl)/2 IF((xx(n).gt.xx(1)).eqv.(x.gt.xx(jm)))THEN jl=jm ELSE ju=jm ENDIF go to 10 ENDIF j=jl RETURN END