Skip to content

docs(hotpaths): the nebular routines mapped in the tour, and the survey of that code - #138

Merged
elijahmathews merged 2 commits into
feat/hotpath-04c-reverse-passfrom
feat/hotpath-nebular-survey
Nov 19, 2026
Merged

elijahmathews merged 2 commits into
feat/hotpath-04c-reverse-passfrom
feat/hotpath-nebular-survey

Conversation

@elijahmathews

Copy link
Copy Markdown
Owner

Stack: after #137. Documentation only.

The survey of the nebular code that the unification plan called for. The family (about 2000 lines: nebular_setup, add_nebular_batch, nebular_kernels, nebular_continuum_tiled, cue_nebular, cue_nebular_backward, backward_nebular, neb_run_block, and the line routines) is two physical models, each with a forward and a reverse pass: the CLOUDY grids, and cue (Li et al. 2024, a neural-network emulation of CLOUDY), plus the line profiles and the dust absorption of the lines. They share the interface (add_nebular_batch) and the line handling, not code, so there is no copy to merge; the plan records that, and doc/HOT_PATH_TOUR.md gets a section with a table of the routines (forward and reverse, per model) for a reader who has to find their way in.

Every routine named was checked to exist.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5

@elijahmathews
elijahmathews added this pull request to stack #114 November 19, 2026 11:58
@elijahmathews
elijahmathews marked this pull request as ready for review November 19, 2026 16:55
@elijahmathews
elijahmathews merged commit d87acc0 into main Nov 19, 2026
@elijahmathews
elijahmathews deleted the feat/hotpath-nebular-survey branch November 19, 2026 17:49
elijahmathews added a commit that referenced this pull request Nov 19, 2026
…139)

Stack: after #138. Merge order: ..., #137, #138, this. A rename,
bit-identical.

## What changes

The flags of `compute_csp_batch` had names that did not say what they
mean (`imf` is "the SSPs come from the operators", not anything about
the IMF itself; `zw`, `zmode`, `naf`...). In `opensps_csp_batch.f90`
(the routines of the driver and the stage routines that receive them):

| Old | New | Meaning |
|---|---|---|
| `imf` | `use_operators` | the SSPs come from the operators (`ssp_ops`
given) |
| `zimf` | `operators_per_z` | one operator per metallicity of the
context |
| `zw` | `weights_over_z` | SSP weights over ages and metallicities
(`ssp_weights_z`) |
| `zmode` | `blend_z` | each model blends the resident bases at its own
`logzsol` |
| `naf` | `n_afe_planes` | [alpha/Fe] planes of the stack (1: none) |
| `zvar` | `z_varies` | the redshifts or `igm_factor` differ among the
models |
| `given_w` | `weights_given` | the SFH weights were supplied |
| `host_w` | `weights_on_host` | few models: the SFH weights computed on
the host |
| `host_m` | `sums_on_host` | few models: weights and per-model sums run
on the host |

223 occurrences; word-boundary replacement in this one file (checked:
the new names were unused, no keyword arguments or other modules use the
old names), 15 code lines and 9 comment blocks that grew past 132
columns reflowed (the comment blocks as whole paragraphs).
`doc/HOT_PATH_TOUR.md` gets a table of the flags and one of the driver's
main arrays (`weights`, `w2`, `yo`, `total`, `absorbed`, `tdiff`, `eml`,
`msum`..., the packed `ipk`/`rpk`/`lpk`/`rout` and the names that view
into them), and the plan the new names.

## Verification

- CPU, both trees built with `-fno-tree-vectorize` (see #134): forward
dumps 6 of 6 and gradient dumps 6 of 6 bit for bit.
- R9700 (both trees rebuilt from scratch, `csp_batch.f90` in both
compile logs): 45 forward dumps, 0 differ bit for bit.
- Host FP64 and FP32 suites, the six device tests and the nvfortran 26.1
compile pass.

🤖 Generated with [Claude Code](https://claude.ai/code)

https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
elijahmathews added a commit that referenced this pull request Nov 19, 2026
…s of a batch (#140)

Stack: after #139. Merge order: ..., #138, #139, this. A move of
procedures within one file; no procedure changed.

## What changes

The procedures of `opensps_csp_batch.f90` were in the order in which
they were written, with the forward stages, their helpers and the
reverse pass interleaved. They now follow the stages of a batch, in the
order in which `compute_csp_batch` runs them:

- the driver, then stage 0 (checks and plan), 1 (per-model setup), 2
(SFH weights), 3 (age sums, mass and L_bol, the slab blend and kernels),
4 (nebular emission), 5 (dust attenuation), 6 (dust emission, IGM, AGN),
7 (smoothing), 8 (outputs), and 9 (the reverse pass, the largest
section),
- a banner for each, and a table of contents after `contains`, so that
the file reads as the hot path from top to bottom (search for `Stage 3:`
to jump to the age sums).

How it was done, and why it is safe: a small tool segmented the file
into 84 units (a procedure with its doc comment, any preprocessor
wrapper around it, and the `#define`/`#include`/`#undef` block after it,
for the template instances) and moved each whole. A mechanical check
showed that the new file holds exactly the lines of the old one plus the
45 banner and table-of-contents lines: nothing lost, nothing duplicated.

A split into several modules was considered and not done: the routines
call each other across the stages (the reverse pass reuses the forward
helpers; the types and constants are shared), so the pieces would need a
common module under them and a long chain of `use` lines, for little
more than the order already gives. `doc/HOT_PATH_TOUR.md` and
`doc/HOT_PATHS_PLAN.md` say so.

## Verification

- CPU, both trees built with `-fno-tree-vectorize` (see #134): forward
dumps 6 of 6 and gradient dumps 6 of 6 bit for bit.
- R9700 (both trees rebuilt from scratch, `csp_batch.f90` in both
compile logs): 45 forward dumps, 0 differ bit for bit.
- Host FP64 and FP32 suites, the six device tests and the nvfortran 26.1
compile pass.

🤖 Generated with [Claude Code](https://claude.ai/code)

https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant