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

bandw.f

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

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

Purpose

This file solves a banded linear system $A\,\mathbf{x} = \mathbf{b}$ by Gaussian elimination without pivoting. It is the solver for the implicit angular-momentum transport in DADCOEFT (its comments speak of $\Omega$ and its radial derivatives).

How it fits

  • Inputs: the arguments A(NMAX,10) (the band), NM (the number of unknowns) and B (the right-hand side).
  • Who calls it: only DADCOEFT.
  • Output: the solution, returned in B; A is overwritten.
  • No COMMON blocks.

Storage. Row $i$ of the matrix is stored in A(i,1:10), with the diagonal in column 5: A(i,5+k) is the coefficient of unknown $x_{i+k}$, for $k = -4, \dots, 5$. The band thus has 4 subdiagonals and 5 superdiagonals. A is declared A(NMAX,10) with NMAX = 8000 (line 9↗; line 12↗), and DADCOEFT declares the same (dadcoeft.f, line 39↗; dadcoeft.f, line 92↗); the two must agree, since the first dimension sets where each column starts. KNOWN_ISSUES.md (lines 1845–1848) keeps NMAX per routine on purpose.

The method

  1. Forward elimination, row by row: divide row $i$ and $b_i$ by the pivot $a_{ii}$, then remove $x_i$ from the next 4 rows, $$a_{jk} \leftarrow a_{jk} - a_{ji}\,a_{ik}, \qquad b_j \leftarrow b_j - a_{ji}\,b_i, \qquad j = i+1, \dots, i+4.$$ The last 4 rows are handled separately, since their bands are cut off by the end of the matrix. A pivot smaller than $10^{-20}$ in absolute value stops the run (STOP 999), after printing the row (for the last row it stops without printing).

  2. Back substitution: with unit diagonal, for $i = N, \dots, 2$, $$b_{i-l} \leftarrow b_{i-l} - b_i\,a_{i-l,\,i}, \qquad l = 1, \dots, \min(5, i-1).$$

Design

No pivoting: the method relies on the matrix being diagonally dominant enough.

About 100 lines of an earlier version (blocks of 4 rows per shell, "DIAGONALIZE OMEGA(II) TERM") remain as comments.

Definitions

subroutineBANDW

lines 3–186 · GitHub

Gaussian elimination without pivoting for a band matrix with 4 subdiagonals and 5 superdiagonals (diagonal in column 5 of A); the solution replaces B.

Called by DADCOEFT

Change log

The changes since rp_1

Changed since rp_1. Declarations only: IMPLICIT NONE, and the unused JSON parameter removed, which settled half of a former question on the dimensions (the other half is now in Storage, above).