E3SM-Project / E3SM-Project/E3SM

[Build] Compiler warnings audit: HOMME/EAMxx build log (2026-06-17)

Open
#8,482 5 comments 0 reactions 0 assignees View on GitHub
bug EAMxx HOMME Tech-debt
Dominant language
Fortran
Stars
440
Forks
481
Avg merge
4d 6h
Merged PRs (30d)
36

Description

## Summary

A review of the CI build log (`LastBuild_20260617-0415.log`) surfaces a large number of compiler warnings across HOMME and EAMxx components. These are grouped below by category for targeted cleanup. None currently block the build, but several (especially **W3** and **W5**) carry real correctness/portability risk.

---

## Warning Categories

### W1 · Fortran: Missing explicit MPI interface / EXTERNAL declaration (warning #8889)

**Severity:** Medium — suppressed by most compilers today, but non-standard and may break with stricter compilers.

**Files affected (representative set):**
- `components/homme/src/share/parallelmod.F90` — lines 112, 115, 140, 141, 190, 199, 225–226, 286–287, 313, 333, 337, 357, 361, 387, 411, 436
- `components/homme/src/share/reductionmod.F90` — lines 307, 356, 400, 445, 499, 548, 646, 648, 652
- `components/homme/src/reprosum_mod.F90` — lines 423, 430, 517, 594, 847, 1108, 1133
- `components/homme/src/share/namelistmod.F90` — lines 735, 741–754, 782–825, 831–835, 855–891 (MPI_Bcast, MPI_Barrier)
- `components/homme/src/share/sladvection.F90` — line 791
- `components/homme/src/share/gllfvremapmod.F90` — lines 992, 1074–1079, 1647, 1658, 1692, 1696 (also LAPACK routines: `DGEQRF`, `DTRSM`, `DORMQR`, `DTRTRS`, `DPOTRF`)
- `components/homme/src/share/composetestmod.F90` — line 163 (`GPTL_GetMemUsage`)

**Fix:** Add `USE mpi` (preferred) or explicit `EXTERNAL` declarations for all bare MPI/LAPACK calls. The modern fix is to use the `mpi_f08` or `mpi` module interfaces throughout.

---

### W2 · C++: `struct`/`class` tag mismatch (`-Wmismatched-tags`)

**Severity:** Low on GCC/Clang, but **could cause linker failures under MSVC ABI**. Indicates inconsistent forward declarations.

**Files affected:**
- `components/homme/src/share/cxx/GllFvRemapImpl.hpp:331` — `GllFvRemapImpl` declared as `class` but defined as `struct` (vs. `GllFvRemap.hpp:171`)
- `components/homme/src/share/cxx/CaarFunctor.hpp:19,22` — `Tracers` and `SimulationParams` declared as `class`, defined as `struct`
- `components/homme/src/share/cxx/VerticalRemapManager.hpp:14` — `FunctorsBuffersManager` declared as `class`, defined as `struct`
- `components/homme/src/share/cxx/HyperviscosityFunctor.hpp:23` — `SimulationParams` redeclared as `class`
- `components/homme/src/share/cxx/GllFvRemap.hpp:15` — `FunctorsBuffersManager` declared as `class`, previously `struct`

**Fix:** Standardize all forward declarations to match the definition keyword (`struct` vs `class`). The compiler notes consistently suggest changing forward declarations to `struct`.

---

### W3 · C++: Uninitialized variable use (`-Wsometimes-uninitialized`)

**Severity:** 🔴 **High** — can produce undefined behavior at runtime depending on control flow.

**Files affected:**
- `components/eamxx/src/control/atmosphere_driver.cpp:496` — `failhandlingtype` used uninitialized if the `else if` branch is not taken (use at line 505, declared line 493)
- `components/eamxx/src/control/atmosphere_driver.cpp:1028` — `lev` (a `LogLevel`) used uninitialized if the `else if (soff)` branch is false (use at line 1033, declared line 1017)
- `components/eamxx/src/share/field/fieldpyutils.hpp:94` — `data` used uninitialized in `switch` default case (use at line 98, instantiated from `pyfield.cpp:55`)

**Fix:**
- Initialize `failhandlingtype` and `lev` to a safe default at declaration.
- Initialize `data = nullptr` at line 80 of `fieldpyutils.hpp` (the compiler itself suggests this fix).

---

### W4 · C++: Unused variables (`-Wunused-variable`, `-Wunused-but-set-variable`, `-Wunused-function`)

**Severity:** Low — code cleanliness, but can mask real bugs if they were meant to be used.

**Files affected:**
- `externals/ekat/src/core/ekat_scaling_factor.hpp:45` — `sz2` set but not used (`int sz1=0, sz2=0`). This warning fires in **dozens** of translation units because `ekat_scaling_factor.hpp` is transitively included by almost every EAMxx source file via `ekat/units.hpp` → `ekat_quantity.hpp`.
- `externals/mam4xx/src/mam4xx/hetfrz.hpp:1415` — `fn` unused
- `externals/mam4xx/src/mam4xx/hetfrz.hpp:1188,1189,1190` — `bcnidep`, `bcnicnt`, `bcniimm` unused
- `externals/mam4xx/src/mam4xx/gas_phase_chemistry.hpp:48,49` — `clsmap4`, `permute4` unused
- `components/homme/src/share/cxx/ComposeTransportImplEnhancedTrajectoryImpl.hpp:781,845` — `calc_vel_horiz_formula_node_ref_mid` and `calc_etadot_formula_node_ref_int` are unused Kokkos functions (`-Wunused-function`)

**Fix:**
- `ekat_scaling_factor.hpp`: remove or use `sz2`, or suppress with `(void)sz2`. This single fix will eliminate the warning from all downstream TUs.
- `hetfrz.hpp` / `gas_phase_chemistry.hpp`: remove or annotate unused variables with `[[maybe_unused]]`.
- `ComposeTransportImplEnhancedTrajectoryImpl.hpp`: guard the two Kokkos functions with `#ifdef` or remove if truly dead code.

---

## Environment

- Build date: 2026-06-17
- Runner: GitHub Actions (`/home/runner/work/E3SM/E3SM/`)
- Components: HOMME (`theta-l/kokkos`), EAMxx (SHOC, P3, ZM, MAM, dynamics)

## Suggested Priority

| Priority | Category |
|---|---|
| 🔴 Fix soon | W3 — uninitialized variables (`atmosphere_driver.cpp`, `fieldpyutils.hpp`) |
| 🟠 Fix next | W1 — missing MPI/LAPACK explicit interfaces (Fortran #8889) |
| 🟡 Cleanup | W2 — struct/class tag mismatches (`-Wmismatched-tags`) |
| 🟢 Low effort, high yield | W4 — unused vars (especially `ekat_scaling_factor.hpp` which fans out to dozens of TUs) |

Contributor guide

Open the contributing guide

Research direction

Start with the W3 warnings in components/eamxx/src/control/atmosphere_driver.cpp and components/eamxx/src/share/field/fieldpyutils.hpp, then review the W1–W4 file lists and the referenced CI log. Verify each targeted warning and apply the stated fixes across the affected HOMME, EAMxx, and external headers. Done means the selected warnings are resolved in the relevant CI build without introducing new failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, fortran
Domain
build-system, tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.