Skip to content

Fix forbidden/precision-unsafe numeric literals (5.0d-11, integer(wp), missing _wp) #1484

Description

@sbryngelson

MFC convention: no d-exponent literals (5.0d-115.0e-11_wp); no precision-implicit bare literals where a real(wp) is expected (add _wp); loop counters must be plain integer, not integer(wp).

(a) d-exponent literal — src/simulation/m_bubbles_EL.fpp:1345

                    if ((1._wp - q_beta(1)%sf(i, j, k)) > 5.0d-11) then

Fix → 5.0e-11_wp. Note: the source linter's d-literal regex ([0-9]d0) only catches ...d0, so 5.0d-11 slips through. This is the only d-literal remaining in src/. Output-neutral (same value).

(b) integer(wp) loop counter — src/simulation/m_bubbles_EE.fpp:73

        integer(wp)                                            :: i, j, k, l

wp is a real kind; using it as an integer kind is wrong/non-portable. Fix → integer. Only occurrence in src/. Output-neutral.

(c) Bare literals missing _wp (add _wp, value unchanged):

  • src/common/m_constants.fpp:38capillary_cutoff = 1.e-61.e-6_wp
  • src/simulation/m_ibm.fpp:11370.4*patch_ib(...)%mass...0.4_wp*
  • src/simulation/m_acoustic_src.fpp:3511/foc_length(ai)1._wp/...
  • src/simulation/m_ib_patches.fpp:603-604-0.5*length(...) / 0.5*length(...)0.5_wp
  • src/simulation/m_ib_patches.fpp:773-774, :854-8551e12 / -1e121e12_wp / -1e12_wp
  • src/simulation/m_compute_levelset.fpp:151,157,241dist_vec(3) = 00._wp
  • src/simulation/m_compute_levelset.fpp:514,555-566 — integer array literals (/1, 0, 0/) etc. assigned to real vectors → real literals

(d) HardcodedIC — golden-gated, NOT output-neutral:

  • src/common/include/1dHardcodedIC.fpp:24,291 + 0.2*sin(5*x_cc(i)) etc. (bare 0.2, 5 default-real literals)
    These compile into pre_process initial conditions used by case-optimization tests. Adding _wp is value-neutral in exact arithmetic, but because these are golden-gated pre_process outputs the change may need ./mfc.sh test --generate --only <affected> if rounding shifts any digit. Flag for test regen — do not assume neutral.

Why it matters: d-literals and bare-real literals break single/mixed-precision builds (--single, --mixed) — a 1.e-6 literal is real32 regardless of wp, silently changing results in mixed mode. integer(wp) is outright type-incorrect.


Filed from a repo-wide code-cleanliness review; locations verified against master @ 40dde5e.

Code references

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working or doesn't seem rightgood first issueGood for newcomers

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions