Skip to content

Commit 9c8ea1d

Browse files
committed
docs: record the derived-type broadcast and patch_ib init traps in common-pitfalls
Both bit this branch, both fail silently, and neither is visible to local testing: a derived-type param regrouping dropped its MPI broadcast (non-root ranks kept the sentinel, invisible to single-rank goldens), and an uninitialized patch_ib member reached the solver through the whole-struct copy from particle_cloud_ibs (garbage v_blow -> ICFL NaN, reproducing only on Frontier AMD where the allocation is not zero-filled). Documents the required steps and the platform-only-NaN signature.
1 parent 6af80f9 commit 9c8ea1d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.claude/rules/common-pitfalls.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ covered in `docs/documentation/contributing.md`.
5959
Gotcha: ADDING a new file under `toolchain/mfc/params/` needs one reconfigure
6060
(the custom command's DEPENDS list is globbed at configure time). Under `--case-optimization` the baked-in constants are dropped from the
6161
namelist, so changing one needs a *rebuild*, not a case edit.
62+
- Derived-type params (`chem_params`, `lag_params`, `rburn`) are NOT auto-broadcast:
63+
`generated_bcast.fpp` covers namelist *scalars* only. Each type needs a hand-written
64+
`_emit_<name>` in `toolchain/mfc/params/generators/fortran_gen.py` plus its call site in
65+
the `target == "sim"` block, and — if it is read on device — an explicit
66+
`$:GPU_UPDATE(device='[name]')` in BOTH `m_global_parameters.fpp` and `m_start_up.fpp`
67+
(`GPU_DECLARE` alone does not make it device-resident). Regrouping scalars into a derived
68+
type silently drops their broadcast, so every non-root rank keeps the `dflt_real`
69+
sentinel; single-rank goldens cannot see this, so pair such a change with a `ppn=2` test
70+
and confirm it fails without the emitter.
71+
- A `patch_ib` member that any `m_ibm` ghost-point code reads must ALSO be set in
72+
`s_add_cloud_particle` (`src/simulation/m_particle_cloud.fpp`): `particle_cloud_ibs` is
73+
`allocate`d without default initialization, and `s_reduce_ib_patch_array` copies the whole
74+
struct into `patch_ib`, overwriting the defaults from
75+
`s_assign_default_values_to_user_inputs`. Anything left unset reaches the solver as
76+
uninitialized memory, and only where the allocation is not already zero-filled — a
77+
garbage `v_blow` failed Frontier AMD with `ICFL is NaN` while every NVIDIA lane and all
78+
local CPU/GPU runs passed. A platform-only NaN is the signature of this class.
6279
- Shared-state pattern: namelist declarations (`#:include 'generated_decls.fpp'`), the
6380
`eqn_idx`/`sys_size`/`b_size`/`tensor_size` state variables, and the common defaults
6481
core all live in `src/common/m_global_parameters_common.fpp`. Each per-target

0 commit comments

Comments
 (0)