Repository navigation
Avoid division by zero in cloud fraction calculation - #1526
Merged
Merged
Conversation
The original cloud fraction calculation (calc_cldfraction) can divide by zero when the saturation vapor pressure reaches or exceeds the atmospheric pressure, which can happen in the upper atmosphere. This can stops runs compiled with DEBUG=true. This commit makes two changes: 1) skip saturation calculations when the cloud condensate (qc+qi+qs) is below qcldmin, since the cloud fraction is zero there; 2) limit saturation vapor pressures over water and ice to 99% of the air pressure, as in the WSM6 microphysics scheme, to avoid division by zero and negative saturation mixing ratios.
dudhia
approved these changes
Oct 30, 2026
dudhia
left a comment
Collaborator
There was a problem hiding this comment.
Looks acceptable. The pressure limit alone would have solved the problem.
Collaborator
Author
|
Thank you for reviewing this PR, Jimy! Agreed, the pressure limit alone would solve it. However, the first change is not new logic. The |
mgduda
approved these changes
Nov 2, 2026
dudhia
approved these changes
Nov 4, 2026
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.
The original cloud fraction calculation (
calc_cldfraction) can produce a zero denominator when the saturation vapor pressure reaches the atmospheric pressure, which can happen in the upper atmosphere.For runs with a high model top (e.g., around 70 km or higher), this can cause the model to stop, especially when compiled with DEBUG=true. The error messages are:
This PR makes two changes:
qc+qi+qs) is belowqcldmin, since the cloud fraction is zero there;Thanks to Song-You Hong (@Songyou184) for identifying the issue.