chem: add scalar guards for p_hcl and p_ch3cl in add_anthropogenics t… - #2387
Open
AlphaBetaGammaChi wants to merge 3 commits into
Open
Conversation
…o prevent SIGSEGV in non-halogen mechanisms
Collaborator
|
The regression results: |
…from uninitialized loop indices In WRF 4.8, area=(dx/mapfac_mx(i,j))*(dy/mapfac_my(i,j)) was placed at subroutine entry before loop indices i and j are initialized. On modern compilers (e.g. GCC 13 on aarch64/x86_64 with -O3), this causes an immediate SIGSEGV out-of-bounds memory access. Restores the safe area=dx*dx calculation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a runtime SIGSEGV crash during
emissions_driverwhen running chemical mechanisms that do not include anthropogenic chlorine (such as CRI-MECH withemiss_opt = 19oremiss_opt = 20).Cause
In
chem/module_emissions_anthropogenics.F, assignments forp_hclandp_ch3clwere placed in the generic anthropogenic emissions loop withoutparam_first_scalarbounds checks.For mechanisms where
e_hclande_ch3clare not present in the package, referencingchem(..., p_hcl)andemis_ant(..., p_e_hcl)causes an invalid memory reference and crashes on timestep 1: