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

ludcmp.f

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

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

Purpose

LUDCMP replaces a square matrix by its LU decomposition with partial pivoting (Crout's method with implicit scaling), as Numerical Recipes' LUDCMP. LUBKSB then solves systems with it.

How it fits

Called only by THDIFF (the diffusion coefficients of Thoul et al., by its name). No COMMON blocks, no calls. Arguments: A(NP,NP) (overwritten by L and U), N, NP, the row permutation INDX, and D = ±1 (the parity of the row swaps).

The method

It first stores each row's scale, $1/\max_k |a_{ik}|$, and stops with STOP 'Singular matrix.' if a row is all zero. Then, for each column $j$ it computes the $U$ entries above the diagonal and the candidates below, picks the pivot with the largest scaled magnitude $|a_{ij}|/\max_k |a_{ik}|$, swaps rows, and divides the sub-diagonal entries by the pivot. A zero pivot is replaced by TINY = $10^{-20}$.

The scale vector VV has the fixed size NMAX = 100 (line 13↗; line 28↗), and N is not checked against it. THDIFF passes N = $2M + 2$ with its own arrays sized 42 (thdiff.f, lines 48–54↗; thdiff.f, line 72↗; thdiff.f, line 264↗), so N ≤ 42; KNOWN_ISSUES.md (lines 1845–1848) keeps NMAX per routine on purpose (settled from the code, Nov 9, 2026).

Definitions

subroutineLUDCMP

lines 2–97 · GitHub

LU decomposition with partial pivoting (Numerical Recipes).

Called by THDIFF

Compiler warnings (3)

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

  • line 40: Equality comparison for REAL(8) [-Wcompare-reals]
  • line 86: Equality comparison for REAL(8) [-Wcompare-reals]
  • line 94: Equality comparison for REAL(8) [-Wcompare-reals]

Change log

The changes since rp_1

Changed since rp_1. Declarations only: IMPLICIT NONE with explicit declarations.