Skip to content

Remove fmt: convert I* files to std::format (part 4)#11619

Open
brianlball wants to merge 3 commits into
developfrom
remove-fmt-part-4
Open

Remove fmt: convert I* files to std::format (part 4)#11619
brianlball wants to merge 3 commits into
developfrom
remove-fmt-part-4

Conversation

@brianlball
Copy link
Copy Markdown
Contributor

Purpose

Continues the remove-fmt campaign (#11553, #11588, #11592). Converts the I*
source files from EnergyPlus::format/fmt::format to C++20 std::format and
replaces the custom {:.NR} flag with standard specifiers.

Scope

File calls converted
InternalHeatGains.cc 148
IceThermalStorage.cc 7
ICEngineElectricGenerator.cc 4

0 {R}/{T} and 0 EnergyPlus::format remain in these files. The DoubleWrapper /
Fortran-format machinery in IOFiles.hh is left untouched (later PR).

Specifier mapping

Per-field, following the A–H precedent and chosen to preserve the reported precision:

  • Magnitude-spanning density columns (e.g. People/Floor Area, the per-area
    Zone Internal Gains Nominal fields) → {:#G}. The old {:.NR} switched to
    scientific below 0.1, so a plain {:.Nf} would truncate small values
    (3.531E-0020.035, losing two sig figs). {:#G} preserves precision
    (0.0353101), matching how A–H handles these EIO "Nominal" tables.
  • Always-tiny CO2 rate{:.4E} — reproduces the baseline mantissa exactly
    (3.8200E-0083.8200E-08, only exponent width differs).
  • People counts{:.1f} — matches the old 1-decimal echo.
  • Fractions / DesignLevel watts (always ≥ 0.1) → {:.3f} (exact match).

Verification (energyplus-regressions vs develop, local Windows)

  • 0 numeric result diffs — ESO/MTR/SSZ/ZSZ/JSON byte-identical.
  • Display-only table/EIO diffs: 543 small + 10 big, 652 EIO.
  • The 10 big are irreducible x.x5 people-count flips — old {R} rounds half-up,
    std::format rounds half-to-even. Same benign class accepted in Remove fmt - Part 2: Remove {R}, Files A-D #11588/Remove fmt - Part 3: Remove {R}, Files E-H #11592.
  • ⚠️ {:#G} has documented MSVC-vs-gcc trailing-zero divergence; local run is
    Windows-only, so CI (ubuntu/macos) is the authoritative check on the density
    outputs. A–H already ship {:#G} broadly, so risk is low but non-zero.

Indentation note

Whitespace-only line changes are clang-format v19 reflow: std::format is 7 chars
shorter than EnergyPlus::format, so wrapped calls collapse under the 150-col
limit. pre-commit run clang-format passes clean.

Question for review

Is the per-field mapping ({:#G} densities / {:.4E} CO2 / {:.1f} counts) the
approach you want, and are the 10 half-even count-flip diffs acceptable (consistent
with prior parts)?

Convert InternalHeatGains.cc, IceThermalStorage.cc, and ICEngineElectricGenerator.cc from EnergyPlus::format to std::format and replace the custom {:.NR} flag with standard specifiers. Magnitude-spanning density columns use {:#G} (A-H precedent), preserving precision for sub-0.1 values; the always-tiny CO2 rate uses {:.4E}; people counts use {:.1f}. Continues the remove-fmt campaign (#11553, #11588, #11592). Display-only; numeric results byte-identical to develop.
@brianlball brianlball added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

⚠️ Regressions detected on ubuntu-24.04 for commit 98e953c

Regression Summary
  • EIO: 693
  • Table Big Diffs: 10
  • Table Small Diffs: 580

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

⚠️ Regressions detected on macos-14 for commit 98e953c

Regression Summary
  • EIO: 689
  • Table Big Diffs: 10
  • Table Small Diffs: 578

@brianlball
Copy link
Copy Markdown
Contributor Author

brianlball commented Jun 4, 2026

CI looks good ✅

All checks pass. I went through the regression artifacts from both Linux and macOS.

The 10 "Big Diffs" are all people-count display changes in the
People Internal Gains Nominal table:

Test change
5ZoneAirCooledWithSpaces / …DaylightingIntMass / …HVAC 11.911.8
1ZoneEvapCooler_ReportPeriodPowerOutage (+ _naturalVent) 1.00.9
ASHRAE901_HotelLarge_STD2019_Denver 0.50.4
ASHRAE901_HotelSmall_STD2019_Denver 0.50.4, 1.41.3
TranspiredCollectors 14.314.2
UserDefinedRoomAirPatterns 1.31.2
ASHRAE901_OutPatientHealthCare_STD2019_Denver tiny min/max counts (0.011, 0.056, …) → 0.0 / 0.1

Most are a count landing on a .5 and rounding the other way — old code rounds
half-up, std::format rounds half-to-even. OutPatient is the exception: sub-0.1
per-schedule counts that {:.1f} rounds to 0.0/0.1 where develop printed
scientific notation. All are 1-decimal count display; same class as #11588 / #11592.
(Counts stay {:.1f} deliberately — unlike the densities, {:#G} would render
whole people counts as 5.00000; the sub-0.1 roundings are a negligible
fractional-occupancy artifact.)

The one risk worth checking, checked. These files switch the density columns
to {:#G}, which has a history of printing differently on MSVC vs gcc. I compared
our output across all 689 cases that ran on both Linux and macOS — identical on
every one
. No platform divergence.

Why the diff count is on the higher side: densities use {:#G} on purpose to
keep precision on small values — plain fixed formatting would turn 3.531E-002
into 0.035 and lose digits. That trades a larger diff count for no precision loss.

Linux macOS
Result diffs 0 0
Table Big 10 10
Table Small 580 578
EIO (echo) 693 689

@brianlball brianlball requested a review from mitchute June 4, 2026 16:28
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

⚠️ Regressions detected on macos-14 for commit a19e69d

Regression Summary
  • EIO: 690
  • Table Big Diffs: 78
  • Table Small Diffs: 511

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

⚠️ Regressions detected on ubuntu-24.04 for commit a19e69d

Regression Summary
  • EIO: 694
  • Table Big Diffs: 78
  • Table Small Diffs: 513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants