Fix UW shallow convection mumin NaNs - #1485
Open
mathomp4 wants to merge 5 commits into
Open
Conversation
narnold1
approved these changes
Jul 27, 2026
narnold1
left a comment
Contributor
There was a problem hiding this comment.
Can confirm that this fixes the "compute_mumin" issue, and has minimal effect on science output (based on BOMEX SCM case and a short AMIP exp).
mathomp4
marked this pull request as ready for review
July 28, 2026 12:35
Member
Author
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.
This PR was from me asking GPT 5.6 Terra to look at the issues in #1466
It first saw an OpenMP issue that, while a bug, is not the cause of #1466. It then looked at
compute_mumin2and thought it could have odd behavior in some cases. So, I asked it for acompute_mumin3and this is what it came up with.I can say that ifx passed Debug with this.
This draft addresses the UW shallow convection
musolve that could produce NaNs in edge cases.Why this change
compute_mumin2uses a Newton iteration starting frommulow.exp(-mu**2)/erfc(mu)becomes numerically unsafe, so the old solve can trigger NaN behavior instead of converging cleanly.ufrc/cbmfconstraints.What changed
compute_mumin3, a bounded bisection solve on[mulow, 3].ufrclcllimit needs to be enforced.uwshcu.F90so threaded execution uses private workspace arrays.How
mumin3differs frommumin2mumin2: unbounded Newton iteration, faster when well-behaved, but it can overshoot into a numerically unsafe region and produce NaNs.mumin3: bounded bisection, slower but more conservative, and it stays inside a finite interval so it cannot chase the solve into the underflow/0-0 regime.muvalues.mumin3should return a finite bounded result instead of failing the limiter solve.Validation note
muinstead of failing the solve.Acknowledgement