Two related duplications in src/pre_process/.
(a) patch_id_fp declaration boilerplate (22 copies). The same 5-line mixed-precision conditional declaration is repeated ~22 times across m_assign_variables.fpp, m_icpp_patches.fpp, and m_initial_condition.fpp:
#ifdef MFC_MIXED_PRECISION
integer(kind=1), dimension(0:m,0:n,0:p), intent(inout) :: patch_id_fp
#else
integer, dimension(0:m,0:n,0:p), intent(inout) :: patch_id_fp
#endif
A single Fypp macro — e.g. @:PATCH_ID_FP_DECL() expanding to the #ifdef'd declaration — replaces all of them and makes the kind choice editable in one place.
(b) QBMM moment-set block + void-fraction rescale (≥2 copies each) inside s_assign_patch_species_primitive_variables (m_assign_variables.fpp). The q_prim_vf(qbmm_idx%fullmom(i, p, q))%sf(...) = ... moment-initialization block (the polytropic vs non-polytropic if, 6 fullmom assignments each) appears near-identically at ~315-337 and ~482+. The "adjust volume fractions, according to modeled gas void fraction" rescale recurs at ~247, 267, 300, 408.
Why it's friction: (a) is pure boilerplate that obscures signatures and risks the two precision arms drifting; (b) duplicates non-trivial physics initialization across the patch-species branches.
Safe refactor: (a) a Fypp declaration macro — mechanical, near-zero risk. (b) extract the moment-set into a seq helper or Fypp macro keyed on the polytropic flag.
Golden-file risk: (a) zero — a declaration; no generated instructions change. (b) moderate — it sets initial-condition field values, so an extraction must reproduce the exact expressions; any drift changes IC golden files for QBMM/bubble pre_process tests.
Recommended split: the declaration-macro half (a) is a clean good-first-issue (zero golden risk); the QBMM-block half (b) is the more delicate, separately-verifiable part.
Dedup note: not covered by #1426/#1440/#1441/#1451.
Filed from a repo-wide code-cleanliness review; verified against master @ 40dde5e.
Code references
Two related duplications in
src/pre_process/.(a)
patch_id_fpdeclaration boilerplate (22 copies). The same 5-line mixed-precision conditional declaration is repeated ~22 times acrossm_assign_variables.fpp,m_icpp_patches.fpp, andm_initial_condition.fpp:A single Fypp macro — e.g.
@:PATCH_ID_FP_DECL()expanding to the#ifdef'd declaration — replaces all of them and makes the kind choice editable in one place.(b) QBMM moment-set block + void-fraction rescale (≥2 copies each) inside
s_assign_patch_species_primitive_variables(m_assign_variables.fpp). Theq_prim_vf(qbmm_idx%fullmom(i, p, q))%sf(...) = ...moment-initialization block (the polytropic vs non-polytropicif, 6fullmomassignments each) appears near-identically at ~315-337 and ~482+. The "adjust volume fractions, according to modeled gas void fraction" rescale recurs at ~247, 267, 300, 408.Why it's friction: (a) is pure boilerplate that obscures signatures and risks the two precision arms drifting; (b) duplicates non-trivial physics initialization across the patch-species branches.
Safe refactor: (a) a Fypp declaration macro — mechanical, near-zero risk. (b) extract the moment-set into a
seqhelper or Fypp macro keyed on the polytropic flag.Golden-file risk: (a) zero — a declaration; no generated instructions change. (b) moderate — it sets initial-condition field values, so an extraction must reproduce the exact expressions; any drift changes IC golden files for QBMM/bubble pre_process tests.
Recommended split: the declaration-macro half (a) is a clean good-first-issue (zero golden risk); the QBMM-block half (b) is the more delicate, separately-verifiable part.
Dedup note: not covered by #1426/#1440/#1441/#1451.
Filed from a repo-wide code-cleanliness review; verified against
master@40dde5e.Code references
src/pre_process/m_assign_variables.fpp:39-43— patch_id_fp decl blocksrc/pre_process/m_assign_variables.fpp:315-337— QBMM moment block