Skip to content

Commit 31bf02d

Browse files
committed
address most comments
1 parent 3d809fd commit 31bf02d

File tree

13 files changed

+177
-284
lines changed

13 files changed

+177
-284
lines changed

.buildkite/PrecompileCI/src/PrecompileCI.jl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,26 @@ import ClimaParams
2525

2626
sphere_grid = CA.SphereGrid(
2727
FT;
28-
context, radius, h_elem, nh_poly, z_elem, z_max, z_stretch,
29-
dz_bottom, bubble,
30-
topography,
28+
context,
29+
radius, h_elem, nh_poly,
30+
z_elem, z_max, z_stretch, dz_bottom,
31+
bubble, topography,
3132
)
3233
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,
34+
FT;
35+
context,
36+
x_elem, x_max, y_elem, y_max, nh_poly, periodic_x = true, periodic_y = true,
37+
z_elem, z_max, z_stretch, dz_bottom,
38+
bubble, topography,
3639
)
3740
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+
FT;
42+
context,
43+
x_elem, x_max, nh_poly, periodic_x = true,
44+
z_elem, z_max, z_stretch, dz_bottom,
45+
bubble, topography,
4146
)
42-
column_grid = CA.ColGrid(
47+
column_grid = CA.ColumnGrid(
4348
FT; context, z_elem, z_max, z_stretch, dz_bottom,
4449
)
4550
all_grids = (sphere_grid, box_grid, plane_grid, column_grid)

docs/src/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ClimaAtmos.InitialConditions.ColumnInterpolatableField
5252
## Grids
5353

5454
```@docs
55-
ClimaAtmos.ColGrid
55+
ClimaAtmos.ColumnGrid
5656
ClimaAtmos.SphereGrid
5757
ClimaAtmos.PlaneGrid
5858
ClimaAtmos.BoxGrid

examples/topography_spectra.jl

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,57 @@ import ClimaCoreSpectra: power_spectrum_2d
1414

1515
const AA = AtmosArtifacts
1616

17+
using ClimaCore:
18+
Geometry, Domains, Meshes, Topologies, Spaces, Grids, Hypsography, Fields
19+
using ClimaComms
20+
using ClimaUtilities: SpaceVaryingInputs.SpaceVaryingInput
1721

18-
function mask(x::FT) where {FT}
19-
return x * FT(x > 0)
22+
# h_elem is the number of elements per side of every panel (6 panels in total)
23+
function cubed_sphere_mesh(; radius, h_elem)
24+
domain = Domains.SphereDomain(radius)
25+
return Meshes.EquiangularCubedSphere(domain, h_elem)
2026
end
2127

28+
function make_horizontal_space(
29+
mesh,
30+
quad,
31+
comms_ctx::ClimaComms.SingletonCommsContext,
32+
bubble,
33+
)
34+
35+
space = if mesh isa Meshes.AbstractMesh1D
36+
topology = Topologies.IntervalTopology(comms_ctx, mesh)
37+
Spaces.SpectralElementSpace1D(topology, quad)
38+
elseif mesh isa Meshes.AbstractMesh2D
39+
topology = Topologies.Topology2D(
40+
comms_ctx,
41+
mesh,
42+
Topologies.spacefillingcurve(mesh),
43+
)
44+
Spaces.SpectralElementSpace2D(topology, quad; enable_bubble = bubble)
45+
end
46+
return space
47+
end
48+
49+
function make_horizontal_space(mesh, quad, comms_ctx, bubble)
50+
if mesh isa Meshes.AbstractMesh1D
51+
error("Distributed mode does not work with 1D horizontal spaces.")
52+
elseif mesh isa Meshes.AbstractMesh2D
53+
topology = Topologies.DistributedTopology2D(
54+
comms_ctx,
55+
mesh,
56+
Topologies.spacefillingcurve(mesh),
57+
)
58+
space = Spaces.SpectralElementSpace2D(
59+
topology,
60+
quad;
61+
enable_bubble = bubble,
62+
)
63+
end
64+
return space
65+
end
66+
67+
2268
"""
2369
generate_spaces(; h_elem=16)
2470
For a given number of elements `h_elem`, this function generates a
@@ -37,10 +83,10 @@ function generate_spaces(;
3783
)
3884
FT = Float32
3985
cubed_sphere_mesh =
40-
CA.cubed_sphere_mesh(; radius = FT(planet_radius), h_elem)
86+
cubed_sphere_mesh(; radius = FT(planet_radius), h_elem)
4187
quad = Quadratures.GLL{4}()
4288
comms_ctx = ClimaComms.context()
43-
h_space = CA.make_horizontal_space(cubed_sphere_mesh, quad, comms_ctx, true)
89+
h_space = make_horizontal_space(cubed_sphere_mesh, quad, comms_ctx, true)
4490
Δh_scale = Spaces.node_horizontal_length_scale(h_space)
4591
@assert h_space isa CC.Spaces.SpectralElementSpace2D
4692
coords = CC.Fields.coordinate_field(h_space)
@@ -49,7 +95,7 @@ function generate_spaces(;
4995
"z",
5096
h_space,
5197
)
52-
elev_from_file = @. mask(elev_from_file)
98+
elev_from_file = @. max(elev_from_file, 0)
5399
# Fractional damping of smallest resolved scale
54100
# Approximated as k₀ ≈ 1/Δx, with n_attenuation
55101
# the factor by which we wish to damp wavenumber
@@ -58,7 +104,7 @@ function generate_spaces(;
58104
κ = diff_courant * Δh_scale^2
59105
maxiter = Int(round(log(n_attenuation) / diff_courant))
60106
diffuse_surface_elevation!(elev_from_file; κ, dt = FT(1), maxiter)
61-
elev_from_file = @. mask(elev_from_file)
107+
elev_from_file = @. max(elev_from_file, 0)
62108
return elev_from_file
63109
end
64110

post_processing/ci_plots.jl

Lines changed: 19 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,112 +1494,24 @@ function make_plots(
14941494
sim_type::Union{
14951495
EDMFBoxPlots,
14961496
DiagEDMFBoxPlotsWithPrecip,
1497-
},
1498-
output_paths::Vector{<:AbstractString},
1499-
)
1500-
simdirs = SimDir.(output_paths)
1501-
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{
15811497
EDMFColumnPlots,
15821498
EDMFColumnPlotsWithPrecip,
15831499
},
15841500
output_paths::Vector{<:AbstractString},
15851501
)
15861502
simdirs = SimDir.(output_paths)
15871503

1588-
if sim_type isa EDMFColumnPlotsWithPrecip
1504+
# Determine if this is a box or column type
1505+
is_box = sim_type isa Union{EDMFBoxPlots, DiagEDMFBoxPlotsWithPrecip}
1506+
1507+
# Determine precipitation names based on type
1508+
if sim_type isa DiagEDMFBoxPlotsWithPrecip
1509+
precip_names = ("husra", "hussn", "husraup", "hussnup")
1510+
elseif sim_type isa EDMFColumnPlotsWithPrecip
15891511
if sim_type isa Val{:prognostic_edmfx_rico_column_2M}
15901512
precip_names = (
1591-
"husra",
1592-
"hussn",
1593-
"husraup",
1594-
"hussnup",
1595-
"husraen",
1596-
"hussnen",
1597-
"cdnc",
1598-
"ncra",
1599-
"cdncup",
1600-
"ncraup",
1601-
"cdncen",
1602-
"ncraen",
1513+
"husra", "hussn", "husraup", "hussnup", "husraen", "hussnen",
1514+
"cdnc", "ncra", "cdncup", "ncraup", "cdncen", "ncraen",
16031515
)
16041516
else
16051517
precip_names =
@@ -1610,27 +1522,9 @@ function make_plots(
16101522
end
16111523

16121524
short_names = [
1613-
"wa",
1614-
"waup",
1615-
"ta",
1616-
"taup",
1617-
"hus",
1618-
"husup",
1619-
"arup",
1620-
"tke",
1621-
"ua",
1622-
"thetaa",
1623-
"thetaaup",
1624-
"ha",
1625-
"haup",
1626-
"hur",
1627-
"hurup",
1628-
"lmix",
1629-
"cl",
1630-
"clw",
1631-
"clwup",
1632-
"cli",
1633-
"cliup",
1525+
"wa", "waup", "ta", "taup", "hus", "husup", "arup", "tke", "ua",
1526+
"thetaa", "thetaaup", "ha", "haup", "hur", "hurup", "lmix",
1527+
"cl", "clw", "clwup", "cli", "cliup",
16341528
precip_names...,
16351529
]
16361530
reduction = "inst"
@@ -1647,9 +1541,13 @@ function make_plots(
16471541
short_name_tuples = pair_edmf_names(short_names)
16481542
var_groups_zt =
16491543
map_comparison(simdirs, short_name_tuples) do simdir, name_tuple
1650-
return [
1651-
get(simdir; short_name, reduction, period) for short_name in name_tuple
1652-
]
1544+
vars = map(short_name -> get(simdir; short_name, reduction, period), name_tuple)
1545+
# For box types, slice to a point (x=0, y=0)
1546+
if is_box
1547+
return map(var -> slice(var, x = 0.0, y = 0.0), vars)
1548+
else
1549+
return vars
1550+
end
16531551
end
16541552

16551553
var_groups_z = [

reproducibility_tests/ref_counter.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# What is the ref_counter?
66
#
7-
# The ref_counter is part of reproducability tests. The counter identifies a
7+
# The ref_counter is part of reproducibility tests. The counter identifies a
88
# particular snapshot of our code, a "reference". Each PR is tested against this
99
# reference to check if it reproduces the expected behavior. This allows us to
1010
# check that PRs that are expected to not modify the behavior do indeed preserve

src/ClimaAtmos.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import .Parameters as CAP
1717

1818
include(joinpath("utils", "abbreviations.jl"))
1919
include(joinpath("utils", "gpu_compat.jl"))
20-
include(joinpath("utils", "common_spaces.jl"))
2120
include(joinpath("solver", "types.jl"))
2221
include(joinpath("solver", "cli_options.jl"))
2322
include(joinpath("utils", "utilities.jl"))

src/diagnostics/default_diagnostics.jl

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -169,31 +169,26 @@ function core_default_diagnostics(output_writer, duration, start_date; topograph
169169
min_func = (args...; kwargs...) -> hourly_min(FT, args...; kwargs...)
170170
max_func = (args...; kwargs...) -> hourly_max(FT, args...; kwargs...)
171171
end
172-
core_diagnostics = if topography
173-
[
174-
# We need to compute the topography at the beginning of the
175-
# simulation (and only at the beginning), so we set
176-
# output/compute_schedule_func to false. It is still computed at the
177-
# very beginning
178-
ScheduledDiagnostic(;
179-
variable = get_diagnostic_variable("orog"),
180-
output_schedule_func = (integrator) -> false,
181-
compute_schedule_func = (integrator) -> false,
182-
output_writer,
183-
output_short_name = "orog_inst",
184-
),
185-
average_func(core_diagnostics...; output_writer, start_date)...,
186-
min_func("ts"; output_writer, start_date),
187-
max_func("ts"; output_writer, start_date)]
188-
else
189-
[
190-
average_func(core_diagnostics...; output_writer, start_date)...,
191-
min_func("ts"; output_writer, start_date),
192-
max_func("ts"; output_writer, start_date),
193-
]
172+
# Common diagnostics for all cases
173+
common_diagnostics = [
174+
average_func(core_diagnostics...; output_writer, start_date)...,
175+
min_func("ts"; output_writer, start_date),
176+
max_func("ts"; output_writer, start_date),
177+
]
178+
179+
# Prepend orography diagnostic if topography is enabled
180+
if topography
181+
orog_diagnostic = ScheduledDiagnostic(;
182+
variable = get_diagnostic_variable("orog"),
183+
output_schedule_func = (integrator) -> false,
184+
compute_schedule_func = (integrator) -> false,
185+
output_writer,
186+
output_short_name = "orog_inst",
187+
)
188+
pushfirst!(common_diagnostics, orog_diagnostic)
194189
end
195190

196-
return core_diagnostics
191+
return common_diagnostics
197192
end
198193

199194
##################

src/prognostic_equations/advection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)
240240

241241
if point_type <: Geometry.Abstract3DPoint
242242
@. ᶜω³ = wcurlₕ(Y.c.uₕ)
243-
elseif point_type <: Union{Geometry.Abstract2DPoint, Geometry.ZPoint}
243+
else
244244
@. ᶜω³ = zero(ᶜω³)
245245
end
246246

0 commit comments

Comments
 (0)