c_sum_Yi_Phi reaches s_compute_speed_of_sound_avg as the c_c argument, which uses it as
if (chemistry) then ! Reacting mixture sound speed
if (avg_state == avg_state_roe .and. abs(c_c) > verysmall) then
c = sqrt(c_c - (gamma - 1.0_wp)*(vel_sum - H))
else
call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, adv, c)
end if
It is written in exactly two places: roe_avg (src/simulation/include/inline_riemann.fpp), inside its if (chemistry) block, and src/simulation/m_riemann_solver_hllc.fpp:957, where the hypoelastic variant zeroes it. Two consequences follow.
1. HLL never initializes it
c_sum_Yi_Phi is a private variable of the offload loop in src/simulation/m_riemann_solver_hll.fpp and is written only when avg_state == 1, because roe_avg is the only writer. With chemistry, avg_state = 2 and wave_speeds = 2, line 334 passes an uninitialized value, and abs(c_c) > verysmall reads it.
Fortran does not guarantee short-circuit evaluation of .and., so the read can happen even though avg_state == avg_state_roe is already false. The value is not used — the else branch is taken either way — so this is an uninitialized read rather than a wrong answer. It is the shape that tends to surface as a platform-specific NaN rather than a reproducible failure.
2. The HLLC base path hard-codes zero
src/simulation/m_riemann_solver_hllc.fpp:285-286 passes a literal 0._wp where HLL (line 334) and the HLLC hypoelastic variant (line 1050) pass the real value:
call s_compute_speed_of_sound_avg(pres_R, rho_avg, gamma_avg, pi_inf_R, qv_avg, vel_avg_rms, &
& H_avg, 0._wp, alpha_R, c_avg)
Since abs(c_c) > verysmall gates the branch, HLLC without hypoelasticity always falls back to s_compute_speed_of_sound and never uses the reacting Roe sound speed, while HLL and HLLC-with-hypoelasticity do. So the same case can get a different sound speed depending on which solver and which variant it runs through. If that is deliberate it deserves a comment saying so; if not, it is an inconsistency.
c_sum_Yi_Phireachess_compute_speed_of_sound_avgas thec_cargument, which uses it asIt is written in exactly two places:
roe_avg(src/simulation/include/inline_riemann.fpp), inside itsif (chemistry)block, andsrc/simulation/m_riemann_solver_hllc.fpp:957, where the hypoelastic variant zeroes it. Two consequences follow.1. HLL never initializes it
c_sum_Yi_Phiis aprivatevariable of the offload loop insrc/simulation/m_riemann_solver_hll.fppand is written only whenavg_state == 1, becauseroe_avgis the only writer. Withchemistry,avg_state = 2andwave_speeds = 2, line 334 passes an uninitialized value, andabs(c_c) > verysmallreads it.Fortran does not guarantee short-circuit evaluation of
.and., so the read can happen even thoughavg_state == avg_state_roeis already false. The value is not used — theelsebranch is taken either way — so this is an uninitialized read rather than a wrong answer. It is the shape that tends to surface as a platform-specific NaN rather than a reproducible failure.2. The HLLC base path hard-codes zero
src/simulation/m_riemann_solver_hllc.fpp:285-286passes a literal0._wpwhere HLL (line 334) and the HLLC hypoelastic variant (line 1050) pass the real value:Since
abs(c_c) > verysmallgates the branch, HLLC without hypoelasticity always falls back tos_compute_speed_of_soundand never uses the reacting Roe sound speed, while HLL and HLLC-with-hypoelasticity do. So the same case can get a different sound speed depending on which solver and which variant it runs through. If that is deliberate it deserves a comment saying so; if not, it is an inconsistency.