diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 85daaacbeb..68f12985d4 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -569,7 +569,7 @@ steps: - label: ":computer: checkbounds" command: > julia --color=yes --check-bounds=yes --project=perf perf/benchmark.jl - --config_file $PERF_CONFIG_PATH/checkbounds.yml + $PERF_CONFIG_PATH/checkbounds.yml artifact_paths: "checkbounds/*" agents: slurm_mem: 20GB @@ -970,14 +970,14 @@ steps: - label: ":computer: Benchmark: perf target (default)" command: > julia --color=yes --project=perf perf/benchmark.jl - --config_file $PERF_CONFIG_PATH/bm_perf_target.yml + $PERF_CONFIG_PATH/bm_perf_target.yml agents: slurm_mem: 20GB - label: ":computer: Benchmark: perf target (Threaded)" command: > julia --color=yes --threads 8 --project=perf perf/benchmark.jl - --config_file $PERF_CONFIG_PATH/bm_perf_target_threaded.yml + $PERF_CONFIG_PATH/bm_perf_target_threaded.yml agents: slurm_mem: 20GB slurm_cpus_per_task: 8 @@ -986,7 +986,7 @@ steps: - label: ":fire: Flame graph: perf target (default)" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_target.yml + $PERF_CONFIG_PATH/flame_perf_target.yml artifact_paths: "flame_perf_target/*" agents: slurm_mem: 20GB @@ -994,7 +994,7 @@ steps: - label: ":fire: Flame graph: perf target (with tracers)" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_target_tracers.yml + $PERF_CONFIG_PATH/flame_perf_target_tracers.yml artifact_paths: "flame_perf_target_tracers/*" agents: slurm_mem: 20GB @@ -1002,7 +1002,7 @@ steps: - label: ":fire: Flame graph: perf target (edmfx)" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_target_edmfx.yml + $PERF_CONFIG_PATH/flame_perf_target_edmfx.yml artifact_paths: "flame_perf_target_edmfx/*" agents: slurm_mem: 20GB @@ -1010,7 +1010,7 @@ steps: - label: ":fire: Flame graph: perf target (diagnostic edmfx)" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_target_diagnostic_edmfx.yml + $PERF_CONFIG_PATH/flame_perf_target_diagnostic_edmfx.yml artifact_paths: "flame_perf_target_diagnostic_edmfx/*" agents: slurm_mem: 20GB @@ -1018,7 +1018,7 @@ steps: - label: ":fire: Flame graph: perf target (edmf)" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_target_edmf.yml + $PERF_CONFIG_PATH/flame_perf_target_edmf.yml artifact_paths: "flame_perf_target_edmf/*" agents: slurm_mem: 20GB @@ -1026,7 +1026,7 @@ steps: - label: ":fire: Flame graph: perf target (Threaded)" command: > julia --threads 8 --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_target_threaded.yml + $PERF_CONFIG_PATH/flame_perf_target_threaded.yml artifact_paths: "flame_perf_target_threaded/*" agents: slurm_cpus_per_task: 8 @@ -1035,7 +1035,7 @@ steps: - label: ":fire: Flame graph: perf target (Callbacks)" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_target_callbacks.yml + $PERF_CONFIG_PATH/flame_perf_target_callbacks.yml artifact_paths: "flame_perf_target_callbacks/*" agents: slurm_mem: 20GB @@ -1043,7 +1043,7 @@ steps: - label: ":fire: Flame graph: gravity wave" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/perf_gw.yml + $PERF_CONFIG_PATH/flame_perf_gw.yml artifact_paths: "flame_perf_gw/*" agents: slurm_mem: 20GB @@ -1051,7 +1051,7 @@ steps: - label: ":fire: Flame graph: perf target (diagnostics)" command: > julia --color=yes --project=perf perf/flame.jl - --config_file $PERF_CONFIG_PATH/flame/diagnostics.yml + $PERF_CONFIG_PATH/flame_perf_diagnostics.yml artifact_paths: "flame_perf_diagnostics/*" agents: slurm_mem: 20GB @@ -1060,7 +1060,7 @@ steps: - label: ":rocket: JET n-failures (inference)" command: > julia --color=yes --project=perf perf/jet_test_nfailures.jl - --config_file $PERF_CONFIG_PATH/jet_n_failures.yml + $PERF_CONFIG_PATH/jet_n_failures.yml agents: slurm_mem: 20GB @@ -1068,7 +1068,6 @@ steps: - label: ":mag::rocket: Invalidations" command: > julia --color=yes --project=perf perf/invalidations.jl - --config_file $PERF_CONFIG_PATH/invalidations.yml artifact_paths: "invalidations/*" agents: slurm_mem: 20GB diff --git a/config/default_configs/default_config.yml b/config/default_configs/default_config.yml index 20ec70dc9b..327705bc0c 100644 --- a/config/default_configs/default_config.yml +++ b/config/default_configs/default_config.yml @@ -113,9 +113,6 @@ output_dir: device: help: "Device type to use [`auto` (default) `CPUSingleThreaded`, `CPUMultiThreaded`, `CUDADevice`]" value: "auto" -target_job: - help: "An (optional) job to target for analyzing performance" - value: ~ reference_job_id: help: |- Identifier of job to use as the "reference" solution in the quicklook plot; the current job's results get compared to the results of the quicklook job on the main branch (only used if `debugging_tc` is `true`) diff --git a/config/perf_configs/checkbounds.yml b/config/perf_configs/checkbounds.yml index e4992a0008..c87007712f 100644 --- a/config/perf_configs/checkbounds.yml +++ b/config/perf_configs/checkbounds.yml @@ -1 +1 @@ -job_id: "checkbounds" \ No newline at end of file +job_id: "checkbounds" diff --git a/config/perf_configs/flame/diagnostics.yml b/config/perf_configs/flame/diagnostics.yml deleted file mode 100644 index 5a80e59bdf..0000000000 --- a/config/perf_configs/flame/diagnostics.yml +++ /dev/null @@ -1,11 +0,0 @@ -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 diff --git a/config/perf_configs/flame/perf_gw.yml b/config/perf_configs/flame/perf_gw.yml deleted file mode 100644 index 9016c0b16b..0000000000 --- a/config/perf_configs/flame/perf_gw.yml +++ /dev/null @@ -1,16 +0,0 @@ -rad: "allskywithclear" -rayleigh_sponge: true -orographic_gravity_wave: "raw_topo" -z_elem: 25 -dt: "1secs" -surface_setup: "DefaultMoninObukhov" -t_end: "1mins" -non_orographic_gravity_wave: true -dz_bottom: 300.0 -vert_diff: "true" -idealized_insolation: false -z_max: 45000.0 -precip_model: "0M" -job_id: "flame_perf_gw" -moist: "equil" -toml: [toml/flame_perf_gw.toml] diff --git a/config/perf_configs/flame/perf_target_diagnostic_edmfx.yml b/config/perf_configs/flame/perf_target_diagnostic_edmfx.yml deleted file mode 100644 index eb7056956e..0000000000 --- a/config/perf_configs/flame/perf_target_diagnostic_edmfx.yml +++ /dev/null @@ -1,3 +0,0 @@ -target_job: "diagnostic_edmfx_aquaplanet_tke" -job_id: "flame_perf_target_diagnostic_edmfx" -apply_limiter: false diff --git a/config/perf_configs/flame/perf_target_edmf.yml b/config/perf_configs/flame/perf_target_edmf.yml deleted file mode 100644 index 8dd6088c68..0000000000 --- a/config/perf_configs/flame/perf_target_edmf.yml +++ /dev/null @@ -1,5 +0,0 @@ -job_id: "flame_perf_target_edmf" -precip_model: "nothing" -target_job: "sphere_baroclinic_wave_rhoe_equilmoist_edmf" -rad: "nothing" -apply_limiter: false \ No newline at end of file diff --git a/config/perf_configs/flame/perf_target_edmfx.yml b/config/perf_configs/flame/perf_target_edmfx.yml deleted file mode 100644 index 0a09f96641..0000000000 --- a/config/perf_configs/flame/perf_target_edmfx.yml +++ /dev/null @@ -1,3 +0,0 @@ -target_job: "sphere_baroclinic_wave_rhoe_equilmoist_edmfx" -job_id: "flame_perf_target_edmfx" -apply_limiter: false \ No newline at end of file diff --git a/config/perf_configs/flame/perf_target_threaded.yml b/config/perf_configs/flame/perf_target_threaded.yml deleted file mode 100644 index 3179e32b7a..0000000000 --- a/config/perf_configs/flame/perf_target_threaded.yml +++ /dev/null @@ -1 +0,0 @@ -job_id: "flame_perf_target_threaded" \ No newline at end of file diff --git a/config/perf_configs/flame_perf_diagnostics.yml b/config/perf_configs/flame_perf_diagnostics.yml new file mode 100644 index 0000000000..63863f23be --- /dev/null +++ b/config/perf_configs/flame_perf_diagnostics.yml @@ -0,0 +1,11 @@ +diagnostics: + - reduction_time: "average" + short_name: "ua" + period: "1secs" + - reduction_time: "max" + short_name: "va" + period: "1secs" + - reduction_time: "max" + short_name: "ta" + period: "1secs" +job_id: "flame_perf_diagnostics" diff --git a/config/perf_configs/flame_perf_gw.yml b/config/perf_configs/flame_perf_gw.yml new file mode 100644 index 0000000000..81df77c5d1 --- /dev/null +++ b/config/perf_configs/flame_perf_gw.yml @@ -0,0 +1,9 @@ +dz_bottom: 300.0 +rayleigh_sponge: true +toml: + - "toml/flame_perf_gw.toml" +orographic_gravity_wave: "raw_topo" +idealized_insolation: false +non_orographic_gravity_wave: true +job_id: "flame_perf_gw" +z_max: 45000.0 diff --git a/config/perf_configs/flame/perf_target.yml b/config/perf_configs/flame_perf_target.yml similarity index 100% rename from config/perf_configs/flame/perf_target.yml rename to config/perf_configs/flame_perf_target.yml diff --git a/config/perf_configs/flame/perf_target_callbacks.yml b/config/perf_configs/flame_perf_target_callbacks.yml similarity index 81% rename from config/perf_configs/flame/perf_target_callbacks.yml rename to config/perf_configs/flame_perf_target_callbacks.yml index d036e86d82..f99f919402 100644 --- a/config/perf_configs/flame/perf_target_callbacks.yml +++ b/config/perf_configs/flame_perf_target_callbacks.yml @@ -1,5 +1,4 @@ dt_save_to_disk: "1secs" dt_save_restart: "1secs" dt_rad: "1secs" -dt_save_to_sol: "1secs" job_id: "flame_perf_target_callbacks" diff --git a/config/perf_configs/flame_perf_target_diagnostic_edmfx.yml b/config/perf_configs/flame_perf_target_diagnostic_edmfx.yml new file mode 100644 index 0000000000..b5f20d92f3 --- /dev/null +++ b/config/perf_configs/flame_perf_target_diagnostic_edmfx.yml @@ -0,0 +1,9 @@ +dt_save_to_disk: "600secs" +edmfx_entr_model: "ConstantTimescale" +edmfx_nh_pressure: true +edmfx_upwinding: "first_order" +prognostic_tke: true +edmfx_sgs_flux: true +turbconv: "diagnostic_edmfx" +job_id: "flame_perf_target_diagnostic_edmfx" +edmfx_detr_model: "ConstantCoefficient" diff --git a/config/perf_configs/flame_perf_target_edmf.yml b/config/perf_configs/flame_perf_target_edmf.yml new file mode 100644 index 0000000000..ac15113d07 --- /dev/null +++ b/config/perf_configs/flame_perf_target_edmf.yml @@ -0,0 +1,9 @@ +rad: ~ +apply_limiter: false +dt_save_to_disk: "10secs" +precip_model: ~ +turbconv: "edmf" +post_process: false +FLOAT_TYPE: "Float64" +job_id: "flame_perf_target_edmf" +z_stretch: false diff --git a/config/perf_configs/flame_perf_target_edmfx.yml b/config/perf_configs/flame_perf_target_edmfx.yml new file mode 100644 index 0000000000..f892c20bd4 --- /dev/null +++ b/config/perf_configs/flame_perf_target_edmfx.yml @@ -0,0 +1,9 @@ +dt_save_to_disk: "30secs" +reference_job_id: "sphere_baroclinic_wave_rhoe_equilmoist" +ode_algo: "SSP33ShuOsher" +initial_condition: "MoistBaroclinicWaveWithEDMF" +edmfx_entr_model: "ConstantCoefficient" +edmfx_detr_model: "ConstantCoefficient" +edmfx_sgs_flux: true +turbconv: "edmfx" +job_id: "flame_perf_target_edmfx" diff --git a/config/perf_configs/flame_perf_target_threaded.yml b/config/perf_configs/flame_perf_target_threaded.yml new file mode 100644 index 0000000000..9f6b830521 --- /dev/null +++ b/config/perf_configs/flame_perf_target_threaded.yml @@ -0,0 +1 @@ +job_id: "flame_perf_target_threaded" diff --git a/config/perf_configs/flame/perf_target_tracers.yml b/config/perf_configs/flame_perf_target_tracers.yml similarity index 100% rename from config/perf_configs/flame/perf_target_tracers.yml rename to config/perf_configs/flame_perf_target_tracers.yml diff --git a/config/perf_configs/jet_n_failures.yml b/config/perf_configs/jet_n_failures.yml index 6c8f6142a9..4c358b7748 100644 --- a/config/perf_configs/jet_n_failures.yml +++ b/config/perf_configs/jet_n_failures.yml @@ -1,5 +1 @@ -target_job: "sphere_baroclinic_wave_rhoe_equilmoist_edmf" -moist: "dry" -precip_model: ~ -rad: ~ -job_id: "jet_n_failures" \ No newline at end of file +job_id: "jet_n_failures" diff --git a/docs/src/repl_scripts.jl b/docs/src/repl_scripts.jl index 467ce062da..f979ba2825 100644 --- a/docs/src/repl_scripts.jl +++ b/docs/src/repl_scripts.jl @@ -16,7 +16,7 @@ function print_repl_script(config) end end ib *= """\n""" - ib *= """config = CA.AtmosConfig(; config_dict);\n""" + ib *= """config = CA.AtmosConfig(config_dict);\n""" ib *= """\n""" ib *= """include("examples/hybrid/driver.jl")\n""" println(ib) diff --git a/perf/benchmark.jl b/perf/benchmark.jl index cef75aeb02..e1ff928c0d 100644 --- a/perf/benchmark.jl +++ b/perf/benchmark.jl @@ -1,7 +1,14 @@ import Random Random.seed!(1234) import ClimaAtmos as CA -config = CA.AtmosCoveragePerfConfig() + +include("common.jl") + +length(ARGS) != 1 && error("Usage: benchmark.jl ") +config_file = ARGS[1] +config_dict = YAML.load_file(config_file) +config = AtmosCoveragePerfConfig(config_dict) + integrator = CA.get_integrator(config) (; parsed_args) = config diff --git a/perf/benchmark_dump.jl b/perf/benchmark_dump.jl index d74c6693d6..25e7a6ea34 100644 --- a/perf/benchmark_dump.jl +++ b/perf/benchmark_dump.jl @@ -1,13 +1,3 @@ -#= -``` -julia --project=examples perf/benchmark_dump.jl -``` -Or, interactively, -``` -julia --project=examples -include(joinpath("perf", "benchmark_dump.jl")); -``` -=# import Random Random.seed!(1234) import ClimaAtmos as CA @@ -17,16 +7,16 @@ using Plots using PrettyTables import YAML +# Need to generate config_dict here to override `h_elem` in the loop below parsed_args = CA.parse_commandline(CA.argparse_settings()) config_dict = YAML.load_file(parsed_args["config_file"]) output_dir = joinpath(config_dict["job_id"]) steptimes = [] - # Iterate through varying number of horizontal elements for h_elem in 8:8:40 config_dict["h_elem"] = h_elem - config = CA.AtmosConfig(; config_dict = config_dict) + config = CA.AtmosConfig(config_dict) integrator = CA.get_integrator(config) Y₀ = deepcopy(integrator.u) diff --git a/perf/common.jl b/perf/common.jl new file mode 100644 index 0000000000..89478b34e9 --- /dev/null +++ b/perf/common.jl @@ -0,0 +1,42 @@ +import YAML + +""" + AtmosCoveragePerfConfig() + AtmosCoveragePerfConfig(; config_dict) + +Creates a model configuration that covers many physics components. +The configuration precedence is as follows: + 1. Configuration from the given config file/dict (highest precendence) + 2. Default perf configuration (to increase coverage) + 3. Default configuration (lowest precedence) +""" +function AtmosCoveragePerfConfig(config_dict = Dict()) + perf_default_config = perf_config_dict() + config_dict = merge(perf_default_config, config_dict) + return CA.AtmosConfig(config_dict) +end + +""" + TargetJobConfig(target_job) + +Creates a full model configuration from the given target job. +""" +TargetJobConfig(target_job) = + CA.AtmosConfig(CA.config_from_target_job(target_job)) + + +""" + perf_config_dict() + +Loads the default performance configuration from a file into a Dict. +""" +function perf_config_dict() + perf_defaults = joinpath( + dirname(@__FILE__), + "..", + "config", + "default_configs", + "default_perf.yml", + ) + return YAML.load_file(perf_defaults) +end diff --git a/perf/flame.jl b/perf/flame.jl index c946aad3c3..f9f15c54cf 100644 --- a/perf/flame.jl +++ b/perf/flame.jl @@ -1,7 +1,14 @@ import Random Random.seed!(1234) import ClimaAtmos as CA -config = CA.AtmosCoveragePerfConfig() + +include("common.jl") + +length(ARGS) != 1 && error("Usage: flame.jl ") +config_file = ARGS[1] +config_dict = YAML.load_file(config_file) +config = AtmosCoveragePerfConfig(config_dict) +job_id = config.parsed_args["job_id"] integrator = CA.get_integrator(config) # The callbacks flame graph is very expensive, so only do 2 steps. @@ -11,11 +18,9 @@ import SciMLBase SciMLBase.step!(integrator) # compile first CA.call_all_callbacks!(integrator) # compile callbacks import Profile, ProfileCanvas -(; output_dir, job_id) = integrator.p.simulation output_dir = job_id mkpath(output_dir) - @info "collect profile" Profile.clear() prof = Profile.@profile SciMLBase.step!(integrator) @@ -58,7 +63,7 @@ allocs_limit["flame_perf_target"] = 12864 allocs_limit["flame_perf_target_tracers"] = 212496 allocs_limit["flame_perf_target_edmfx"] = 304064 allocs_limit["flame_perf_diagnostics"] = 3024344 -allocs_limit["flame_perf_target_diagnostic_edmfx"] = 862576 +allocs_limit["flame_perf_target_diagnostic_edmfx"] = 862960 allocs_limit["flame_perf_target_edmf"] = 12459299664 allocs_limit["flame_perf_target_threaded"] = 6175664 allocs_limit["flame_perf_target_callbacks"] = 46413904 diff --git a/perf/jet.jl b/perf/jet.jl index 07e4e5f0ce..8d86d19995 100644 --- a/perf/jet.jl +++ b/perf/jet.jl @@ -1,9 +1,12 @@ import Random Random.seed!(1234) import ClimaAtmos as CA -config = CA.AtmosCoveragePerfConfig(; - config_dict = CA.config_from_target_job("edmfx_adv_test_box"), -) + +include("common.jl") + +config_dict = Dict("z_elem" => 63, "dt" => "10secs", "t_end" => "3600secs") +config = AtmosCoveragePerfConfig(config_dict) + integrator = CA.get_integrator(config) import JET diff --git a/perf/jet_test_nfailures.jl b/perf/jet_test_nfailures.jl index 8c6adf8272..fb51ad466a 100644 --- a/perf/jet_test_nfailures.jl +++ b/perf/jet_test_nfailures.jl @@ -1,11 +1,17 @@ import Random Random.seed!(1234) import ClimaAtmos as CA -config = CA.AtmosCoveragePerfConfig() + +include("common.jl") + +length(ARGS) != 1 && error("Usage: jet_test_nfailures.jl ") +config_file = ARGS[1] +config_dict = YAML.load_file(config_file) +config = AtmosCoveragePerfConfig(config_dict) + integrator = CA.get_integrator(config) import JET - import SciMLBase SciMLBase.step!(integrator) # Make sure no errors @@ -27,6 +33,7 @@ using Test # we have introduced an inference failure. We hope to drive # this number down to 0. n_allowed_failures = 680 + @show n @test n ≤ n_allowed_failures if n < n_allowed_failures @info "Please update the n-failures to $n" diff --git a/src/solver/types.jl b/src/solver/types.jl index b03cb9a393..ded8223045 100644 --- a/src/solver/types.jl +++ b/src/solver/types.jl @@ -393,56 +393,39 @@ struct AtmosConfig{FT, TD, PA, C} comms_ctx::C end +Base.eltype(::AtmosConfig{FT}) where {FT} = FT + """ - AtmosCoveragePerfConfig() - AtmosCoveragePerfConfig(; s, config_dict) -Creates a model configuration for many performance tests. -Creates a config from the following in order of top priority to last: -1. Configuration from the given config file/dict -2. Default perf configuration -3. Target job configuration -4. Default configuration + AtmosConfig(config_file::String) + +Helper function for the AtmosConfig constructor. Reads a YAML file into a Dict +and passes it to the AtmosConfig constructor. """ -function AtmosCoveragePerfConfig(; - s = argparse_settings(), - config_dict = nothing, -) - parsed_args = parse_commandline(s) - if isnothing(config_dict) - config_dict = YAML.load_file(parsed_args["config_file"]) - end - target_job_config = if haskey(config_dict, "target_job") - config_from_target_job(config_dict["target_job"]) - else - Dict() - end - perf_defaults = joinpath( - dirname(@__FILE__), - "..", - "..", - "config", - "default_configs", - "default_perf.yml", - ) - perf_default_config = YAML.load_file(perf_defaults) - config_dict = merge(target_job_config, perf_default_config, config_dict) - return AtmosConfig(; s, config_dict) +function AtmosConfig(config_file::String; comms_ctx = nothing) + config = YAML.load_file(config_file) + return AtmosConfig(config; comms_ctx) end -function AtmosConfig(; - s = argparse_settings(), - parsed_args = parse_commandline(s), - config_dict = nothing, - comms_ctx = nothing, -) - config = if !isnothing(config_dict) - override_default_config(config_dict) - elseif !isnothing(parsed_args["config_file"]) - override_default_config(parsed_args["config_file"]) - else - @info "Using default configuration" - default_config_dict() - end +""" + AtmosConfig(; comms_ctx = nothing) +Helper function for the AtmosConfig constructor. +Reads the `config_file` from the command line into a Dict +and passes it to the AtmosConfig constructor. +""" +function AtmosConfig(; comms_ctx = nothing) + parsed_args = parse_commandline(argparse_settings()) + return AtmosConfig(parsed_args["config_file"]; comms_ctx) +end + +AtmosConfig(::Nothing; comms_ctx = nothing) = AtmosConfig(Dict(); comms_ctx) + +""" + AtmosConfig(config::Dict; comms_ctx = nothing) +Constructs the AtmosConfig from the Dict passed in. This Dict overrides all of +the default configurations set in `default_config_dict()`. +""" +function AtmosConfig(config::Dict; comms_ctx = nothing) + config = override_default_config(config) FT = config["FLOAT_TYPE"] == "Float64" ? Float64 : Float32 toml_dict = CP.create_toml_dict( FT; @@ -469,4 +452,3 @@ function AtmosConfig(; PA = typeof(config) return AtmosConfig{FT, TD, PA, C}(toml_dict, config, comms_ctx) end -Base.eltype(::AtmosConfig{FT}) where {FT} = FT diff --git a/src/solver/yaml_helper.jl b/src/solver/yaml_helper.jl index 800ac19858..00c980dea4 100644 --- a/src/solver/yaml_helper.jl +++ b/src/solver/yaml_helper.jl @@ -81,10 +81,11 @@ function override_default_config(config_dict::AbstractDict;) config["diagnostics"] = config_dict["diagnostics"] end + config == default_config && @info "Using default configuration" + return config end - """ non_default_config_entries(config) diff --git a/test/config.jl b/test/config.jl new file mode 100644 index 0000000000..4226ee3bcc --- /dev/null +++ b/test/config.jl @@ -0,0 +1,29 @@ +using Test +import ClimaAtmos as CA + +include(joinpath("..", "perf", "common.jl")) + +@testset "AtmosCoveragePerfConfig" begin + # Just default config overridden by `default_perf.yml` + config = AtmosCoveragePerfConfig() + # Test defaults overridden by `default_perf` + @test config.parsed_args["dt"] == "1secs" + # Test defaults not overridden by `default_perf` + @test config.parsed_args["y_elem"] == 6 + + # Test with `target_job` + config = AtmosCoveragePerfConfig( + CA.config_from_target_job("sphere_baroclinic_wave_rhoe"), + ) + # Target job config overridden by `default_perf` + @test config.parsed_args["dt"] == "400secs" + # Target job config not overridden by `default_perf` + @test config.parsed_args["regression_test"] == true + + # Test that config_dict overrides `default_perf` + config_dict = Dict("dt" => "50secs", "turbconv_case" => "GABLS") + config = AtmosCoveragePerfConfig(config_dict) + @test config.parsed_args["dt"] == "50secs" + @test config.parsed_args["turbconv_case"] == "GABLS" + @test config.parsed_args["regression_test"] == false +end diff --git a/test/coupler_compatibility.jl b/test/coupler_compatibility.jl index 8cde9f9ed3..e8fb1b31fa 100644 --- a/test/coupler_compatibility.jl +++ b/test/coupler_compatibility.jl @@ -35,9 +35,7 @@ const T2 = 290 @testset "Coupler Compatibility (Hacky Version)" begin # Initialize a model. The value of surface_setup is irrelevant, since it # will get overwritten. - config = CA.AtmosConfig(; - config_dict = Dict("initial_condition" => "DryBaroclinicWave"), - ) + config = CA.AtmosConfig(Dict("initial_condition" => "DryBaroclinicWave")) integrator = CA.get_integrator(config) (; p, t) = integrator Y = integrator.u @@ -74,8 +72,8 @@ end @testset "Coupler Compatibility (Proper Version)" begin # Initialize a model. Set surface_setup to PrescribedSurface to prevent # ClimaAtmos from modifying the surface conditions. - config = CA.AtmosConfig(; - config_dict = Dict( + config = CA.AtmosConfig( + Dict( "initial_condition" => "DryBaroclinicWave", "surface_setup" => "PrescribedSurface", ), @@ -172,8 +170,8 @@ end # Verify that using PrescribedSurface does not break the initialization of # RRTMGP or diagnostic EDMF. We currently need a moisture model in order to # use diagnostic EDMF. - config = CA.AtmosConfig(; - config_dict = Dict( + config = CA.AtmosConfig( + Dict( "surface_setup" => "PrescribedSurface", "moist" => "equil", "rad" => "clearsky", diff --git a/test/parameter_tests.jl b/test/parameter_tests.jl index 1c0f1ef06c..e6199e66c1 100644 --- a/test/parameter_tests.jl +++ b/test/parameter_tests.jl @@ -16,7 +16,7 @@ default_args = CA.cli_defaults(CA.argparse_settings()) "dt_save_to_disk" => "str", "bubble" => true, ) - parsed_args = CA.AtmosConfig(; config_dict).parsed_args + parsed_args = CA.AtmosConfig(config_dict).parsed_args @test parsed_args["krylov_rtol"] isa FT @test parsed_args["newton_rtol"] isa FT @test parsed_args["max_newton_iters_ode"] isa Int @@ -27,7 +27,7 @@ end @testset "Test unique aliases" begin config_dict = Dict("toml" => ["parameter_tests.toml"]) - config = CA.AtmosConfig(; config_dict) + config = CA.AtmosConfig(config_dict) @test_throws ErrorException CP.get_parameter_values!( config.toml_dict, ["same_alias"], @@ -38,7 +38,7 @@ end toml_path = joinpath("..", "toml") for toml in readdir(toml_path) config_dict = Dict("toml" => [joinpath(toml_path, toml)]) - config = CA.AtmosConfig(; config_dict) + config = CA.AtmosConfig(config_dict) # Ensure that there are no errors @test CA.create_parameter_set(config) isa CA.Parameters.ClimaAtmosParameters diff --git a/test/runtests.jl b/test/runtests.jl index 72b455285e..88124df3fe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,7 @@ using Test @safetestset "Utilities" begin @time include("utilities.jl") end @safetestset "Parameter tests" begin @time include("parameter_tests.jl") end @safetestset "Coupler Compatibility" begin @time include("coupler_compatibility.jl") end +@safetestset "Configuration tests" begin @time include("config.jl") end #! format: on nothing