Skip to content

Commit 3f51371

Browse files
committed
Use CommonSpaces to create spaces
1 parent 30f879c commit 3f51371

File tree

26 files changed

+950
-519
lines changed

26 files changed

+950
-519
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ weakdeps = ["CUDA", "MPI"]
406406

407407
[[deps.ClimaCore]]
408408
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LazyBroadcast", "LinearAlgebra", "MultiBroadcastFusion", "NVTX", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "StaticArrays", "Statistics", "UnrolledUtilities"]
409-
git-tree-sha1 = "ca717446978d2815b4fa23a62a2131861e44d1e8"
409+
git-tree-sha1 = "a2acae071e36c1c69c94a83d1fb74b25e8b0fde0"
410410
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
411-
version = "0.14.42"
411+
version = "0.14.43"
412412
weakdeps = ["CUDA", "Krylov"]
413413

414414
[deps.ClimaCore.extensions]
@@ -1864,7 +1864,7 @@ version = "2.5.5+0"
18641864
[[deps.OpenLibm_jll]]
18651865
deps = ["Artifacts", "Libdl"]
18661866
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
1867-
version = "0.8.5+0"
1867+
version = "0.8.1+4"
18681868

18691869
[[deps.OpenMPI_jll]]
18701870
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]

.buildkite/PrecompileCI/src/PrecompileCI.jl

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module PrecompileCI
33
using PrecompileTools, Logging
44
import ClimaAtmos as CA
55
import ClimaComms
6-
import ClimaCore: InputOutput, Meshes, Spaces, Quadratures
76
import ClimaParams
87

98
@compile_workload begin
@@ -14,34 +13,38 @@ import ClimaParams
1413
x_elem = y_elem = 2
1514
x_max = y_max = 1e8
1615
z_max = FT(30000.0)
17-
dz_bottom = FT(500) # other values?
18-
z_stretch = Meshes.HyperbolicTangentStretching(dz_bottom) # Meshes.Uniform()
19-
bubble = true # false
20-
parsed_args =
21-
Dict{String, Any}("topography" => "NoWarp", "topo_smoothing" => false)
22-
comms_ctx = ClimaComms.context(ClimaComms.CPUSingleThreaded())
23-
deep = false
24-
25-
# constants
26-
quad = Quadratures.GLL{4}()
16+
dz_bottom = FT(500)
17+
z_stretch = true
18+
bubble = true
19+
nh_poly = 3 # GLL{4} = nh_poly + 1
20+
# TODO: compile CUDA methods as well
21+
context = ClimaComms.context(ClimaComms.CPUSingleThreaded())
22+
topography = CA.NoTopography()
2723
params = CA.ClimaAtmosParameters(FT)
2824
radius = CA.Parameters.planet_radius(params)
2925

30-
# Sphere
31-
horz_mesh = CA.cubed_sphere_mesh(; radius, h_elem)
32-
h_space = CA.make_horizontal_space(horz_mesh, quad, comms_ctx, bubble)
33-
CA.make_hybrid_spaces(h_space, z_max, z_elem, z_stretch; parsed_args)
34-
35-
# box
36-
horizontal_mesh = CA.periodic_rectangle_mesh(; x_max, y_max, x_elem, y_elem)
37-
h_space = CA.make_horizontal_space(horizontal_mesh, quad, comms_ctx, bubble)
38-
# This is broken
39-
# CA.make_hybrid_spaces(h_space, z_max, z_elem, z_stretch; parsed_args)
40-
41-
# plane
42-
horizontal_mesh = CA.periodic_line_mesh(; x_max, x_elem)
43-
h_space = CA.make_horizontal_space(horizontal_mesh, quad, comms_ctx, bubble)
26+
sphere_grid = CA.SphereGrid(
27+
FT;
28+
context, radius, h_elem, nh_poly, z_elem, z_max, z_stretch,
29+
dz_bottom, bubble,
30+
topography,
31+
)
32+
box_grid = CA.BoxGrid(
33+
FT; context, x_elem, x_max, y_elem, y_max, z_elem, z_max, nh_poly,
34+
z_stretch, dz_bottom, bubble,
35+
periodic_x = true, periodic_y = true, topography,
36+
)
37+
plane_grid = CA.PlaneGrid(
38+
FT; context, x_elem, x_max, z_elem, z_max, nh_poly, z_stretch,
39+
dz_bottom, bubble, periodic_x = true,
40+
topography,
41+
)
42+
column_grid = CA.ColGrid(
43+
FT; context, z_elem, z_max, z_stretch, dz_bottom,
44+
)
45+
all_grids = (sphere_grid, box_grid, plane_grid, column_grid)
46+
foreach(CA.get_spaces, all_grids)
4447
end
4548
end
4649

47-
end # module Precompile
50+
end # module PrecompileCI

.buildkite/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ steps:
12811281
CLIMACOMMS_DEVICE: "CUDA"
12821282
CLIMA_NAME_CUDA_KERNELS_FROM_STACK_TRACE: "true"
12831283
agents:
1284-
slurm_mem: 24GB
1284+
slurm_mem: 28GB
12851285
slurm_gpus: 1
12861286

12871287
- group: "Flame graphs"

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ ArgParse = "1"
4444
Artifacts = "1"
4545
AtmosphericProfilesLibrary = "0.1.7"
4646
ClimaComms = "0.6.9"
47-
ClimaCore = "0.14.37"
47+
ClimaCore = "0.14.43"
4848
ClimaDiagnostics = "0.2.12"
4949
ClimaInterpolations = "0.1.0"
5050
ClimaParams = "1.0.2"
5151
ClimaTimeSteppers = "0.8.2"
52-
ClimaUtilities = "0.1.23"
52+
ClimaUtilities = "0.1.27"
5353
CloudMicrophysics = "0.28, 0.29"
5454
Dates = "1"
5555
ForwardDiff = "1"

calibration/experiments/gcm_driven_scm/helper_funcs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ CLIMADIAGNOSTICS_LES_NAME_MAP =
2323
"""Get z cell centers coordinates for CA run, given config. """
2424
function get_z_grid(atmos_config; z_max = nothing)
2525
params = CA.ClimaAtmosParameters(atmos_config)
26-
spaces =
27-
CA.get_spaces(atmos_config.parsed_args, params, atmos_config.comms_ctx)
26+
grid = CA.get_grid(atmos_config.parsed_args, params, atmos_config.comms_ctx)
27+
spaces = CA.get_spaces(grid, atmos_config.comms_ctx)
2828
coord = CA.Fields.coordinate_field(spaces.center_space)
2929
z_vec = convert(Vector{Float64}, parent(coord.z)[:])
3030
if !isnothing(z_max)

docs/src/api.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,21 @@ ClimaAtmos.InitialConditions.Bomex
4343
ClimaAtmos.InitialConditions.Soares
4444
```
4545

46-
### Helper
46+
## Helper
4747

4848
```@docs
4949
ClimaAtmos.InitialConditions.ColumnInterpolatableField
5050
```
5151

52+
## Grids
53+
54+
```@docs
55+
ClimaAtmos.ColGrid
56+
ClimaAtmos.SphereGrid
57+
ClimaAtmos.PlaneGrid
58+
ClimaAtmos.BoxGrid
59+
```
60+
5261
## Jacobian
5362

5463
```@docs
@@ -68,6 +77,8 @@ ClimaAtmos.ScharTopography
6877
ClimaAtmos.EarthTopography
6978
ClimaAtmos.DCMIP200Topography
7079
ClimaAtmos.Hughes2023Topography
80+
ClimaAtmos.SLEVEWarp
81+
ClimaAtmos.LinearWarp
7182
```
7283

7384
### Internals

post_processing/ci_plots.jl

Lines changed: 109 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,6 @@ make_plots_generic(
437437
simulation_path,
438438
vars,
439439
time = LAST_SNAP,
440-
x = 0.0, # Our columns are still 3D objects...
441-
y = 0.0,
442440
more_kwargs = YLINEARSCALE,
443441
)
444442
```
@@ -453,8 +451,6 @@ make_plots_generic(
453451
simulation_path,
454452
vars,
455453
time = LAST_SNAP,
456-
x = 0.0, # Our columns are still 3D objects...
457-
y = 0.0,
458454
more_kwargs = YLINEARSCALE,
459455
)
460456
```
@@ -589,14 +585,23 @@ ColumnPlots = Union{
589585
function make_plots(::ColumnPlots, output_paths::Vector{<:AbstractString})
590586
simdirs = SimDir.(output_paths)
591587
short_names = ["ta", "wa"]
592-
vars = map_comparison(get, simdirs, short_names)
588+
vars = map_comparison(simdirs, short_names) do simdir, short_name
589+
var = get(simdir; short_name)
590+
# For vertical-only (FiniteDifferenceGrid) spaces, the data may have
591+
# extra singleton dimensions. Check and squeeze if needed.
592+
if haskey(var.dims, "x") && length(var.dims["x"]) == 1
593+
var = slice(var; x = var.dims["x"][1])
594+
end
595+
if haskey(var.dims, "y") && length(var.dims["y"]) == 1
596+
var = slice(var; y = var.dims["y"][1])
597+
end
598+
return var
599+
end
593600

594601
make_plots_generic(
595602
output_paths,
596603
vars,
597604
time = LAST_SNAP,
598-
x = 0.0, # Our columns are still 3D objects...
599-
y = 0.0,
600605
MAX_NUM_COLS = length(simdirs),
601606
more_kwargs = YLINEARSCALE,
602607
)
@@ -644,7 +649,7 @@ function make_plots(
644649
end
645650

646651
vars = [
647-
slice(get(simdir; short_name), x = 0.0, y = 0.0) for
652+
get(simdir; short_name) for
648653
short_name in short_names
649654
]
650655

@@ -689,7 +694,7 @@ function make_plots(
689694
surface_precip = read_var(simdir.variable_paths["pr"]["inst"]["10s"])
690695
viz.line_plot1D!(
691696
fig,
692-
slice(surface_precip, x = 0.0, y = 0.0);
697+
surface_precip;
693698
p_loc = [pr_row, 1:3],
694699
)
695700

@@ -1371,6 +1376,12 @@ EDMFBoxPlots = Union{
13711376
Val{:diagnostic_edmfx_dycoms_rf01_box},
13721377
Val{:diagnostic_edmfx_trmm_box_0M},
13731378
Val{:diagnostic_edmfx_dycoms_rf01_explicit_box},
1379+
Val{:prognostic_edmfx_bomex_box},
1380+
Val{:rcemipii_box_diagnostic_edmfx},
1381+
Val{:diagnostic_edmfx_trmm_stretched_box},
1382+
}
1383+
1384+
EDMFColumnPlots = Union{
13741385
Val{:prognostic_edmfx_adv_test_column},
13751386
Val{:prognostic_edmfx_gabls_column},
13761387
Val{:prognostic_edmfx_gabls_column_sparse_autodiff},
@@ -1386,13 +1397,10 @@ EDMFBoxPlots = Union{
13861397
Val{:prognostic_edmfx_simpleplume_column},
13871398
Val{:prognostic_edmfx_gcmdriven_column},
13881399
Val{:prognostic_edmfx_tv_era5driven_column},
1389-
Val{:prognostic_edmfx_bomex_box},
1390-
Val{:rcemipii_box_diagnostic_edmfx},
13911400
Val{:prognostic_edmfx_soares_column},
1392-
Val{:diagnostic_edmfx_trmm_stretched_box},
13931401
}
13941402

1395-
EDMFBoxPlotsWithPrecip = Union{
1403+
EDMFColumnPlotsWithPrecip = Union{
13961404
Val{:prognostic_edmfx_rico_column},
13971405
Val{:prognostic_edmfx_rico_implicit_column},
13981406
Val{:prognostic_edmfx_rico_column_2M},
@@ -1485,14 +1493,99 @@ end
14851493
function make_plots(
14861494
sim_type::Union{
14871495
EDMFBoxPlots,
1488-
EDMFBoxPlotsWithPrecip,
14891496
DiagEDMFBoxPlotsWithPrecip,
14901497
},
14911498
output_paths::Vector{<:AbstractString},
14921499
)
14931500
simdirs = SimDir.(output_paths)
14941501

1495-
if sim_type isa EDMFBoxPlotsWithPrecip
1502+
if sim_type isa DiagEDMFBoxPlotsWithPrecip
1503+
precip_names = ("husra", "hussn", "husraup", "hussnup")
1504+
else
1505+
precip_names = ()
1506+
end
1507+
1508+
short_names = [
1509+
"wa",
1510+
"waup",
1511+
"ta",
1512+
"taup",
1513+
"hus",
1514+
"husup",
1515+
"arup",
1516+
"tke",
1517+
"ua",
1518+
"thetaa",
1519+
"thetaaup",
1520+
"ha",
1521+
"haup",
1522+
"hur",
1523+
"hurup",
1524+
"lmix",
1525+
"cl",
1526+
"clw",
1527+
"clwup",
1528+
"cli",
1529+
"cliup",
1530+
precip_names...,
1531+
]
1532+
reduction = "inst"
1533+
1534+
available_periods = ClimaAnalysis.available_periods(
1535+
simdirs[1];
1536+
short_name = short_names[1],
1537+
reduction,
1538+
)
1539+
# choose the shortest available period
1540+
available_periods = collect(available_periods) # ensure vector for indexing
1541+
period = available_periods[argmin(CA.time_to_seconds.(available_periods))]
1542+
1543+
short_name_tuples = pair_edmf_names(short_names)
1544+
var_groups_zt =
1545+
map_comparison(simdirs, short_name_tuples) do simdir, name_tuple
1546+
return [
1547+
slice(
1548+
get(simdir; short_name, reduction, period),
1549+
x = 0.0,
1550+
y = 0.0,
1551+
) for short_name in name_tuple
1552+
]
1553+
end
1554+
1555+
var_groups_z = [
1556+
([slice(v, time = LAST_SNAP) for v in group]...,) for
1557+
group in var_groups_zt
1558+
]
1559+
1560+
tmp_file = make_plots_generic(
1561+
output_paths,
1562+
output_name = "tmp",
1563+
var_groups_z;
1564+
plot_fn = plot_edmf_vert_profile!,
1565+
MAX_NUM_COLS = 2,
1566+
MAX_NUM_ROWS = 4,
1567+
)
1568+
1569+
make_plots_generic(
1570+
output_paths,
1571+
vcat(var_groups_zt...),
1572+
plot_fn = plot_parsed_attribute_title!,
1573+
summary_files = [tmp_file],
1574+
MAX_NUM_COLS = 2,
1575+
MAX_NUM_ROWS = 4,
1576+
)
1577+
end
1578+
1579+
function make_plots(
1580+
sim_type::Union{
1581+
EDMFColumnPlots,
1582+
EDMFColumnPlotsWithPrecip,
1583+
},
1584+
output_paths::Vector{<:AbstractString},
1585+
)
1586+
simdirs = SimDir.(output_paths)
1587+
1588+
if sim_type isa EDMFColumnPlotsWithPrecip
14961589
if sim_type isa Val{:prognostic_edmfx_rico_column_2M}
14971590
precip_names = (
14981591
"husra",
@@ -1512,8 +1605,6 @@ function make_plots(
15121605
precip_names =
15131606
("husra", "hussn", "husraup", "hussnup", "husraen", "hussnen")
15141607
end
1515-
elseif sim_type isa DiagEDMFBoxPlotsWithPrecip
1516-
precip_names = ("husra", "hussn", "husraup", "hussnup")
15171608
else
15181609
precip_names = ()
15191610
end
@@ -1557,11 +1648,7 @@ function make_plots(
15571648
var_groups_zt =
15581649
map_comparison(simdirs, short_name_tuples) do simdir, name_tuple
15591650
return [
1560-
slice(
1561-
get(simdir; short_name, reduction, period),
1562-
x = 0.0,
1563-
y = 0.0,
1564-
) for short_name in name_tuple
1651+
get(simdir; short_name, reduction, period) for short_name in name_tuple
15651652
]
15661653
end
15671654

0 commit comments

Comments
 (0)