Skip to content

inaccuracy: legacy single-precision physics constants (c/pi/sol/kB) in KiLCA + KIM #166

Description

@krystophny

Category: inaccuracy (latent, pre-existing; encoded in the golden record).

Several legacy Fortran files declare real(8)/real(dp) physics constants from
literals that are parsed at single precision (no _dp/d0 suffix, or an e
exponent), so a ~7-significant-figure value is stored in a double and then used
in double-precision physics. Example: 29979245800.0 (bare) rounds to
29979246592.0 — off by ~792, i.e. ~2.6e-8 relative.

These are not bugs introduced by the C++->Fortran port; they predate it and
the KiLCA golden record was generated with them, so they must not be "fixed"
in isolation
— doing so shifts the golden outputs. (The port already had to
reproduce one of these: the KiLCA constants module keeps its single-precision
c for the legacy Fortran physics, while the ported-from-C++ modules carry a
local double c mirroring the oracle's constants.h; see PR #161.)

Affected (verified legacy, 0 lines changed vs the pre-port base)

  • KiLCA/hom_medium/hmedium.f90:21,23,106,108,351,352,408,409c = 29979245800.0, pi = 3.14159... (single).
  • KiLCA/imhd/imhd.f90:137,138,221,222pi, c (single).
  • KiLCA/math/W/wfunc.f90:11, wmfunc.f90:11, wm_asympt.f90:11pi = 3.141592653589793238462643383279502884197 (single).
  • KIM/src/util/constants_mod.f90:8sol = 29979245800.0 (single; used across kernels/electromagnetic_solver/species/calculate_equil).
  • KIM/src/util/constants_mod.f90:13kB = 1.380649e-16 (e exponent -> single: 1.3806490132968306e-16 vs 1.380649e-16).

Fix (deferred, requires golden regeneration)

Add explicit double-precision suffixes (_dp) / d-exponents to the literals,
consolidate onto a single shared constants module where possible, then
regenerate the KiLCA and KIM golden records and confirm the strict bar holds.
Coordinate with any golden exclusions.

Environment

Branch fortran-port-all (PR #161); files unchanged since the pre-port base.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions