Skip to content

Fix bugs that cause model crash when CAM radiation is activated#1391

Open
smileMchen wants to merge 1 commit intoMPAS-Dev:developfrom
smileMchen:camrad
Open

Fix bugs that cause model crash when CAM radiation is activated#1391
smileMchen wants to merge 1 commit intoMPAS-Dev:developfrom
smileMchen:camrad

Conversation

@smileMchen
Copy link

@smileMchen smileMchen commented Jan 5, 2026

This PR fixes the bugs that cause model crash when CAM radiation scheme is activated.

Several arrays are allocated only when RRTMG radiation scheme is activated. However, these arrays are used when CAM radiation scheme is turned on, leading to segmentation fault and subsequent model crash. This PR fixes this issue by reallocating these arrays based on specific schemes.

Tests have been conducted to confirm that changes in this PR fix the model crash when using CAM radiation scheme.

@mgduda
Copy link
Contributor

mgduda commented Mar 23, 2026

@smileMchen I've tested the changes in this PR, and I can confirm that they fix crashes when using CAM radiation. Could you add a bit more detail to the commit message to explain more specifically what the problem was, and how the changes in the commit fix that problem?

For our commit messages, we usually follow the format: one-line summary (80 chars or less), a blank line, then one or more paragraphs (wrapped at 80 chars) describing the changes in the commit in detail.

If you have any questions at all, please don't hesitate to ask!

@smileMchen
Copy link
Author

@mgduda

Michael,

I have updated the commit message. Thanks.

Ming

@mgduda
Copy link
Contributor

mgduda commented Mar 23, 2026

Thanks for the updated PR description. Since we preserve the commit history when merging PRs, I think it would be good to update the commit message (i.e., to amend the message in commit ef0b686). If you don't object, I can amend ef0b686 with a commit message based on the PR description. Then we should be all set.

@smileMchen
Copy link
Author

Hi Michael, Please go ahead. Thanks.

This commit fixes bugs that cause MPAS-Atmosphere to crash when the CAM
radiation scheme is activated.

Several arrays are allocated only when the RRTMG radiation scheme is activated.
However, these arrays were being used when the CAM radiation scheme is turned
on, leading to a segmentation fault. This commit fixes this issue by
conditionally using these arrays only when the RRTMG scheme has been selected
at runtime.
Copy link
Contributor

@mgduda mgduda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix in this PR looks good to me, and I have just a few very minor clean-up requests. If it would be easier, I can just amend the commit in this PR to address these.


!copy local arrays to MPAS grid:
call radiation_sw_to_MPAS(diag_physics,tend_physics,its,ite)
!mchen call radiation_sw_to_MPAS(diag_physics,tend_physics,its,ite)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be fine to just remove this commented-out line.


radiation_sw_select: select case (trim(radt_sw_scheme))
case("rrtmg_sw")
do i = its,ite
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for consistency, should we indent this block using three spaces?

do i = its,ite
swddir_p(i,j) = 0.0_RKIND
swddni_p(i,j) = 0.0_RKIND
swddif_p(i,j) = 0.0_RKIND
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we indent the body of these loops by three spaces for consistency?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants