Skip to content

Use default_num_points when available #3774

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 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
20 changes: 10 additions & 10 deletions .buildkite/Manifest-v1.11.toml
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ version = "0.30.1"

[[deps.ClimaComms]]
deps = ["Adapt", "Logging", "LoggingExtras"]
git-tree-sha1 = "40ad44466dfe0092e18c04bc02c849fe8e095d30"
git-tree-sha1 = "2a96bdd5339bdcd903867a46d1f00110f7b890cc"
uuid = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
version = "0.6.6"
version = "0.6.7"
weakdeps = ["CUDA", "MPI"]

[deps.ClimaComms.extensions]
Expand Down Expand Up @@ -399,9 +399,9 @@ version = "0.3.18"

[[deps.ClimaDiagnostics]]
deps = ["Accessors", "ClimaComms", "ClimaCore", "ClimaUtilities", "Dates", "NCDatasets", "OrderedCollections", "SciMLBase"]
git-tree-sha1 = "ec2ee9e870e51a9d8b76decf941f6c9d3d3b1365"
git-tree-sha1 = "e931fd003740b97fa525246a6ea7c14143d12051"
uuid = "1ecacbb8-0713-4841-9a07-eb5aa8a2d53f"
version = "0.2.13"
version = "0.2.14"

[[deps.ClimaParams]]
deps = ["TOML"]
Expand All @@ -417,9 +417,9 @@ version = "0.1.1"

[[deps.ClimaTimeSteppers]]
deps = ["ClimaComms", "DataStructures", "DiffEqBase", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
git-tree-sha1 = "f71d6c31fdfeaa66516ccf904a916e99904e5078"
git-tree-sha1 = "23c8346606e165aa8805f25063f24e39bd8e148d"
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
version = "0.8.4"
version = "0.8.5"
weakdeps = ["BenchmarkTools", "CUDA", "OrderedCollections", "PrettyTables", "StatsBase"]

[deps.ClimaTimeSteppers.extensions]
Expand Down Expand Up @@ -2153,9 +2153,9 @@ version = "0.1.0"

[[deps.SciMLBase]]
deps = ["ADTypes", "Accessors", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "Moshi", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface"]
git-tree-sha1 = "44397dee277159f224492bcf99c442d2a907c6f5"
git-tree-sha1 = "846e89af4ec4ba471d3050a70405978cbdf70681"
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
version = "2.91.0"
version = "2.91.1"

[deps.SciMLBase.extensions]
SciMLBaseChainRulesCoreExt = "ChainRulesCore"
Expand Down Expand Up @@ -2505,9 +2505,9 @@ version = "1.0.2"

[[deps.Thermodynamics]]
deps = ["DocStringExtensions", "KernelAbstractions", "Random", "RootSolvers"]
git-tree-sha1 = "efe74e0344fd7fb68b831316055290d80a62d9c1"
git-tree-sha1 = "f708faaf347760e9dcd82beb1a9455c86bdf9911"
uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
version = "0.12.11"
version = "0.12.12"
weakdeps = ["ClimaParams"]

[deps.Thermodynamics.extensions]
Expand Down
21 changes: 1 addition & 20 deletions src/callbacks/get_callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,7 @@ function get_diagnostics(parsed_args, atmos_model, Y, p, sim_info, output_dir)
num_netcdf_points =
tuple(parsed_args["netcdf_interpolation_num_points"]...)
else
# Estimate the number of points we need to cover the entire domain
# ncolumns is the number of local columns
tot_num_columns =
ClimaComms.nprocs(context) * Fields.ncolumns(axes(Y.c))
if parsed_args["config"] == "plane"
num1, num2 = tot_num_columns, 0
elseif parsed_args["config"] == "sphere"
num2 = round(Int, sqrt(tot_num_columns / 2))
num1 = 2num2
elseif parsed_args["config"] == "box"
num2 = round(Int, sqrt(tot_num_columns))
num1 = num2
elseif parsed_args["config"] == "column"
# We need at least two points horizontally because our column is
# actually a box
num1, num2 = 2, 2
else
error("Uncaught case")
end
num_netcdf_points = (num1, num2, Spaces.nlevels(axes(Y.c)))
num_netcdf_points = default_netcdf_points(axes(Y.c), parsed_args)
end

z_sampling_method =
Expand Down
31 changes: 31 additions & 0 deletions src/compat.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ClimaCore
import ClimaUtilities
import ClimaCore: Domains, Spaces, Topologies
import ClimaDiagnostics
import RRTMGP

# To allow for backwards compatibility of ClimaCore:
Expand Down Expand Up @@ -96,3 +97,33 @@ else
WallTimeInfo = ClimaUtilities.OnlineLogging.WallTimeInfo
report_walltime = ClimaUtilities.OnlineLogging.report_walltime
end

if pkgversion(ClimaDiagnostics) < v"0.2.14"
function default_netcdf_points(space, parsed_args)
# Estimate the number of points we need to cover the entire domain
# ncolumns is the number of local columns
tot_num_columns =
ClimaComms.nprocs(ClimaComms.context(space)) *
Fields.ncolumns(space)
if parsed_args["config"] == "plane"
num1, num2 = tot_num_columns, 0
elseif parsed_args["config"] == "sphere"
num2 = round(Int, sqrt(tot_num_columns / 2))
num1 = 2num2
elseif parsed_args["config"] == "box"
num2 = round(Int, sqrt(tot_num_columns))
num1 = num2
elseif parsed_args["config"] == "column"
# We need at least two points horizontally because our column is
# actually a box
num1, num2 = 2, 2
else
error("Uncaught case")
end
return (num1, num2, Spaces.nlevels(space))
end
else
function default_netcdf_points(space, _)
return ClimaDiagnostics.Writers.default_num_points(space)
end
end
Comment on lines +101 to +129
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Missing imports for Fields and ClimaComms

The function uses ClimaComms and Fields modules but there are no corresponding import statements visible in this file.


🏁 Script executed:

#!/bin/bash
# Check if Fields and ClimaComms are imported elsewhere
grep -r "import.*Fields" --include="*.jl" .
grep -r "import.*ClimaComms" --include="*.jl" .

Length of output: 5776


Let’s inspect the top of src/compat.jl for any import/using statements:


🏁 Script executed:

#!/bin/bash
grep -n '^import' src/compat.jl
grep -n '^using' src/compat.jl

Length of output: 199


Add missing imports for Fields and ClimaComms

The default_netcdf_points function calls Fields.ncolumns and ClimaComms.nprocs/ClimaComms.context, but neither module is imported in src/compat.jl.

• File: src/compat.jl – at the top, alongside the other import statements
• Add:

 import ClimaCore
+import ClimaCore: Fields
+import ClimaComms
 import ClimaUtilities
 import ClimaCore: Domains, Spaces, Topologies
 import ClimaDiagnostics
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if pkgversion(ClimaDiagnostics) < v"0.2.14"
function default_netcdf_points(space, parsed_args)
# Estimate the number of points we need to cover the entire domain
# ncolumns is the number of local columns
tot_num_columns =
ClimaComms.nprocs(ClimaComms.context(space)) *
Fields.ncolumns(space)
if parsed_args["config"] == "plane"
num1, num2 = tot_num_columns, 0
elseif parsed_args["config"] == "sphere"
num2 = round(Int, sqrt(tot_num_columns / 2))
num1 = 2num2
elseif parsed_args["config"] == "box"
num2 = round(Int, sqrt(tot_num_columns))
num1 = num2
elseif parsed_args["config"] == "column"
# We need at least two points horizontally because our column is
# actually a box
num1, num2 = 2, 2
else
error("Uncaught case")
end
return (num1, num2, Spaces.nlevels(space))
end
else
function default_netcdf_points(space, _)
return ClimaDiagnostics.Writers.default_num_points(space)
end
end
# At the top of src/compat.jl, alongside the other imports:
import ClimaCore
+import ClimaCore: Fields
+import ClimaComms
import ClimaUtilities
import ClimaCore: Domains, Spaces, Topologies
import ClimaDiagnostics
🤖 Prompt for AI Agents
In src/compat.jl around lines 101 to 129, the function default_netcdf_points
uses the Fields and ClimaComms modules but these are not imported in the file.
To fix this, add import statements for Fields and ClimaComms at the top of
src/compat.jl alongside the existing imports. This will ensure the function can
access Fields.ncolumns and ClimaComms.nprocs/context without errors.

Loading