Skip to content

Commit 59ba581

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 59ba581

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-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: 30 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,32 @@ 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)) * Fields.ncolumns(space)
107+
if parsed_args["config"] == "plane"
108+
num1, num2 = tot_num_columns, 0
109+
elseif parsed_args["config"] == "sphere"
110+
num2 = round(Int, sqrt(tot_num_columns / 2))
111+
num1 = 2num2
112+
elseif parsed_args["config"] == "box"
113+
num2 = round(Int, sqrt(tot_num_columns))
114+
num1 = num2
115+
elseif parsed_args["config"] == "column"
116+
# We need at least two points horizontally because our column is
117+
# actually a box
118+
num1, num2 = 2, 2
119+
else
120+
error("Uncaught case")
121+
end
122+
return (num1, num2, Spaces.nlevels(space))
123+
end
124+
else
125+
function default_netcdf_points(space, _)
126+
return ClimaDiagnostics.Writers.default_num_points(space)
127+
end
128+
end

0 commit comments

Comments
 (0)