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

Clear ALL_DIAGNOSTICS in define_diagnostics #977

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/diagnostics/define_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
define_diagnostics!(land_model)

Calls `add_diagnostic_variable!` for all available variables specializing the
compute function for `land_model`.
compute function for `land_model`. `ALL_DIAGNOSTICS` is emptied before adding diagnostic
variables.
"""
function define_diagnostics!(land_model)

# clear `ALL_DIAGNOSTICS` to prevent each call to `add_diagnostic_variable!` from warning
# about overwriting the same diagnostic variable
if length(ALL_DIAGNOSTICS) > 0
@warn "Clearing the `ALL_DIAGNOSTICS` dictionary"
empty!(ALL_DIAGNOSTICS)
end
### BucketModel ###

## Stored in p (diagnostics variables stored in the cache) ##
Expand Down
4 changes: 3 additions & 1 deletion test/diagnostics/diagnostics_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ prob = SciMLBase.ODEProblem(

# ClimaDiagnostics

ClimaLand.Diagnostics.define_diagnostics!(model)
@test_logs (:warn, "Clearing the `ALL_DIAGNOSTICS` dictionary") ClimaLand.Diagnostics.define_diagnostics!(
model,
)
diags = ["rn", "lhf"]

tmpdir = mktempdir(".")
Expand Down
Loading