diff --git a/docs/src/config.md b/docs/src/config.md index d914c22b0de..a67402bfc7f 100644 --- a/docs/src/config.md +++ b/docs/src/config.md @@ -9,7 +9,14 @@ To start the model with a custom configuration, run: `julia --project=examples examples/driver.jl --config_file ` -### Example +### Rerunning the driver without recompiling +If you are running the model interactively and want to rerun the model +with a new configuration without recompiling, +a convenience function `run_driver(config_file)` is defined. +It creates a new AtmosConfig from the given file and includes the driver file. +To run: `CA.run_driver("path/to/config.yml")` + +### Configuration File Example Below is the default Bomex configuration: ``` edmf_coriolis: Bomex diff --git a/src/solver/yaml_helper.jl b/src/solver/yaml_helper.jl index 399532a30ce..22e3b8222f2 100644 --- a/src/solver/yaml_helper.jl +++ b/src/solver/yaml_helper.jl @@ -162,3 +162,23 @@ function job_id_from_config(config, defaults = default_config_dict()) warn && @warn "Truncated job ID:$s may not be unique due to use of Real" return s end + +""" + run_driver(config_file) + +Convenience function to run the driver with a given config file. +Useful for re-running the model with a new/modified configuration without recompiling +""" +function run_driver(config_file) + config_dict = YAML.load_file(config_file) + config = CA.AtmosConfig(; config_dict) + driver_path = joinpath( + dirname(@__FILE__), + "..", + "..", + "examples", + "hybrid", + "driver.jl", + ) + include(driver_path) +end