In src/simulation/m_rhs.fpp the energy slot of flux_src_n is allocated for the chemistry-diffusion path inside if (chemistry):
if (chemistry) then
...
if (chem_params%diffusion .and. .not. (viscous .or. surface_tension .or. heat_conduction)) then
@:ALLOCATE(flux_src_n(i)%vf(eqn_idx%E)%sf(...))
end if
end if
but the matching deallocation in s_finalize_rhs_module tests only the inner condition:
if (chem_params%diffusion .and. .not. (viscous .or. surface_tension .or. heat_conduction)) then
@:DEALLOCATE(flux_src_n(i)%vf(eqn_idx%E)%sf)
end if
chemistry is a compile-time Fypp constant while chem_params%diffusion is read from the namelist, so a non-chemistry build whose input sets chem_params%diffusion = T would reach the deallocation for a pointer that was never allocated.
Whether that is reachable depends on whether input validation rejects chem_params%diffusion in a non-chemistry build — I did not chase that down. Either way the two guards should match: the deallocation should carry the same chemistry condition its allocation does.
Found while adding Fourier heat conduction (#1906); unrelated to that change. The heat_conduction term in both conditions is from that PR, but the asymmetry predates it.
In
src/simulation/m_rhs.fppthe energy slot offlux_src_nis allocated for the chemistry-diffusion path insideif (chemistry):but the matching deallocation in
s_finalize_rhs_moduletests only the inner condition:chemistryis a compile-time Fypp constant whilechem_params%diffusionis read from the namelist, so a non-chemistry build whose input setschem_params%diffusion = Twould reach the deallocation for a pointer that was never allocated.Whether that is reachable depends on whether input validation rejects
chem_params%diffusionin a non-chemistry build — I did not chase that down. Either way the two guards should match: the deallocation should carry the samechemistrycondition its allocation does.Found while adding Fourier heat conduction (#1906); unrelated to that change. The
heat_conductionterm in both conditions is from that PR, but the asymmetry predates it.