Skip to content

Commit

Permalink
Add run_driver convenience func
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Sep 11, 2023
1 parent f751e69 commit 6db3253
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/src/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ To start the model with a custom configuration, run:

`julia --project=examples examples/driver.jl --config_file <yaml>`

### 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
Expand Down
20 changes: 20 additions & 0 deletions src/solver/yaml_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6db3253

Please sign in to comment.