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 diagnostic module #2064

Merged
merged 66 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
5efe292
Add DiagnosticVariable
Sbozzolo Sep 1, 2023
e702b2e
Add ALL_DIAGNOSTICS
Sbozzolo Sep 1, 2023
0a9dd4b
Add ScheduledDiagnosticIterations
Sbozzolo Sep 1, 2023
4ff287f
Add reduction_identities.jl
Sbozzolo Sep 1, 2023
f6ad164
Add ScheduledDiagnosticTime
Sbozzolo Sep 1, 2023
705d732
Add more constructors for ScheduledDiagnostics
Sbozzolo Sep 1, 2023
034c3a6
Add get_callbacks_from_diagnostics
Sbozzolo Sep 1, 2023
33c690c
Add HDF5Writer
Sbozzolo Sep 1, 2023
29bdb28
Add default_diagnostics.jl
Sbozzolo Sep 1, 2023
cd0eb75
Add design note of pre_output_hook!
Sbozzolo Sep 5, 2023
b3c4ef1
Add basic support for diagnostics
Sbozzolo Sep 8, 2023
d57ed17
Add constructor for SDTime from SDIterations
Sbozzolo Sep 6, 2023
16beb0b
Add descriptive_name for ScheduledDiagnostics
Sbozzolo Sep 6, 2023
800a483
Use descriptive_name for filenames and errors
Sbozzolo Sep 6, 2023
42be42d
Add automatically generated list of diagnostics
Sbozzolo Sep 6, 2023
daca016
Capture the 'average' reduction in naming
Sbozzolo Sep 7, 2023
10b1201
Add helper function for diagnostics
Sbozzolo Sep 7, 2023
1fd4d42
Add example and docs on model-dependent diagnostic
Sbozzolo Sep 8, 2023
0b85ac9
Make Diagnostics a submodule
Sbozzolo Sep 8, 2023
bbba03e
Fix short/long names in documentation
Sbozzolo Sep 8, 2023
b977817
Rename compute_from_integrator
Sbozzolo Sep 8, 2023
21cd34b
Switch deepcopies to copies
Sbozzolo Sep 8, 2023
a229222
Do not parametrize string in DiagnosticVariable
Sbozzolo Sep 8, 2023
24aaa5c
Use more proper English
Sbozzolo Sep 8, 2023
fff3a93
Add name field to ScheduledDiagnostics
Sbozzolo Sep 8, 2023
36a525f
Add numeric values to error messages
Sbozzolo Sep 8, 2023
d53cf57
Do not use Val for functions
Sbozzolo Sep 8, 2023
6a0dd0b
Use push! instead of append!
Sbozzolo Sep 8, 2023
c821638
Add diagnostic accumulators
Sbozzolo Sep 9, 2023
6d07133
Refactor produce_common_diagnostic_function
Sbozzolo Sep 9, 2023
9515540
Add flag to output default diagnostics
Sbozzolo Sep 21, 2023
80e95db
Accept nothing as pre_output_hook!
Sbozzolo Sep 14, 2023
96c085d
Add YAML reader for diagnostics
Sbozzolo Sep 11, 2023
3a401eb
Clean up daily/hourly functions
Sbozzolo Sep 11, 2023
dfe4508
Change name to output_name in diagnostics
Sbozzolo Sep 11, 2023
bf20885
Add preliminary support to writing to NetCDF
Sbozzolo Sep 13, 2023
ff66204
Fix argument to compute_relative_humidty
Sbozzolo Sep 12, 2023
0cd5901
Pass state, cache, and time to diagnostics
Sbozzolo Sep 12, 2023
f91774b
add core diagnostics
LenkaNovak Sep 13, 2023
ae7a2c6
Fix diagnostics, and store them correctly
Sbozzolo Sep 14, 2023
0864fef
Remove newlines between docstrings and functions
Sbozzolo Sep 14, 2023
1e6b01e
Avoid unnecessary specialization
Sbozzolo Sep 14, 2023
ba68487
Move ClimaCore patch outside of abbreviations.jl
Sbozzolo Sep 14, 2023
2e7cc69
Use abbreviations.jl instead of definining our own
Sbozzolo Sep 14, 2023
f8cf05f
Print error values in seconds instead of iteration
Sbozzolo Sep 14, 2023
e750776
Make ALL_DIAGNOSTICS an implementation detail
Sbozzolo Sep 14, 2023
26e730b
Avoid allocations of diagnostics in callbacks
Sbozzolo Sep 14, 2023
02ea925
Fix element type for more complex Fields
Sbozzolo Sep 15, 2023
86be6fc
Allow accumulators to take Vector values
Sbozzolo Sep 15, 2023
9491af2
Modify and add some core diagnostics
szy21 Sep 16, 2023
f63f15b
Remove allocation in drag_vector
Sbozzolo Sep 18, 2023
17dcb20
Clean up radiation_diagnostics.jl
Sbozzolo Sep 18, 2023
e6e901f
Fix reduction name in suffix
Sbozzolo Sep 18, 2023
c549ac8
Add standard names and long ones for ScheduledDiag
Sbozzolo Sep 18, 2023
55b4900
Reword "get_" functions
Sbozzolo Sep 18, 2023
8ff2f00
Add some default diagnostics
Sbozzolo Sep 18, 2023
cbd3783
Add timing information to diagnostics
Sbozzolo Sep 19, 2023
68fe9fd
Reduce inference time in SciMLBase.CallbackSet
Sbozzolo Sep 19, 2023
3c689b7
Remove Any[]s
Sbozzolo Sep 20, 2023
2a400c9
Move to orchestrate_callbacks
Sbozzolo Sep 20, 2023
b913c80
Make timestep evenly divide day in CI
Sbozzolo Sep 21, 2023
057099a
Update link to diagnostic table
Sbozzolo Sep 21, 2023
c836a5b
Add diagnostics to one CI model
Sbozzolo Sep 21, 2023
1f6862a
Add diagnostic flamegraph
Sbozzolo Sep 22, 2023
bbeaf89
Move import of Diagnostics
Sbozzolo Sep 25, 2023
b78910f
Add return to accumulate to help inference
Sbozzolo Sep 25, 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
8 changes: 8 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,14 @@ steps:
agents:
slurm_mem: 20GB

- label: ":fire: Flame graph: perf target (diagnostics)"
command: >
julia --color=yes --project=perf perf/flame.jl
--config_file $PERF_CONFIG_PATH/flame/diagnostics.yml
artifact_paths: "flame_perf_diagnostics/*"
agents:
slurm_mem: 20GB

# Inference
- label: ":rocket: JET n-failures (inference)"
command: >
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ deps/src/
docs/build/
docs/site/

# File generated by make_available_diagnostics.jl
docs/src/available_diagnostics.md

# File generated by Pkg, the package manager, based on a corresponding Project.toml
# It records a fixed state of all packages used by the project. As such, it should not be
# committed for packages, but should be committed for applications that require a static
Expand Down
3 changes: 3 additions & 0 deletions config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ override_τ_precip:
log_params:
help: "Log parameters to file [`false` (default), `true`]"
value: false
output_default_diagnostics:
help: "Output the default diagnostics associated to the selected atmospheric model"
value: false
2 changes: 1 addition & 1 deletion config/model_configs/sphere_baroclinic_wave_rhoe.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dt_save_to_disk: "2days"
regression_test: true
initial_condition: "DryBaroclinicWave"
dt: "580secs"
dt: "400secs"
t_end: "10days"
job_id: "sphere_baroclinic_wave_rhoe"
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +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
2 changes: 1 addition & 1 deletion config/model_configs/sphere_held_suarez_rhoe_hightop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dt_save_to_disk: "4days"
regression_test: true
t_end: "8days"
forcing: "held_suarez"
dt: "500secs"
dt: "400secs"
z_elem: 25
job_id: "sphere_held_suarez_rhoe_hightop"
z_max: 45000.0
2 changes: 1 addition & 1 deletion config/model_configs/sphere_held_suarez_rhotheta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ dt_save_to_disk: "10days"
regression_test: true
t_end: "20days"
forcing: "held_suarez"
dt: "500secs"
dt: "400secs"
job_id: "sphere_held_suarez_rhotheta"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dt_save_to_disk: "5days"
initial_condition: "MoistBaroclinicWave"
max_newton_iters_ode: 4
dt: "500secs"
dt: "400secs"
tracer_upwinding: zalesak
t_end: "5days"
ode_algo: "SSP333"
Expand Down
11 changes: 11 additions & 0 deletions config/perf_configs/flame/diagnostics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
job_id: "flame_perf_diagnostics"
diagnostics:
- short_name: ua
period: 1secs
reduction_time: average
- short_name: va
period: 1secs
reduction_time: max
- short_name: ta
period: 1secs
reduction_time: max
2 changes: 1 addition & 1 deletion config/perf_configs/gpu_baroclinic_wave_rhoe.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
job_id: "gpu_baroclinic_wave_rhoe"
dt: "580secs"
dt: "400secs"
t_end: "10days"
dt_save_to_disk: "2days"
initial_condition: "DryBaroclinicWave"
Expand Down
2 changes: 1 addition & 1 deletion config/perf_configs/gpu_held_suarez_rhoe_hightop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ z_elem: 25
dz_bottom: 300
forcing: "held_suarez"
job_id: "gpu_held_suarez_rhoe_hightop"
dt: "500secs"
dt: "400secs"
t_end: "8days"
dt_save_to_disk: "4days"
4 changes: 4 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ disable_logging(Base.CoreLogging.Info) # Hide doctest's `@info` printing
doctest(ClimaAtmos)
disable_logging(Base.CoreLogging.BelowMinLevel) # Re-enable all logging

include("make_diagnostic_table.jl")

makedocs(
CitationBibliography(joinpath(@__DIR__, "bibliography.bib")),
modules = [ClimaAtmos],
Expand All @@ -26,6 +28,8 @@ makedocs(
"Contributor Guide" => "contributor_guide.md",
"Equations" => "equations.md",
"EDMF Equations" => "edmf_equations.md",
"Diagnostics" => "diagnostics.md",
"Available Diagnostics" => "available_diagnostics.md",
"Diagnostic EDMF Equations" => "diagnostic_edmf_equations.md",
"Gravity Wave Drag Parameterizations" => "gravity_wave.md",
"Radiative Equilibrium" => "radiative_equilibrium.md",
Expand Down
32 changes: 32 additions & 0 deletions docs/make_diagnostic_table.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ClimaAtmos as CA

# Read all the diagnostics we know how to compute, and print them into a
# markdown table that is later compiled into the docs

# basename(pwd()) if the code is run from inside the docs folder. If we don't
# have that, we will assume that we are running from the project root. If this
# code is run from anywhere but these two places, mkdocs will fail to find
# availbale_diagnostics.md
prefix = basename(pwd()) == "docs" ? "" : "docs/"

out_path = "$(prefix)src/available_diagnostics.md"

open(out_path, "w") do file

write(file, "# Available diagnostic variables\n\n")

write(
file,
"| Short name | Long name | Standard name | Units | Comments |\n",
)
write(file, "|---|---|---|---|---|\n")

for d in values(CA.Diagnostics.ALL_DIAGNOSTICS)
write(file, "| `$(d.short_name)` ")
write(file, "| $(d.long_name) ")
write(file, "| `$(d.standard_name)` ")
write(file, "| $(d.units) ")
write(file, "| $(d.comments)|\n")
end
end
@info "Written $out_path"
Loading
Loading