Skip to content

Commit 15f03a1

Browse files
committed
Use default_num_points when available
`ClimaDiagnostics` introduced a function to compute the default number of points for the NetCDFWriter. This commit uses this new function when available.
1 parent 0628793 commit 15f03a1

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

src/callbacks/get_callbacks.jl

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,7 @@ function get_diagnostics(parsed_args, atmos_model, Y, p, sim_info, output_dir)
3333
num_netcdf_points =
3434
tuple(parsed_args["netcdf_interpolation_num_points"]...)
3535
else
36-
# Estimate the number of points we need to cover the entire domain
37-
# ncolumns is the number of local columns
38-
tot_num_columns =
39-
ClimaComms.nprocs(context) * Fields.ncolumns(axes(Y.c))
40-
if parsed_args["config"] == "plane"
41-
num1, num2 = tot_num_columns, 0
42-
elseif parsed_args["config"] == "sphere"
43-
num2 = round(Int, sqrt(tot_num_columns / 2))
44-
num1 = 2num2
45-
elseif parsed_args["config"] == "box"
46-
num2 = round(Int, sqrt(tot_num_columns))
47-
num1 = num2
48-
elseif parsed_args["config"] == "column"
49-
# We need at least two points horizontally because our column is
50-
# actually a box
51-
num1, num2 = 2, 2
52-
else
53-
error("Uncaught case")
54-
end
55-
num_netcdf_points = (num1, num2, Spaces.nlevels(axes(Y.c)))
36+
num_netcdf_points = default_netcdf_points(axes(Y.c), parsed_args)
5637
end
5738

5839
z_sampling_method =

src/compat.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ClimaCore
22
import ClimaUtilities
33
import ClimaCore: Domains, Spaces, Topologies
4+
import ClimaDiagnostics
45
import RRTMGP
56

67
# To allow for backwards compatibility of ClimaCore:
@@ -96,3 +97,33 @@ else
9697
WallTimeInfo = ClimaUtilities.OnlineLogging.WallTimeInfo
9798
report_walltime = ClimaUtilities.OnlineLogging.report_walltime
9899
end
100+
101+
if pkgversion(ClimaDiagnostics) < v"0.2.13"
102+
function default_netcdf_points(space, parsed_args)
103+
# Estimate the number of points we need to cover the entire domain
104+
# ncolumns is the number of local columns
105+
tot_num_columns =
106+
ClimaComms.nprocs(ClimaComms.context(space)) *
107+
Fields.ncolumns(space)
108+
if parsed_args["config"] == "plane"
109+
num1, num2 = tot_num_columns, 0
110+
elseif parsed_args["config"] == "sphere"
111+
num2 = round(Int, sqrt(tot_num_columns / 2))
112+
num1 = 2num2
113+
elseif parsed_args["config"] == "box"
114+
num2 = round(Int, sqrt(tot_num_columns))
115+
num1 = num2
116+
elseif parsed_args["config"] == "column"
117+
# We need at least two points horizontally because our column is
118+
# actually a box
119+
num1, num2 = 2, 2
120+
else
121+
error("Uncaught case")
122+
end
123+
return (num1, num2, Spaces.nlevels(space))
124+
end
125+
else
126+
function default_netcdf_points(space, _)
127+
return ClimaDiagnostics.Writers.default_num_points(space)
128+
end
129+
end

0 commit comments

Comments
 (0)