Skip to content

fixed scalarIndexing performance issue #1215

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

Open
wants to merge 4 commits 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
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ function make_drivers(site_ID, setup, config, params, context)
end
end
if length(missing_drivers) != 0
error("Driver data missing for columns: $([missing_drivers[i] * " " for
i in 1:length(missing_drivers)]...)")
error(
"Driver data missing for columns: $([missing_drivers[i] * " " for
i in 1:length(missing_drivers)]...)",
)
end

thermo_params = LP.thermodynamic_parameters(earth_param_set)
Expand Down
19 changes: 10 additions & 9 deletions src/shared_utilities/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -593,22 +593,23 @@ function count_nans_state(
mask = nothing,
verbose = false,
)
# Note: this code uses `parent`; this pattern should not be replicated
num_nans = 0
ClimaComms.allowscalar(ClimaComms.device()) do
num_nans =
isnothing(mask) ? Int(sum(isnan.(parent(state)))) :
Int(sum(isnan.(parent(state)) .* parent(mask)))
if isnothing(mask)
num_nans = count(isnan, parent(state))
else
num_nans = mapreduce(
(s, m) -> m != 0 && isnan(s),
Base.add_sum,
parent(state),
parent(mask),
)
end
if isapprox(num_nans, 0)
if num_nans == 0
verbose && @info "No NaNs found"
else
@warn "$num_nans NaNs found"
end
return nothing
end


"""
NaNCheckCallback(nancheck_frequency::Union{AbstractFloat, Dates.Period},
start_date, dt)
Expand Down
Loading