Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add state NaN checker #970

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

add state NaN checker #970

wants to merge 4 commits into from

Conversation

juliasloan25
Copy link
Member

@juliasloan25 juliasloan25 commented Jan 2, 2025

Purpose

closes #969

Adds a function that quantitatively checks how many NaNs are present in the state, and displays this information to the user. This can be used to inspect sol.u[end] after a simulation has run, to see if any NaNs were produced at the end of the simulation.

If no NaNs are found, this information is logged in an info statement. If NaNs are found, this information is logged in a warn statement.

To-do

  • add function to recursively check NaNs in state
  • add tests
  • add optional mask argument
  • add monthly callback to longruns

@juliasloan25 juliasloan25 force-pushed the js/check-nans branch 2 times, most recently from 8a8e505 to 39a4e0e Compare January 3, 2025 23:30
Adds a function that quantitatively checks how many NaNs are present in the state, and displays this information to the user. This can be used to inspect sol.u[end] after a simulation has run, to see if any NaNs were produced at the end of the simulation.
If no NaNs are found, this information is logged in an info statement. If NaNs are found, this information is logged in a warn statement.
return nothing
end

function count_nans_state(state::ClimaCore.Fields.Field)
Copy link
Member

Choose a reason for hiding this comment

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

would we like to make this also take the land mask as a second argument?

Copy link
Member

@kmdeck kmdeck left a comment

Choose a reason for hiding this comment

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

do you want to also add this to our global runs in this PR? soil, soil canopy, soil canopy snow? perhaps we can add it as a callback to check every month e.g.

Comment on lines 513 to 524
for pn in propertynames(state)
state_new = getproperty(state, pn)
@info "Checking NaNs in $pn"
count_nans_state(state_new, mask)
end
Copy link
Member

@Sbozzolo Sbozzolo Jan 6, 2025

Choose a reason for hiding this comment

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

Maybe

any(isnan, state)

works

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.

Add a state NaN checker
3 participants