1C
2C
3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4C READ PURE Z LAOL89
5CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6 SUBROUTINE RDZLAOL(FPUREZ)
7C 10/14/26 MHP via Claude
8C code changed to convert COMMON/ZLAOL/ into ZLAOL_MOD.
9 USE ZLAOL_MOD
10C 10/14/26 MHP via Claude
11C code changed to convert COMMON/IOUNITS/ into IOUNITS_MOD.
12 USE IOUNITS_MOD
13C 10/20/26 MHP via Claude
14C code changed to replace implicit typing with IMPLICIT NONE and
15C explicit declarations.
16 IMPLICIT NONE
17 INTEGER I,II,IR,IT,N
18C MHP 10/02 vector v not used
19C SUBROUTINE RDZLAOL(V)
20
21 REAL*8 DUMMY(104)
22 CHARACTER*256 FPUREZ
23
24C MHP 8/25 Removed character file names from common block
25C DBG 12/95 ARRAYS FOR PURE Z TABLE
26C 9/25/26 MHP via Claude
27C code changed to consolidate all I/O logical unit numbers, previously
28C scattered across COMMON/LUOUT/, COMMON/LUNUM/, COMMON/ALEX06/,
29C COMMON/ACDPTH/, COMMON/NEWOPAC/, COMMON/LOPAL95/, COMMON/ATMOS2/,
30C COMMON/ALATM03/, COMMON/OPALEOS/, and COMMON/SCV2/, into a single
31C COMMON/IOUNITS/
32C 10/13/26 MHP via Claude: removed the unused COMMON/NMLPAR/ declaration
33C (no member referenced here; residue of the obsolete-option removals).
34C 10/13/26 MHP via Claude: removed the unused COMMON/NEWOPAC/ declaration
35C (no member referenced here; residue of the obsolete-option removals).
36C DIMENSION V(12)
37 SAVE
38
39 OPEN(UNIT=IOPUREZ, FILE=FPUREZ,FORM='FORMATTED',
40 * * STATUS='OLD')
41C READ IN ARRAY SIZES
42 READ(IOPUREZ,100)N,NUMRHOZ,NUMTZ
43 100 100 FORMAT(/,18X,I2,9X,I3,14X,I3)
44 IF(N.NE.1.OR.NUMRHOZ.GT.104.OR.NUMTZ.GT.52) THEN
45 WRITE(ISHORT,*)' Z OPACITY INPUT ERROR.'
46C 10/30/26 MHP via Claude: bare STOP -> STOP 3, the input-error code (issue 38).
47 STOP 3
48 END IF
49 READ(IOPUREZ,120)(DUMMY(I),I=1,11)
50 120 120 FORMAT(47X,F8.5,//,1P6E12.5,/,1P4E12.5)
51 READ(IOPUREZ,131)DUMMY(1)
52 131 131 FORMAT(54X,F8.5,///////)
53C READ IN H MASS FRACTIONS OF TABLE
54 READ(IOPUREZ,140)DUMMY(1)
55 140 140 FORMAT(/,(1P6E12.5))
56C READ IN DENSITY GRID OF TABLE
57 READ(IOPUREZ,150)(ZORHO(II),II=1,NUMRHOZ)
58 150 150 FORMAT(/,(1P6E12.5))
59C READ IN TEMPERATURE GRID OF TABLE
60 READ(IOPUREZ,160)(ZOT(II),II=1,NUMTZ)
61 160 160 FORMAT(/,(1P6E12.5))
62C READ IN PURE Z OPACITIES
63 READ(IOPUREZ,170)
64 170 170 FORMAT(1X)
65 DO IR=1,NUMRHOZ
66 READ(IOPUREZ,200)
67 200 200 FORMAT(1X)
68 READ(IOPUREZ,210)(ZOLAOL(IR,IT),IT=1,NUMTZ)
69 210 210 FORMAT(1P6E12.5)
70 END DO
71 CLOSE(IOPUREZ)
72
73 RETURN
74 END
1"""Python version of rdzlaol.f (YREC 7be4133): read the LAOL89 opacity
2table for pure metals (the "pure Z" table)."""
3
4from pyrec import iounits_mod
5from pyrec import zlaol_mod
6
7
8def _e_records(unit, n, per=6, w=12):
9 """Read n reals as FORMAT (1P6E12.5) does: per to a record, so
10 ceil(n/per) records. (1P would scale a field without an exponent by
11 1/10; the tables' fields have exponents, and it is not applied.)"""
12
13 out = []
14 while len(out) < n:
15 line = iounits_mod.read(unit)
16 for k in range(min(per, n - len(out))):
17 text = line[k * w:(k + 1) * w].replace(' ', '')
18 out.append(float(text.replace('D', 'E')) if text else 0.0)
19 return out
20
21
22def _skip(unit, nrec):
23 for _ in range(nrec):
24 iounits_mod.read(unit)
25
26
27def rdzlaol(fpurez: str) -> None:
28 """Read the pure-metal opacity table from the file fpurez (unit
29 IOPUREZ) into ZLAOL_MOD: the sizes NUMRHOZ, NUMTZ, the grids ZORHO,
30 ZOT and the opacities ZOLAOL(rho, T). The header (mix, hydrogen
31 fraction) is read and dropped. Stops the run if the file has more
32 than one composition or the grids exceed 104 x 52.
33
34 Translates: rdzlaol.f#RDZLAOL (7be4133)
35
36 Arguments: fpurez, the file name. Returns nothing.
37
38 """
39
40 z = zlaol_mod
41 iopurez = iounits_mod.iopurez
42
43 # Open the file (Fortran lines 39–40).
44 iounits_mod.open(iopurez, fpurez, status='OLD')
45
46 # The array sizes, checked (Fortran lines 41–48).
47 # FORMAT 100: (/,18X,I2,9X,I3,14X,I3), the second record.
48 _skip(iopurez, 1)
49 line = iounits_mod.read(iopurez)
50 n = int(line[18:20])
51 z.numrhoz = int(line[29:32])
52 z.numtz = int(line[46:49])
53 if n != 1 or z.numrhoz > 104 or z.numtz > 52:
54 iounits_mod.write(iounits_mod.ishort, ' Z OPACITY INPUT ERROR.')
55 raise SystemExit(3) # STOP 3, the input-error code
56
57 # The header, read and dropped (Fortran lines 49–55).
58 # FORMAT 120: (47X,F8.5,//,1P6E12.5,/,1P4E12.5), the mix: 4 records.
59 _skip(iopurez, 4)
60 # FORMAT 131: (54X,F8.5,///////), the hydrogen fraction: 8 records.
61 _skip(iopurez, 8)
62 # FORMAT 140: (/,(1P6E12.5)), one dummy value: 2 records.
63 _skip(iopurez, 2)
64
65 # The density and temperature grids (Fortran lines 56–61).
66 # FORMATs 150 and 160: (/,(1P6E12.5)).
67 _skip(iopurez, 1)
68 vals = _e_records(iopurez, z.numrhoz)
69 for ii in range(1, z.numrhoz + 1):
70 z.zorho[ii] = vals[ii - 1]
71 _skip(iopurez, 1)
72 vals = _e_records(iopurez, z.numtz)
73 for ii in range(1, z.numtz + 1):
74 z.zot[ii] = vals[ii - 1]
75
76 # The opacities, one density at a time (Fortran lines 62–70).
77 _skip(iopurez, 1) # FORMAT 170
78 for ir in range(1, z.numrhoz + 1):
79 _skip(iopurez, 1) # FORMAT 200
80 vals = _e_records(iopurez, z.numtz) # FORMAT 210
81 for it in range(1, z.numtz + 1):
82 z.zolaol[ir, it] = vals[it - 1]
83
84 # Close the file (Fortran line 71).
85 iounits_mod.close(iopurez)