Skip to content

Commit 46654da

Browse files
committed
Use CommonSpaces to create spaces
1 parent b298354 commit 46654da

File tree

25 files changed

+872
-436
lines changed

25 files changed

+872
-436
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+2"
18681868

18691869
[[deps.OpenMPI_jll]]
18701870
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]
@@ -2210,9 +2210,9 @@ version = "0.5.1+0"
22102210

22112211
[[deps.RootSolvers]]
22122212
deps = ["ForwardDiff", "Printf"]
2213-
git-tree-sha1 = "75b130d104fb3d9d39a5c784fad23aebc7d7d956"
2213+
git-tree-sha1 = "769388dbf7656e70f6ee250f35bb6cbca8f43203"
22142214
uuid = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
2215-
version = "1.0.0"
2215+
version = "0.4.6"
22162216

22172217
[[deps.RoundingEmulator]]
22182218
git-tree-sha1 = "40b9edad2e5287e05bd413a38f61a8ff55b9557b"

.buildkite/PrecompileCI/src/PrecompileCI.jl

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,39 @@ import ClimaParams
1515
x_max = y_max = 1e8
1616
z_max = FT(30000.0)
1717
dz_bottom = FT(500) # other values?
18-
z_stretch = Meshes.HyperbolicTangentStretching(dz_bottom) # Meshes.Uniform()
18+
z_stretch = true # Meshes.Uniform()
1919
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}()
20+
nh_poly = 3 # GLL{4} = nh_poly + 1
21+
context = ClimaComms.context(ClimaComms.CPUSingleThreaded())
22+
deep_atmosphere = false
23+
topography = CA.NoTopography()
2724
params = CA.ClimaAtmosParameters(FT)
2825
radius = CA.Parameters.planet_radius(params)
2926

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)
27+
sphere_grid = CA.SphereGrid(
28+
FT;
29+
context, radius, h_elem, nh_poly, z_elem, z_max, z_stretch,
30+
dz_bottom, bubble, deep_atmosphere,
31+
topography,
32+
)
33+
box_grid = CA.BoxGrid(
34+
FT; context, x_elem, x_max, y_elem, y_max, z_elem, z_max, nh_poly,
35+
z_stretch, dz_bottom, bubble, deep_atmosphere,
36+
periodic_x = true, periodic_y = true, topography,
37+
)
38+
plane_grid = CA.PlaneGrid(
39+
FT; context, x_elem, x_max, z_elem, z_max, nh_poly, z_stretch,
40+
dz_bottom, bubble, deep_atmosphere, periodic_x = true,
41+
topography,
42+
)
43+
column_grid = CA.ColGrid(
44+
FT; context, z_elem, z_max, z_stretch, dz_bottom,
45+
)
4046

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)
47+
for grid in [sphere_grid, box_grid, plane_grid, column_grid]
48+
CA.get_spaces(grid, context)
49+
end
4450
end
4551
end
4652

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

.buildkite/ci_driver.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ redirect_stderr(IOContext(stderr, :stacktrace_types_limited => Ref(false)))
99
# To load in the precompiled methods, run `using PrecompileCI` before loading ClimaAtmos.
1010
# To see what methods are precompiled, open julia: `julia --project=.buildkite/PrecompileCI`
1111
# and run `using PrecompileTools; PrecompileTools.verbose[] = true; include(".buildkite/PrecompileCI/src/PrecompileCI.jl")`
12-
haskey(ENV, "CI") && (using PrecompileCI)
12+
# haskey(ENV, "CI") && (using PrecompileCI)
1313

1414
import ClimaComms
1515
ClimaComms.@import_required_backends

.buildkite/pipeline.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,17 @@ steps:
2828
- julia --check-bounds=yes -e 'using TOML; @assert TOML.parsefile(".buildkite/Manifest-v1.11.toml")["deps"]["ClimaAtmos"][1]["path"] == ".."'
2929

3030
- echo "--- Instantiate .buildkite"
31-
- "julia --project=.buildkite -e 'using Pkg; Pkg.instantiate(;verbose=true); Pkg.precompile(;strict=true); using CUDA; CUDA.precompile_runtime(); Pkg.status()'"
32-
31+
- julia --project=.buildkite -e '
32+
33+
using Pkg;
34+
Pkg.Registry.update();
35+
Pkg.add(PackageSpec(name="ClimaCore", url="https://github.com/CliMA/ClimaCore.jl", rev="ne/fd_grid"));
36+
Pkg.add(PackageSpec(name="ClimaUtilities", url="https://github.com/CliMA/ClimaUtilities.jl", rev="main"));
37+
Pkg.instantiate();
38+
Pkg.precompile(; strict=true);
39+
using CUDA; CUDA.precompile_runtime();
40+
Pkg.status()
41+
'
3342
agents:
3443
slurm_cpus_per_task: 8
3544
slurm_gpus: 1

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ArgParse = "1"
4444
Artifacts = "1"
4545
AtmosphericProfilesLibrary = "0.1.7"
4646
ClimaComms = "0.6.9"
47-
ClimaCore = "0.14.37"
47+
ClimaCore = "0.14.42"
4848
ClimaDiagnostics = "0.2.12"
4949
ClimaInterpolations = "0.1.0"
5050
ClimaParams = "1.0.2"

calibration/experiments/gcm_driven_scm/helper_funcs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ 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+
# TODO: Update this to use the new get_spaces function
2627
spaces =
2728
CA.get_spaces(atmos_config.parsed_args, params, atmos_config.comms_ctx)
2829
coord = CA.Fields.coordinate_field(spaces.center_space)

docs/src/api.md

Lines changed: 10 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

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

src/ClimaAtmos.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ import .Diagnostics as CAD
156156
include(joinpath("callbacks", "get_callbacks.jl"))
157157

158158
include(joinpath("simulation", "AtmosSimulations.jl"))
159+
include(joinpath("simulation", "grids.jl"))
159160

160161
include(joinpath("solver", "model_getters.jl")) # high-level (using parsed_args) model getters
161162
include(joinpath("solver", "type_getters.jl"))

src/cache/temporary_quantities.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function temporary_quantities(Y, atmos)
2828
center_space, face_space = axes(Y.c), axes(Y.f)
2929

3030
FT = Spaces.undertype(center_space)
31-
CTh = CTh_vector_type(Y.c)
3231
uvw_vec = UVW(FT(0), FT(0), FT(0))
3332
return (;
3433
ᶠtemp_scalar = Fields.Field(FT, face_space), # ᶠp, ᶠρK_h
@@ -81,7 +80,7 @@ function temporary_quantities(Y, atmos)
8180
# TODO: Remove this hack
8281
sfc_temp_C3 = Fields.Field(C3{FT}, Spaces.level(face_space, half)), # ρ_flux_χ
8382
# Implicit solver cache:
84-
∂ᶜK_∂ᶜuₕ = similar(Y.c, DiagonalMatrixRow{Adjoint{FT, CTh{FT}}}),
83+
∂ᶜK_∂ᶜuₕ = similar(Y.c, DiagonalMatrixRow{Adjoint{FT, CT12{FT}}}),
8584
∂ᶜK_∂ᶠu₃ = similar(Y.c, BidiagonalMatrixRow{Adjoint{FT, CT3{FT}}}),
8685
ᶠp_grad_matrix = similar(Y.f, BidiagonalMatrixRow{C3{FT}}),
8786
ᶠbidiagonal_matrix_ct3 = similar(Y.f, BidiagonalMatrixRow{CT3{FT}}),

0 commit comments

Comments
 (0)