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

putyrec7.f

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

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

Variables on this page (2)

clsun, json

Purpose

Writes a stellar model in the older "YREC7" text format (LLP 4/16/03), which YREC can still read as a starting model. PUTMODEL2 writes the newer "MODEL2" format.

How it fits

  • Inputs: the model and its global quantities, as arguments (as for PUTMODEL2, without the physics labels). The comments "Last two lines are MODEL2 add-ons" (line 31↗) and "Any error messages go to LU ISHORT" (line 51↗) describe the argument list before ISHORT and the MODEL2 add-ons were removed from it (lines 9–10↗; lines 28–29↗).
  • Who calls it: no routine in src/ calls it. It is kept on purpose: KNOWN_ISSUES.md (issue 24, lines 1658–1666) records the developers' ruling to keep it, since its reader is live and the format may have legacy use, while fourteen other unreachable routines were removed (settled from YREC's public sources, Nov 9, 2026).
  • Who reads the format: STARIN recognizes the leading NMOD and calls GETYREC7.
  • Output: the file on unit IWRITE. The routine also changes two of the caller's arrays: TLUMX is converted to erg s⁻¹ in place when it is in solar units (lines 71–77↗), and OMEGA is floored at $10^{-59}$ (line 131↗).

The format. A header line NMOD (model number, shells, mass, $\log T_\mathrm{eff}$, $\log L$, $\log M$, age, step); a flags line (LROT, LEXCOM, JCORE, JENV, CMIXL); a TLUMX line (erg s⁻¹); three ENV lines; one line per shell ($\log m$, $\log r$, $L$, $\log P$, $\log T$, $\log\rho$, convection flag, and $X$ and $Z$ as integers in units of $10^{-6}$); the abundances 4–11 only from JCORE to JENV (each convection zone stores one composition); with LEXCOM, abundances 12–15 two shells per line; with LROT, $|\log_{10}\Omega|$, eight per line. For a fully convective star (JENV ≤ JCORE), two lines of abundances 4–11 are written, for JCORE and JENV (lines 102–104↗), although the comment says "write out 1 comp" (line 101↗); GETYREC7 reads two as well (getyrec7.f, lines 156–157↗), so only the comment is wrong (settled from the code, Nov 9, 2026).

Suspected bugs, checked by running the code

Each bug is marked by what running the code showed: (changes results, large) or (small), the fix moving a run clearly beyond a null change; (stops the run); (wrong output), the fix changing only what is written; (harmless in the runs), within the noise; (never occurred), the code ran but the fault did not; (not reached); (cannot be reached), a guard prevents it; (withdrawn), the suspicion was wrong.

1. (cannot be reached) The flags record does not match its reader.

(lines 65–66↗; getyrec7.f, lines 104–105↗) This routine writes the flags as 2(L1,1X),'F F ',2I4,F7.3, four characters between the flags and JCORE; GETYREC7 reads them as 2(L1,1X),5X,2I4,F7.3, skipping five, so every field it reads is shifted by one column. With Fortran's default treatment of blanks in input (ignored), the values still come back right while JENV < 1000 and CMIXL < 100; when JENV has four digits, its first digit is read as the last digit of JCORE, and JENV loses it. Only when a model written by PUTYREC7, which nothing in src/ calls, is read back.

A possible fix (in the writer, since GETYREC7 presumably matches the files YREC7 itself wrote):

putyrec7.f

@@ lines 63–69 @@

 C write PHYSICS FLAGS- ROTATION,EXTENDED COMP,CENTRAL AND SURFACE CZ'S
       WRITE(IWRITE,30)LROT,LEXCOM,JCORE,JENV,CMIXL
-   30 FORMAT(2(L1,1X),'F F ',2I4,F7.3)
+C 11/09/26 KC via Claude
+C code changed to write five characters between the flags and JCORE,
+C as GETYREC7 reads them.
+   30 FORMAT(2(L1,1X),'F F  ',2I4,F7.3)

 C write LUMINOSITIES
 C If TLUMX are in solar units, convert to ergs.  Decide by

Checked by running YREC (Nov 9, 2026; a line added at each suspected path counted how often it was taken, the outputs otherwise unchanged): not reached in any of 34 runs (26 of YREC's cases, from a 0.04 $M_\odot$ brown dwarf and the solar models to 9 $M_\odot$, rotation, and helium burning, and 8 made-up ones). Nothing in src/ calls PUTYREC7, so it cannot be reached at 7be4133; it is fragile code. Intent: KNOWN_ISSUES.md keeps the routine on purpose ("it may have legacy use even though nothing in the tree calls it") but says nothing of its format. Not run: a model written by PUTYREC7 and read back by GETYREC7, which needs a caller.

Definitions

subroutinePUTYREC7

lines 8–146 · GitHub

Uses modules CONSTANTS_MOD, DIMENSIONS_MOD

Change log

The changes since rp_1

Changed since rp_1. Declarations only: /CONST/ to CONSTANTS_MOD, JSON from DIMENSIONS_MOD, IMPLICIT NONE.