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

readalex06.f

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

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

Variables on this page (11)

capalex06, captalex06, ialex06, numd, numt, numx, numz, r0gr06, tgr06, xxg06, zzg06

Purpose

Reads the low-temperature opacity tables of Ferguson et al. (2005, ApJ 623, 585), called the "Alexander 2006" tables in the code, for all compositions at once.

How it fits

  • Who calls it: SETUPOPAC, when LALEX06 is true.
  • Input: the formatted file FALEX06 (its name passed through SETUPOPAC since the change "MHP 8/25"), opened on unit IALEX06 from IOUNITS_MOD (set in PARMIN).
  • Outputs, through modules:
  • ALOT06ALL_MOD: CAPTALEX06(143, 85, 19), all tables, read by ALEX06TAB;
  • GALOT06_MOD: the grids TGR06 ($\log T$), XXG06 ($X$), R0GR06 ($\log R$), ZZG06 ($Z$), initialized in the module itself and read here (to check the tables) and by ALEX06TAB and GETALEX06;
  • ALOT06_MOD: the table for one composition, CAPALEX06(85, 19), initialized here to the first table ($X = 0$, $Z = 0$), and the composition and starting indices (XE, ZE, IX, IT, ID, initialized in the module). ALEX06TAB rebuilds it for the envelope's composition, and GETALEX06 interpolates in it.

The tables. From the header comments: $X$ = 0, 0.1, 0.2, 0.35, 0.5, 0.7, 0.8, 0.9 and $1-Z$; 16 values of $Z$ from 0 to 0.1; 85 values of $\log T$ from 2.7 to 4.5 (0.05 dex steps, 0.01 dex between 2.9 and 3.5); 19 values of $\log R$ from $-8$ to 1, with

$$R = \frac{\rho}{T_6^{\,3}} .$$

The tables at $X = 1-Z$ exist for 15 values of $Z$ only (none for $Z = 0.1$), so there are $8 \times 16 + 15 = 143$ compositions (NUMXZ), stored at index $(i_X - 1)\cdot 16 + i_Z$ (line 82↗; line 121↗).

The comment on the storage index is stale. Repeated in both loops (lines 58–61↗; lines 101–104↗), it speaks of "15 sets of metal abundance with 7 sets of hydrogen," while the code reads NUMZ = 16 values of $Z$ and NUMX = 9 of $X$ (lines 37–38↗), the ninth at $X = 1-Z$ with 15 tables, as above.

The method

For each composition, the routine reads the header ($X$, $Z$) and checks it against the grid; reads the $\log R$ row and checks it; then reads the 85 temperature rows in descending order of $T$, checking each $\log T$ against TGR06. A mismatch prints an error (to the terminal only) and stops the run with exit status 3, the code for input errors, except for the check of $X$ and $Z$ in the first loop, whose STOP is commented out (bug 1).

The check could cover all 19 densities. Both loops check R0GRTAB(KK) for KK = 1, 16 (lines 73–74↗; lines 114–115↗), not up to NUMD = 19, so the last three values of $\log R$ (0, 0.5, 1) are read but not checked. The table gives no reason for it: All 143 "log T" rows of input/opacity/molecular/alexmol06gs98.tab hold the same 19 values as R0GR06 (galot06_mod.f, lines 46–47↗), so a check to NUMD would pass (checked from the file, Nov 10, 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. (never occurred) A check that does not stop.

(lines 63–70↗) In the first loop (the eight values of $X$ below $1-Z$), the STOP after a mismatch of the header's $X$ or $Z$ is commented out (line 69), so the run goes on after printing "RUN STOPPED," and the table is stored under the composition the grid expects. In the second loop the same check stops the run (lines 106–112). What follows: A table file in another order or with other compositions is read without stopping, if its $\log R$ and $\log T$ rows match. Only with LALEX06 (off by default in the code; recommended by YREC's User Guide).

A possible fix:

readalex06.f

@@ lines 62–72 @@
 C HEADER INFORMATION: X AND Z; CHECK FOR CONSISTENCY
             READ(IALEX06,10)XX,ZZ
  10   FORMAT(30X,F9.6,7X,F9.6//)
+C 11/09/26 KC via Claude
+C code changed to stop on a mismatch of X or Z in the first loop too,
+C as the second loop does.
             IF(XX.NE.XXG06(I) .OR. ZZ.NE.ZZG06(II))THEN
                WRITE(*,15)XXG06(I),XX,ZZG06(II),ZZ
  15   FORMAT(1X,'ERROR IN ALEXANDER OPACITY TABLES:'/
      *       1X,'EXPECTED AND ACTUAL X,Z',4F7.2,' RUN STOPPED')
-C               STOP
+               STOP 3
             ENDIF
             READ(IALEX06,20)(R0GRTAB(K),K=1,NUMD)
  20   FORMAT(6X,19F7.3)

Checked by running YREC (Nov 9, 2026; a line added at each suspected path counted how often it was taken, the outputs otherwise unchanged): 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 (each one of YREC's cases with a few settings changed), of which one stopped in its first second. The check ran 128 times in each of the 33 others (one per table, $X$ = 0 to 0.9, $Z$ = 0 to 0.1), and never found a mismatch in alexmol06gs98.tab, the table every case reads. What would reach it: a table file in another order or with other compositions. The fix is a stop, so it was not run. Intent: The STOP was commented out with no reason given; the second loop's check stops.

2. (never occurred) No STATUS='OLD'.

(line 54↗) The file is opened without STATUS, so with a wrong name the OPEN creates an empty file of that name, and the run fails at the first READ (line 63), at the end of the file, with the compiler's message rather than one that names the missing table.

A possible fix:

readalex06.f

@@ lines 51–57 @@
       REAL*8 R0GRTAB(NUMD),XX,ZZ,T
 C INITIALIZE INDEX OF PREVIOUS CLOSEST POINTS AND ENVELOPE ABUNDANCES
       SAVE
-      OPEN(UNIT=IALEX06,FILE=FALEX06)
+C 11/09/26 KC via Claude
+C code changed to open the table with STATUS='OLD', so that a wrong
+C file name stops the run at the OPEN.
+      OPEN(UNIT=IALEX06,FILE=FALEX06,STATUS='OLD')
 C READ IN INITIAL X AND Z; ENSURE THAT THEY HAVE THE EXPECTED VALUES.
       DO I = 1,NUMX-1
          DO II = 1, NUMZ

Checked by running YREC (Nov 9, 2026; a line added at each suspected path counted how often it was taken, the outputs otherwise unchanged): The OPEN ran once in each of the 33 runs, and the file always existed. What would reach it: a wrong FALEX06. The fix is a stop, so it was not run. Intent: none found.

Definitions

subroutineREADALEX06

lines 18–141 · GitHub

Uses modules ALOT06ALL_MOD, ALOT06_MOD, GALOT06_MOD, IOUNITS_MOD

Called by SETUPOPAC

Compiler warnings (8)

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

  • line 65: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 65: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 74: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 88: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 108: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 108: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 115: Inequality comparison for REAL(8) [-Wcompare-reals]
  • line 126: Inequality comparison for REAL(8) [-Wcompare-reals]

Change log

The changes since rp_1

Changed since rp_1. Declarations only: COMMON blocks to modules, IMPLICIT NONE; the grids' and the starting indices' DATA statements moved into the modules (GALOT06_MOD, ALOT06_MOD), with the same values.

Changed since a8a5950. The stops on a mismatch exit with status 3, the code for input errors, instead of a bare STOP (exit status 0) (KNOWN_ISSUES.md, issue 38). The commented-out stop of bug 1 is unchanged.