splint.f
56 lines · 1 definitions · on GitHub (7be4133)
Python version: splint.py, 46 lines, on the right (switch to Python above the code).
Variables on this page (1)
Purpose
SPLINT evaluates a cubic spline at one point $x$, from the table $(x_i, y_i)$ and the second derivatives $y''_i$ computed beforehand: by SPLINJ, or, for the opacity routine GTPURZ, by CSPLINE (computed there, or tabulated by ZSULAOL). The comments say it is taken from Numerical Recipes (Press et al., p. 89) and was changed from REAL*4, for the opacities, to REAL*8 (MHP, 10/02).
The header's "OUTPUT OF SPLINE ABOVE" (lines 7–10↗) is Numerical Recipes' text: Its spline (with end slopes) is CSPLINE here, while spline.f is an unrelated quadratic spline. The second derivatives come from SPLINJ in BOOLE and CALCAD (boole.f, lines 48–51↗; calcad.f, lines 347–348↗) and from CSPLINE in GTPURZ, directly (gtpurz.f, lines 115–116↗) and through the ZSDORL that ZSULAOL stores (gtpurz.f, lines 78–82↗; zsulaol.f, lines 40–44↗).
How it fits
The method
A bisection finds $x_\mathrm{lo} \le x < x_\mathrm{hi}$ (KLO, KHI). With $h = x_\mathrm{hi} - x_\mathrm{lo}$, $A = (x_\mathrm{hi} - x)/h$ and $B = 1 - A$:
$$y = A\,y_\mathrm{lo} + B\,y_\mathrm{hi} + \frac{h^2}{6}\left[(A^3 - A)\,y''_\mathrm{lo} + (B^3 - B)\,y''_\mathrm{hi}\right].$$
If two abscissas coincide ($h = 0$) it writes an error, with the abscissa and $x$, to the terminal and to ISHORT, and stops the run (STOP 1). Outside the table it extrapolates the end interval's cubic, without a warning.
Design
KLO and KHI are arguments but are reset on entry, so a caller's previous bracket is not used as a starting guess.
Definitions
subroutineSPLINT
Cubic-spline interpolation at one point (equation above), with arrays sized N; stops the run when two table abscissas coincide.
Uses modules IOUNITS_MOD
Called by BOOLE, CALCAD ×2, GTPURZ ×2
Compiler warnings (1)
gfortran -Wall -Wextra, compiling only; nothing was run.
- line 42: Equality comparison for REAL(8) [-Wcompare-reals]
Change log
The changes since rp_1
Changed since rp_1. Declarations only: /LUOUT/ to IOUNITS_MOD, IMPLICIT NONE; two callers, GTLAOL and GTLAOL2, were removed with their files.
Changed since a8a5950. The stop on two equal abscissas now gives the abscissa and $x$ in its message, writes it to the terminal as well as the .short file, and exits with status 1, the code for run-time errors, instead of a bare STOP (KNOWN_ISSUES.md, issue 38).