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

spline.f

148 lines · 1 definitions · on GitHub (7be4133)

Python version: spline.py, 74 lines, on the right (switch to Python above the code).

Purpose

SPLINE evaluates a shape-preserving quadratic spline at one point, in one interval of the table. Its header credits the method to D. F. McAllister and J. A. Roulier, coded by S. L. Dodd and M. Roulier (N.C. State University). The knots and parameters of the spline in the interval are computed beforehand.

How it fits

  • Who calls it: only MEVAL, which controls the evaluation of the osculatory quadratic spline and computes the knots and parameters (through CHOOSE, by MEVAL's comments).
  • COMMON blocks: none; a function of its arguments only.

The method

In the interval $[x_0, x_1]$ (XTABS, XTABS1), with values $f_0, f_1$ (YTABS, YTABS1), the spline is made of quadratic pieces joined at one knot $z_1$ (Z1; cases 1–3) or two knots $\xi_1 < z_1$ (Y1, Z1; case 4, NCASE = 4). Each piece is a quadratic Bézier form; for example, for $x$ between $z_1$ and $x_1$:

$$s(x) = \frac{z_2\,(x_1 - x)^2 + 2 w_2\,(x - z_1)(x_1 - x) + f_1\,(x - z_1)^2}{(x_1 - z_1)^2},$$

where $z_2$ (Z2) is the value at the knot and $w_2$ (W2) the middle control value. For $x$ between $x_0$ and the knot, V2 plays the role of W2; between the two knots of case 4, E2 does, with Y2 the value at the first knot.

Design

Where a denominator would vanish (a knot at an end of the interval), linear interpolation between the interval's ends is used instead: "MODIFICATION DUE TO MARC PINSONNEAULT 6/87." Each fallback is reached only when XVALS lies outside [XTABS, XTABS1] (with the knot at XTABS1, only for XVALS > XTABS1, lines 66–73↗ and lines 139–146↗; with the knot at XTABS, only for XVALS < XTABS, lines 79–86↗ and lines 102–109↗), and the one between the two knots of case 4 (lines 126–133↗) never, since it needs Y1 < XVALS < Z1 with Z1 = Y1. MEVAL passes such points only when it extrapolates beyond the table's ends (meval.f, line 135↗, meval.f, line 259↗): The fallback is then a linear extrapolation of the end interval (settled from the code, Nov 9, 2026).

Definitions

functionSPLINE

lines 1–148 · GitHub

The value of a shape-preserving quadratic spline at XVALS, from one or two knots in the interval (equation above).

Called by MEVAL ×3

Compiler warnings (8)

gfortran -Wall -Wextra, compiling only; nothing was run.

  • line 60: Equality comparison for REAL(8) [-Wcompare-reals]
  • line 67: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 80: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 96: Equality comparison for REAL(8) [-Wcompare-reals]
  • line 103: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 120: Equality comparison for REAL(8) [-Wcompare-reals]
  • line 127: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 140: Inequality comparison for REAL(8) [-Wcompare-reals]

Change log

The changes since rp_1

Changed since rp_1. Declarations only: IMPLICIT NONE.