locate.f
37 lines · 1 definitions · on GitHub (7be4133)
Python version: locate.py, 52 lines, on the right (switch to Python above the code).
Purpose
LOCATE finds, by bisection, the index $j$ such that $x$ lies between XX(j) and XX(j+1) in a monotonic array (ascending or descending), as in Numerical Recipes. $j = 0$ or $N$ means out of range.
How it fits
Called by the Livermore-table routine GTPURZ (GTLAOL and GTLAOL2 also called it; removed since rp_1) and by ALSURFP (Allard atmospheres). No COMMON blocks, no calls.
The method
Standard bisection. Then two tolerances are added: if $j = 0$ but $x > 0.99\,\texttt{XX(1)}$, it returns $j = 1$; if $j = N$ but $x < 1.01\,\texttt{XX(N)}$, it returns $N-1$.
Definitions
subroutineLOCATE
Bisection search with 1 % end tolerances (above).
Change log
The changes since rp_1
Changed since rp_1. Declarations only: IMPLICIT NONE with explicit declarations. Two of its callers (GTLAOL, GTLAOL2) are removed since rp_1.