PyREC scaffolding (from YREC development, 7be4133)/ locate.fGlossary

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

lines 9–37 · GitHub

Bisection search with 1 % end tolerances (above).

Called by ALSURFP ×2, GTPURZ

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.