1
2
3C
4C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
5C SETSCAL
6C$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
7 SUBROUTINE SETSCAL(ALRI,LSTAR,LPASSR)
8C 10/14/26 MHP via Claude
9C code changed to convert COMMON/NMLPAR/ into NMLPAR_MOD.
10 USE NMLPAR_MOD
11C 10/14/26 MHP via Claude
12C code changed to convert COMMON/CONSTANTS/ into CONSTANTS_MOD.
13 USE CONSTANTS_MOD
14C 10/14/26 MHP via Claude
15C code changed to convert COMMON/IOUNITS/ into IOUNITS_MOD.
16 USE IOUNITS_MOD
17C 10/14/26 MHP via Claude
18C code changed to convert COMMON/RUNLOOP/ into RUNLOOP_MOD. A blanket
19C USE imports exactly the names the COMMON declaration made global here,
20C so it cannot change meaning. See runloop_mod.f for the block history
21C and for why the module declares the types the implicit rules supplied.
22 USE RUNLOOP_MOD
23C 10/20/26 MHP via Claude
24C code changed to replace implicit typing with IMPLICIT NONE and
25C explicit declarations.
26 IMPLICIT NONE
27 REAL*8 ALRI
28 INTEGER I,J
29 LOGICAL*4 LPASSR,LSTAR
30C 10/13/26 MHP via Claude
31C code changed to replace COMMON/CALSTAR/ with explicit arguments.
32C setscal.f initializes ALRI, LSTAR and LPASSR, chkscal.f reads and
33C updates ALRI and sets the two flags, and main.f reads the flags; main.f
34C calls both routines, so it now owns all three. ALRI is read as well as
35C written inside chkscal.f and is carried across calls there, which
36C main.f's blanket SAVE preserves exactly as the block did.
37C MHP 8/25 Removed unused variables
38C CHARACTER*256 FLAOL2, FOPAL2
39C 10/12/26 MHP via Claude
40C code changed to extend COMMON/NMLPAR/ to 234 members, adding the
41C namelist variables that the physics routines read from 27 COMMON
42C blocks which also held derived or working members. Those blocks keep
43C only their non-namelist members; five of them -- NEWMX, VMULT,
44C PMMWIND, CCOUT1 and ENVGEN -- had nothing left and are gone.
45C Derivation-only namelist variables from the same blocks went to
46C COMMON/NMLBYPASS/ instead, not here.
47C
48C Declared identically in all 121 files that hold any of these members.
49C Generated from one member list, so every copy is byte-identical; the
50C linker's 'size of symbol changed' warning is the check that they are.
51C 9/25/26 MHP via Claude
52C code changed to consolidate all I/O logical unit numbers, previously
53C scattered across COMMON/LUOUT/, COMMON/LUNUM/, COMMON/ALEX06/,
54C COMMON/ACDPTH/, COMMON/NEWOPAC/, COMMON/LOPAL95/, COMMON/ATMOS2/,
55C COMMON/ALATM03/, COMMON/OPALEOS/, and COMMON/SCV2/, into a single
56C COMMON/IOUNITS/
57C MHP 10/24 ADDED STOP CRITERIA FOR CENTRAL H,D,AND HE4
58C MHP 8/25 Removed character file names from common block
59C 9/24/26 MHP via Claude
60C code changed to remove dead IOOPAL2 from COMMON/ZRAMP/
61C 10/9/26 MHP via Claude
62C code changed to remove NK from COMMON/ZRAMP/: it was only ever a
63C redundant copy of the run-index loop variable main.f already passes
64C explicitly to the subroutines that need it (STARIN/RSCALE), and was
65C never read by name in this file (the "NK-1" in the comment below is
66C just documentation, not live code).
67C 10/13/26 MHP via Claude
68C code changed to remove COMMON/ZRAMP/: its sole remaining member
69C IOLAOL2 is neither written nor read anywhere. The namelist members
70C that shared this block moved to the consolidated block in stage 2b.
71C 9/25/26 MHP via Claude
72C code changed to merge COMMON/CONST/, COMMON/CONST1/, COMMON/CONST2/,
73C and COMMON/CONST3/ into a single COMMON/CONSTANTS/
74C 10/12/26 MHP via Claude
75C code changed to drop BLI, AGER, BLR, BLRP and AGEI from
76C COMMON/CALSTAR/; they are written and read only in chkscal.f and are
77C now locals there. This file never referenced them.
78 SAVE
79C LSTAR T - have got a star at Teff and L
80C LPASSR T - on run have just passed Teff
81C XLS Luminosity (L/Lsun) wanted by adjusting Y
82C XLSTOL tolerance wanted for luminosity
83C LTEFF T - specify Teff for star
84C F - specify R/Rsun for star
85C STEFF Effective temperature of star (K) or...
86C SR Radius of star (R/Rsun)
87C TEFF Teff of current model
88C ALR log(R/Rsun) of current model
89C ALRI log(R/Rsun) of previous model
90C DAGE age of current model (Gyr)
91C AGEI age of previous model (Gyr)
92C AGER age of model at R*
93C BL luminosity of current model
94C BLI luminosity of previous model
95C BLR luminosity of model at R
96C BLRP luminosity of model at R* of previous run
97C XP X of previous run = RESCAL(2, NK-1)
98C mhp 10/02 linct not used, commented out
99C LINCT = .TRUE.
100 LSTAR = .FALSE.
101 LPASSR = .FALSE.
102 IF (LTEFF) THEN
103 SR = SQRT(XLS*CLSUN/(C4PI*CSIG))/(STEFF*STEFF*CRSUN)
104 ELSE
105 STEFF = ((XLS*CLSUN)/(C4PI*CSIG*SR*SR*CRSUN*CRSUN))**0.25D0
106 END IF
107 ALRI = 0
108C SET UP RUN TO EVOLVE TO L, Teff IN HR-DIAGRM.
109C THIS CONSISTS OF SETTING THE NUMBER OF RUNS TO THE MAXIMUM (50),
110C AND COPYING THE RELEVANT PARAMETERS FROM THE FIRST TWO RUNS TO
111C THE NEXT SERIES OF 24 CALIBRATING RUNS.
112 NUMRUN = 50
113 DO I = 2,50
114 XENV0A(I) = XENV0A(1)
115 ZENV0A(I) = ZENV0A(1)
116 CMIXLA(I) = CMIXLA(1)
117 LSENV0A(I) = LSENV0A(1)
118 SENV0A(I) = SENV0A(1)
119 END DO
120 DO I = 3,49,2
121 IRESCA(I) = IRESCA(1)
122 LFIRST(I) = .TRUE.
123 NMODLS(I) = NMODLS(1)
124 RSCLZC(I) = RSCLZC(1)
125 RSCLZM1(I) = RSCLZM1(1)
126 RSCLZM2(I) = RSCLZM2(1)
127 DO J = 1,4
128 RESCAL(J,I) = RESCAL(J,1)
129 END DO
130 END DO
131 DO I = 4,50,2
132 IRESCA(I) = 1
133 LFIRST(I) = .FALSE.
134 NMODLS(I) = NMODLS(2)
135 ENDAGE(I) = ENDAGE(2)
136 LENDAG(I) = LENDAG(2)
137 SETDT(I) = SETDT(2)
138 LSETDT(I) = LSETDT(2)
139 END DO
140 WRITE(*,*) ' Evolve to R*, L* = ', SR, XLS
141 WRITE(ITRACK,*) '#Evolve to R*, L* = ', SR, XLS
142 RETURN
143 END
1"""Python version of setscal.f (YREC 7be4133): the 50 runs of a
2calibration of a star to a given luminosity and Teff (or radius)."""
3
4import math
5
6from pyrec import constants_mod
7from pyrec import iounits_mod
8from pyrec import nmlpar_mod
9from pyrec import runloop_mod
10
11
12def setscal(alri: float, lstar: bool, lpassr: bool) -> tuple[float, bool, bool]:
13 """Compute the target's missing radius or Teff from L = 4 pi R^2
14 sigma Teff^4, reset the search's state, and fill the run list: 25
15 repetitions of runs 1 (a new starting model) and 2 (evolution).
16
17 Translates: setscal.f#SETSCAL (7be4133)
18
19 Arguments: alri, log R/Rsun of the previous model; lstar, lpassr, the
20 search's flags (all only set).
21
22 Returns (alri, lstar, lpassr) = (0, False, False).
23
24 """
25
26 c = constants_mod
27 n = nmlpar_mod
28 r = runloop_mod
29
30 # The search's flags (Fortran lines 100–101).
31 lstar = False
32 lpassr = False
33
34 # The target's missing radius or Teff (Fortran lines 102–107).
35 if n.lteff:
36 n.sr = math.sqrt(n.xls * c.clsun / (c.c4pi * c.csig)) / (
37 n.steff * n.steff * c.crsun)
38 else:
39 n.steff = ((n.xls * c.clsun)
40 / (c.c4pi * c.csig * n.sr * n.sr * c.crsun * c.crsun)
41 )**0.25
42 alri = 0.0
43
44 # 50 runs; run 1's composition and mixing length copied to all
45 # (Fortran lines 108–119).
46 # Question (see the page): the comment says 24 runs.
47 n.numrun = 50
48 for i in range(2, 51):
49 n.xenv0a[i] = n.xenv0a[1]
50 n.zenv0a[i] = n.zenv0a[1]
51 n.cmixla[i] = n.cmixla[1]
52 n.lsenv0a[i] = n.lsenv0a[1]
53 n.senv0a[i] = n.senv0a[1]
54
55 # Runs 3, 5, ..., 49 repeat run 1 (a new starting model) (Fortran lines 120–130).
56 for i in range(3, 50, 2):
57 r.iresca[i] = r.iresca[1]
58 n.lfirst[i] = True
59 n.nmodls[i] = n.nmodls[1]
60 n.rsclzc[i] = n.rsclzc[1]
61 n.rsclzm1[i] = n.rsclzm1[1]
62 n.rsclzm2[i] = n.rsclzm2[1]
63 for j in range(1, 5):
64 r.rescal[j, i] = r.rescal[j, 1]
65
66 # Runs 4, 6, ..., 50 repeat run 2 (evolution) (Fortran lines 131–139).
67 # Question (see the page): END_DCEN, END_XCEN, END_YCEN not copied.
68 for i in range(4, 51, 2):
69 r.iresca[i] = 1
70 n.lfirst[i] = False
71 n.nmodls[i] = n.nmodls[2]
72 n.endage[i] = n.endage[2]
73 r.lendag[i] = r.lendag[2]
74 n.setdt[i] = n.setdt[2]
75 r.lsetdt[i] = r.lsetdt[2]
76
77 # Fortran lines 140–141.
78 print(" Evolve to R*, L* = ", n.sr, n.xls)
79 iounits_mod.write(iounits_mod.itrack,
80 f" #Evolve to R*, L* = {n.sr} {n.xls}")
81 return alri, lstar, lpassr