From de80c30a1e96a5e7c8455a4191b088c2e84c96fd Mon Sep 17 00:00:00 2001 From: Mark Taylor Date: Wed, 19 Aug 2026 14:54:58 -0500 Subject: [PATCH] Fix uninitialized tc_curr causing FIDEAL debug crash The energy diagnostic state fields (tc_curr, tc_init, tc_mnst, tc_prev) are allocated with tc_curr set to an Infinity sentinel value, and are normally zeroed out by co2_diags_init(). However, phys_init() returns early for adiabatic/ideal physics configurations (e.g. the FIDEAL compset) before reaching the co2_diags_init() call, leaving tc_curr at Infinity for the entire run. In debug builds, this trips the shr_assert_in_domain check on state%tc_curr and crashes the run with a segmentation fault during cime_init. Move the co2_diags_init() call to before the adiabatic/ideal_phys early return so these fields are always initialized, and remove the now-redundant duplicate call further down. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- components/eam/src/physics/cam/physpkg.F90 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/eam/src/physics/cam/physpkg.F90 b/components/eam/src/physics/cam/physpkg.F90 index 57ac1f31c891..32675e63c0a4 100644 --- a/components/eam/src/physics/cam/physpkg.F90 +++ b/components/eam/src/physics/cam/physpkg.F90 @@ -840,6 +840,12 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_out ) call check_energy_init(phys_state) + ! Initialize energy diagnostic state fields (tc_curr, tc_init, etc.) + ! so they aren't left at the Infinity sentinel value for ideal/adiabatic + ! physics configurations (e.g. FIDEAL), which return before the call + ! further below. + call co2_diags_init(phys_state) + call tracers_init() ! age of air tracers @@ -913,7 +919,6 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_out ) if (co2_transport()) then call co2_init() end if - call co2_diags_init(phys_state) ! CAM3 prescribed ozone if (cam3_ozone_data_on) call cam3_ozone_data_init(phys_state)