Skip to content

Commit 464f346

Browse files
committed
Automatically choose diagnostic grid
If `netcdf_interpolation_num_points` is not provided, `ClimaAtmos` will to determine it automatically by matching approximately choosing the same number of points as the model grid. In this, we distribute points equally along the two horizontal dimensions.
1 parent 33d6032 commit 464f346

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
ClimaAtmos.jl Release Notes
22
============================
33

4+
v0.28.6
5+
-------
6+
7+
### Features
8+
9+
### Automatically determine diagnostic resolution based on model resolution
10+
11+
If `netcdf_interpolation_num_points` is not provided, `ClimaAtmos` will
12+
determine it automatically by matching approximately the same number of points
13+
as the model grid.
14+
415
v0.28.5
516
-------
617

src/callbacks/get_callbacks.jl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function get_diagnostics(
1111
(; dt, start_date) = sim_info
1212

1313
FT = Spaces.undertype(axes(Y.c))
14+
context = ClimaComms.context(axes(Y.c))
1415

1516
# We either get the diagnostics section in the YAML file, or we return an empty list
1617
# (which will result in an empty list being created by the map below)
@@ -40,9 +41,26 @@ function get_diagnostics(
4041
num_netcdf_points =
4142
tuple(parsed_args["netcdf_interpolation_num_points"]...)
4243
else
43-
# TODO: Once https://github.com/CliMA/ClimaCore.jl/pull/1567 is merged,
44-
# dispatch over the Grid type
45-
num_netcdf_points = (180, 90, 50)
44+
# Estimate the number of points we need to cover the entire domain
45+
# ncolumns is the number of local columns
46+
tot_num_columns =
47+
ClimaComms.nprocs(context) * Fields.ncolumns(axes(Y.c))
48+
if parsed_args["config"] == "plane"
49+
num1, num2 = tot_num_columns, 0
50+
elseif parsed_args["config"] == "sphere"
51+
num2 = round(Int, sqrt(tot_num_columns / 2))
52+
num1 = 2num2
53+
elseif parsed_args["config"] == "box"
54+
num2 = round(Int, sqrt(tot_num_columns))
55+
num1 = num2
56+
elseif parsed_args["config"] == "column"
57+
# We need at least two points horizontally because our column is
58+
# actually a box
59+
num1, num2 = 2, 2
60+
else
61+
error("Uncaught case")
62+
end
63+
num_netcdf_points = (num1, num2, Spaces.nlevels(axes(Y.c)))
4664
end
4765

4866
z_sampling_method =

0 commit comments

Comments
 (0)