pdist.f
125 lines · 1 definitions · on GitHub (7be4133)
Python version: pdist.py, 91 lines, on the right (switch to Python above the code).
Purpose
Decides when to write a model for pulsation calculations: it "calculates the distance the star has travelled in the HR diagram; if far enough, output pulsation model." When the accumulated distance passes a threshold, it opens three new output files named after the run and the model number, and sets LPULSE so that the output routines write the model to them.
How it fits
- Inputs: the previous point (
POL1$=\log L$,POT1$=\log T_\mathrm{eff}$,POA1= age) and the running totalPOLEN; the currentBL($\log L/L_\odot$),TEFFL,MODELN, the run indexNKand the ageDAGE(arguments); the weightsPOA,POB,POCand the thresholdPOMAXin NMLPAR_MOD (namelistCONTROL, read by PARMIN); the base file namesFPMOD,FPENV,FPATM(arguments, since MHP 8/25). - Who calls it: the main program in main.f, after each model when
LPOUTis set. -
Outputs:
POLENand the previous point updated;LPULSEinNMLPAR_MOD; the unitsIOPMOD,IOPENV,IOPATM(from IOUNITS_MOD) opened as<FPMOD>NN_MMMMand so on, withNN=NK(the main program's loop over runs,DO 200 NK = 1, NUMRUN) andMMMMthe model number; a line toIOWRandISHORT. WhileLPULSEis true, WRTMOD writes the model toIOPMODand passesLPULPTon to ENVINT, which writes the atmosphere and envelope toIOPATMandIOPENVfrom the points QATM and QENV store.
The method
The squared step in the HR diagram and in age, with weights $a, b, c$, is accumulated:
$$\ell^2 \mathrel{+}= (a\,\Delta\log L)^2 + (b\,\Delta\log T_\mathrm{eff})^2 + (c\,\Delta t)^2 .$$
When $\ell^2 \ge$ POMAX, the files are opened and $\ell^2$ is reset to zero; otherwise the three units are closed and LPULSE is set false.
POMAX bounds a squared distance. POLEN adds the squares of the weighted steps, $(\mathtt{POA}\,\Delta\log L)^2 + (\mathtt{POB}\,\Delta\log T_\mathrm{eff})^2 + (\mathtt{POC}\,\Delta\mathrm{age})^2$ (lines 76–79↗; printed as "LEN SQ"), and is compared with POMAX (line 83↗), so the default POMAX = 0.1 means a distance of about 0.32. YREC's documentation describes none of POMAX, POA, POB, and POC; it could say that the threshold is a squared distance.
From YREC's documentation
Control Options (Output): LPULSE writes pulsation output, to FPMOD (the interior), FPENV (the envelope) and FPATM (the atmosphere), and needs LSTATM and LSTENV for the outer two; IPVER chooses its format.
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. (not reached) Two different lines under the same labels.
(lines 119–122↗) The same format writes the step's differences (TM1–TM3) to IOWR but their weighted squares (TMP1–TMP3) to ISHORT, under the same labels "D L," "D Te," "D AGE," so the two files disagree and the ISHORT line is mislabeled. Only with LPOUT (off by default).
A possible fix: a choice for the developers: write the same quantities to both units, or give the weighted squares their own labels.
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. PDIST runs only with LPOUT on; its default is false, no case sets it, and no document offers it. LPOUT is in the namelist group that PARMIN reads (parmin.f, line 355↗), so any case with it on reaches this line at every model. The fix (measurement only: the differences written to ISHORT as well) was not run. Intent: none found.
Definitions
subroutinePDIST
Uses modules IOUNITS_MOD, NMLPAR_MOD
Called by (file level)
Change log
The changes since rp_1
Changed since rp_1. NK and DAGE are now arguments (from /ZRAMP/ and /THEAGE/ before; main.f is the only caller); the other COMMON blocks to modules, IMPLICIT NONE; the unused /PULSE/ members and dead /LUNUM/ units dropped.