Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for online remapping #2179

Merged
merged 23 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6567c41
Remove outdated comments
Sbozzolo Sep 28, 2023
0f6b56d
Require output_writer in diagnostics
Sbozzolo Nov 14, 2023
0ed3c02
Rework diagnostic writers
Sbozzolo Nov 14, 2023
6f7f7c5
Make time_index first coordinate in NetCDF
Sbozzolo Oct 11, 2023
fb40d8c
Ignore diagnostics with output_every < 0
Sbozzolo Oct 5, 2023
d35e4a6
Add orography to diagnostics
Sbozzolo Nov 20, 2023
1ea3d37
Add elevation profile in NetCDF output
Sbozzolo Oct 23, 2023
92aa93f
Add support for interpolation of topography
Sbozzolo Oct 11, 2023
8cc1a6b
Output default diagnostics by default
Sbozzolo Oct 20, 2023
fadbc2c
Choose timestep that divides 1 day
Sbozzolo Nov 14, 2023
e6c5a84
Help inference of orchestrate_diagnostics
Sbozzolo Oct 30, 2023
0fb1911
Fix NetCDF performance issue (+ more bugs)
Sbozzolo Oct 31, 2023
258a7d4
Remove redunant reduction in output_long_name
Sbozzolo Nov 6, 2023
f157d32
Be more careful with floating point comparisons
Sbozzolo Nov 22, 2023
ec1b50a
Avoid allocations in diagnostics with U/V/WVectors
Sbozzolo Dec 1, 2023
1da73bb
Remove FT from radiation diagnostics
Sbozzolo Nov 30, 2023
73930d7
Bump allocations
Sbozzolo Dec 4, 2023
ab74587
Output relevant diagnostics
Sbozzolo Nov 29, 2023
d69bfe9
Fix YAML parsing of diagnostics:output_name
Sbozzolo Nov 29, 2023
a8bb43b
Add AtmosSimulation
Sbozzolo Nov 29, 2023
27b0932
Fail test with fewer than 0.5 * alloc_limit
Sbozzolo Nov 30, 2023
1558d75
Avoid allocations due to surface_ct3_unit
Sbozzolo Dec 1, 2023
91fe85c
Add warn_allocations_diagnostics
Sbozzolo Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,6 @@ steps:
--config_file $CONFIG_PATH/box_hydrostatic_balance_rhoe.yml
artifact_paths: "box_hydrostatic_balance_rhoe/*"

- label: ":computer: Bomex box (ρe_tot)"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
--config_file $CONFIG_PATH/bomex_box_rhoe.yml
artifact_paths: "bomex_box_rhoe/*"

- label: ":computer: 3D density current"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
Expand Down
6 changes: 6 additions & 0 deletions config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,10 @@ log_params:
value: false
output_default_diagnostics:
help: "Output the default diagnostics associated to the selected atmospheric model"
value: true
netcdf_interpolate_z_over_msl:
help: "Interpolate diagnostics in the NetCDF files in such a way that `z` is the elevation from the sea level (as opposed to the elevation from the surface)"
value: false
warn_allocations_diagnostics:
help: "When true, a dry-run for all the diagnostics is perform to check whether the functions allocate additional memory (which reduces performances)"
value: false
1 change: 1 addition & 0 deletions config/default_configs/default_perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ forcing: "held_suarez"
precip_model: "0M"
dt_save_to_sol: "Inf"
rad: "allskywithclear"
warn_allocations_diagnostics: true
3 changes: 3 additions & 0 deletions config/model_configs/box_density_current_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ config: "box"
kappa_4: 1.0e7
z_max: 6400.0
job_id: "box_density_current_test"
diagnostics:
- short_name: thetaa
period: 10secs
5 changes: 5 additions & 0 deletions config/model_configs/box_hydrostatic_balance_rhoe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ hyperdiff: "false"
dt: "20secs"
perturb_initstate: false
job_id: "box_hydrostatic_balance_rhoe"
diagnostics:
- short_name: wa
period: 1days
- short_name: ua
period: 1days
4 changes: 4 additions & 0 deletions config/model_configs/plane_agnesi_mountain_test_stretched.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ z_max: 25000.0
topography: "Agnesi"
job_id: "plane_agnesi_mountain_test_stretched"
toml: [toml/plane_agnesi_mountain_test_stretched.toml]
netcdf_interpolate_z_over_msl: true
diagnostics:
- short_name: wa
period: 4hours
4 changes: 4 additions & 0 deletions config/model_configs/plane_agnesi_mountain_test_uniform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ z_max: 25000.0
topography: "Agnesi"
job_id: "plane_agnesi_mountain_test_uniform"
toml: [toml/plane_agnesi_mountain_test_uniform.toml]
netcdf_interpolate_z_over_msl: true
diagnostics:
- short_name: wa
period: 4hours
3 changes: 3 additions & 0 deletions config/model_configs/plane_density_current_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ config: "plane"
kappa_4: 1.0e7
z_max: 6400.0
job_id: "plane_density_current_test"
diagnostics:
- short_name: thetaa
period: 900secs
4 changes: 4 additions & 0 deletions config/model_configs/plane_schar_mountain_test_stretched.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ z_max: 25000.0
topography: "Schar"
job_id: "plane_schar_mountain_test_stretched"
toml: [toml/plane_schar_mountain_test_stretched.toml]
netcdf_interpolate_z_over_msl: true
diagnostics:
- short_name: wa
period: 4hours
4 changes: 4 additions & 0 deletions config/model_configs/plane_schar_mountain_test_uniform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ z_max: 25000.0
topography: "Schar"
job_id: "plane_schar_mountain_test_uniform"
toml: [toml/plane_schar_mountain_test_uniform.toml]
netcdf_interpolate_z_over_msl: true
diagnostics:
- short_name: wa
period: 4hours
71 changes: 0 additions & 71 deletions config/model_configs/prognostic_edmfx_bomex_fixtke_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,74 +28,3 @@ dt: "5secs"
t_end: "6hours"
dt_save_to_disk: "10mins"
toml: [toml/prognostic_edmfx_box.toml]
diagnostics:
- short_name: ts
period: 10mins
- short_name: ta
period: 10mins
- short_name: thetaa
period: 10mins
- short_name: ha
period: 10mins
- short_name: pfull
period: 10mins
- short_name: rhoa
period: 10mins
- short_name: ua
period: 10mins
- short_name: va
period: 10mins
- short_name: wa
period: 10mins
- short_name: hur
period: 10mins
- short_name: hus
period: 10mins
- short_name: clw
period: 10mins
- short_name: cli
period: 10mins
- short_name: hussfc
period: 10mins
- short_name: evspsbl
period: 10mins
- short_name: arup
period: 10mins
- short_name: waup
period: 10mins
- short_name: taup
period: 10mins
- short_name: thetaaup
period: 10mins
- short_name: haup
period: 10mins
- short_name: husup
period: 10mins
- short_name: hurup
period: 10mins
- short_name: clwup
period: 10mins
- short_name: cliup
period: 10mins
- short_name: rhoaen
period: 10mins
- short_name: waen
period: 10mins
- short_name: taen
period: 10mins
- short_name: thetaaen
period: 10mins
- short_name: haen
period: 10mins
- short_name: husen
period: 10mins
- short_name: huren
period: 10mins
- short_name: clwen
period: 10mins
- short_name: clien
period: 10mins
- short_name: tke
period: 10mins
- short_name: lmix
period: 10mins
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dt_save_to_disk: "500secs"
dt_save_to_disk: "400secs"
initial_condition: "IsothermalProfile"
t_end: "1500secs"
config: "column"
hyperdiff: "false"
dt: "500secs"
dt: "400secs"
non_orographic_gravity_wave: true
job_id: "single_column_nonorographic_gravity_wave"
7 changes: 7 additions & 0 deletions config/model_configs/single_column_precipitation_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@ toml: [toml/single_column_precipitation_test.toml]
diagnostics:
- short_name: hus
period: 500secs
writer: h5
- short_name: clw
period: 500secs
writer: h5
- short_name: cli
period: 500secs
writer: h5
- short_name: husra
period: 500secs
writer: h5
- short_name: hussn
period: 500secs
writer: h5
- short_name: ta
period: 500secs
writer: h5
- short_name: wa
period: 500secs
writer: h5
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
rad: "allskywithclear"
dt_save_to_disk: "18hours"
dt_save_to_disk: "1days"
rayleigh_sponge: true
orographic_gravity_wave: "raw_topo"
z_elem: 25
dt: "400secs"
surface_setup: "DefaultMoninObukhov"
t_end: "18hours"
t_end: "15hours"
non_orographic_gravity_wave: true
dz_bottom: 300.0
vert_diff: "true"
Expand All @@ -17,3 +17,4 @@ surface_temperature: "ZonallyAsymmetric"
job_id: "sphere_aquaplanet_rhoe_equilmoist_allsky_gw_raw_zonallyasymmetric"
moist: "equil"
toml: [toml/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_raw_zonallyasymmetric.toml]
netcdf_interpolate_z_over_msl: true
9 changes: 9 additions & 0 deletions config/model_configs/sphere_baroclinic_wave_rhoe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ initial_condition: "DryBaroclinicWave"
dt: "400secs"
t_end: "10days"
job_id: "sphere_baroclinic_wave_rhoe"
diagnostics:
- short_name: pfull
period: 1days
- short_name: wa
period: 1days
- short_name: va
period: 1days
- short_name: rv
period: 1days
11 changes: 11 additions & 0 deletions config/model_configs/sphere_baroclinic_wave_rhoe_equilmoist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ initial_condition: "MoistBaroclinicWave"
dt: "450secs"
job_id: "sphere_baroclinic_wave_rhoe_equilmoist"
moist: "equil"
diagnostics:
- short_name: pfull
period: 1days
- short_name: wa
period: 1days
- short_name: va
period: 1days
- short_name: rv
period: 1days
- short_name: hus
period: 1days
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ dt: "450secs"
FLOAT_TYPE: "Float64"
job_id: "sphere_baroclinic_wave_rhoe_equilmoist_conservation_ft64"
rad: "clearsky"
diagnostics:
- short_name: pfull
period: 1days
- short_name: wa
period: 1days
- short_name: va
period: 1days
- short_name: rv
period: 1days
- short_name: hus
period: 1days
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dt_save_to_disk: "30secs"
initial_condition: "MoistBaroclinicWaveWithEDMF"
dt: "1secs"
edmfx_entr_model: "Generalized"
edmfx_detr_model: "Generalized"
edmfx_entr_model: "Generalized"
edmfx_detr_model: "Generalized"
edmfx_nh_pressure: true
t_end: "6mins"
turbconv: "edmfx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,18 @@ t_end: "6hours"
job_id: "sphere_baroclinic_wave_rhoe_equilmoist_expvdiff"
moist: "equil"
toml: [toml/sphere_baroclinic_wave_rhoe_equilmoist_expvdiff.toml]
diagnostics:
- short_name: pfull
period: 12hours
- short_name: rv
period: 12hours
- short_name: wa
period: 12hours
- short_name: va
period: 12hours
- short_name: pfull
period: 12hours
- short_name: ta
period: 12hours
- short_name: hus
period: 12hours
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ t_end: "6days"
use_reference_state: false
dt: "200secs"
job_id: "sphere_baroclinic_wave_rhoe_topography_dcmip_rs"
netcdf_interpolate_z_over_msl: true
diagnostics:
- short_name: pfull
period: 1days
- short_name: wa
period: 1days
- short_name: va
period: 1days
- short_name: rv
period: 1days
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ viscous_sponge: true
job_id: "sphere_held_suarez_rhoe_equilmoist_hightop_sponge"
moist: "equil"
toml: [toml/sphere_held_suarez_rhoe_equilmoist_hightop_sponge.toml]
output_default_diagnostics: true
netcdf_interpolate_z_over_msl: true
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ precip_model: "0M"
topography: "DCMIP200"
job_id: "sphere_held_suarez_rhoe_equilmoist_topography_dcmip"
moist: "equil"
netcdf_interpolate_z_over_msl: true
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ forcing: "held_suarez"
dt: "200secs"
viscous_sponge: true
job_id: "sphere_held_suarez_rhoe_topography_dcmip"
netcdf_interpolate_z_over_msl: true
16 changes: 14 additions & 2 deletions docs/src/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ identifies the period over which to compute the reduction and how often to save
to disk. `output_name` is optional, and if provided, it identifies the name of the
output file.

The default `writer` is HDF5. If `writer` is `nc` or `netcdf`, the output is
The default `writer` is NetCDF. If `writer` is `nc` or `netcdf`, the output is
remapped non-conservatively on a Cartesian grid and saved to a NetCDF file.
Currently, only 3D fields on cubed spheres are supported.

Expand Down Expand Up @@ -90,7 +90,8 @@ and time, or can be the result of a reduction in a period that is defined by
More specifically, a `ScheduledDiagnostic` contains the following pieces of data

- `variable`: The diagnostic variable that has to be computed and output.
- `output_every`: Frequency of how often to save the results to disk.
- `output_every`: Frequency of how often to save the results to disk. If
`output_every` is non-positive, only output at the first time step.
- `output_writer`: Function that controls out to save the computed diagnostic
variable to disk.
- `reduction_time_func`: If not `nothing`, the `ScheduledDiagnostic` receives an
Expand Down Expand Up @@ -174,6 +175,17 @@ Given a timestep `dt`, a `ScheduledDiagnosticIterations` can be obtained from a
`ScheduledDiagnosticTime` `sd` simply by calling
``ScheduledDiagnosticIterations(sd, dt)`.

## The NetCDF output

The NetCDF writer in `ClimaAtmos` saves different diagnostics to different files
in the same output folder. Files are named after a combination of the diagnostic
variable `short_name`, and the details of the temporal reduction. Inside each
NetCDF file, there is only one diagnostic variable, along with the various
dimensions (e.g., `lat`, `lon`, and `z`). For simulations with topography, the
variable `z` is no longer a simple vector `z[k]`, but it is a full
multidimensional array `z[i, j, k]` which defines the elevation on the sea level
of the point of indices `[i, j, k]`.

## I want to add a new diagnostic variable

Diagnostic variables are represented in `ClimaAtmos` with a `DiagnosticVariable`
Expand Down
7 changes: 4 additions & 3 deletions examples/hybrid/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Random.seed!(1234)
if !(@isdefined config)
config = CA.AtmosConfig()
end
integrator = CA.get_integrator(config)
sol_res = CA.solve_atmos!(integrator)
simulation = CA.get_simulation(config)
(; integrator) = simulation
sol_res = CA.solve_atmos!(simulation)

(; simulation, atmos, params) = integrator.p
(; atmos, params) = integrator.p
(; p) = integrator

import ClimaCore
Expand Down
3 changes: 2 additions & 1 deletion perf/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ config_file = ARGS[1]
config_dict = YAML.load_file(config_file)
config = AtmosCoveragePerfConfig(config_dict)

integrator = CA.get_integrator(config)
simulation = CA.get_simulation(config)
(; integrator) = simulation

(; parsed_args) = config

Expand Down
3 changes: 2 additions & 1 deletion perf/benchmark_dump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ steptimes = []
for h_elem in 8:8:40
config_dict["h_elem"] = h_elem
config = CA.AtmosConfig(config_dict)
integrator = CA.get_integrator(config)
simulation = CA.get_simulation(config)
(; integrator) = simulation
Y₀ = deepcopy(integrator.u)

@info "Compiling benchmark_step for h_elem=$h_elem"
Expand Down
3 changes: 2 additions & 1 deletion perf/benchmark_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import ClimaComms

config = CA.AtmosConfig()

integrator = CA.get_integrator(config);
simulation = CA.get_simulation(config)
(; integrator) = simulation;
Y₀ = deepcopy(integrator.u);
@info "Compiling benchmark_step!..."
CA.benchmark_step!(integrator, Y₀); # compile first
Expand Down
Loading
Loading