|
| 1 | +# REPL script (debugging workflow example) |
| 2 | + |
| 3 | + |
| 4 | +```@example |
| 5 | +
|
| 6 | +ca_dir = joinpath(@__DIR__, "..", "..") |
| 7 | +buildkite_env = joinpath(ca_dir, ".buildkite") |
| 8 | +using Pkg |
| 9 | +Pkg.activate(buildkite_env) |
| 10 | +
|
| 11 | +# julia> using Revise # This is useful For REPL debugging. See also: Infiltrator.jl and Main.@infiltrate |
| 12 | +
|
| 13 | +import ClimaAtmos as CA |
| 14 | +import SciMLBase: step! |
| 15 | +
|
| 16 | +# If you wish to run your simulation on a `CUDA` device, use |
| 17 | +
|
| 18 | +# import ClimaComms |
| 19 | +# ClimaComms.@import_required_backends |
| 20 | +# ENV["CLIMACOMMS_DEVICE"]="CUDA" |
| 21 | +
|
| 22 | +# (Note that the example below runs on a single CPU, which uses |
| 23 | +# ENV["CLIMACOMMS_DEVICE"]="CPU") |
| 24 | +
|
| 25 | +config_file = joinpath(ca_dir, "config/model_configs/baroclinic_wave.yml") |
| 26 | +config = CA.AtmosConfig(config_file) |
| 27 | +
|
| 28 | +# Generate temporary directory for Documenter run-script, clear after |
| 29 | +# demo is completed. |
| 30 | +
|
| 31 | +temp_output_dir = mktempdir(ca_dir, cleanup=true) |
| 32 | +config.parsed_args["output_dir"]=temp_output_dir |
| 33 | +simulation = CA.AtmosSimulation(config) |
| 34 | +
|
| 35 | +# Example: Advance a single timestep and explore the solution |
| 36 | +# stored in `simulation.integrator.u` |
| 37 | +step!(simulation.integrator) |
| 38 | +
|
| 39 | +# Example: Update command line argument, reset simulation, re-run to completion |
| 40 | +# Note that you can also to update the configuration `.yml` and |
| 41 | +# load the simulation again from the `config_file` as above in the same REPL session. |
| 42 | +# Note that you'd need to use `Revise` at the start of your session to apply changes |
| 43 | +# to the source code within your REPL session. |
| 44 | +# e.g. |
| 45 | +# julia> simulation = CA.AtmosSimulation(config_file) |
| 46 | +
|
| 47 | +@info "----------------------------------" |
| 48 | +@info "Update config arguments and re-run" |
| 49 | +@info "----------------------------------" |
| 50 | +
|
| 51 | +config.parsed_args["dt"]="400secs" |
| 52 | +config.parsed_args["t_end"]="800secs" |
| 53 | +simulation = CA.AtmosSimulation(config) |
| 54 | +CA.solve_atmos!(simulation) |
| 55 | +
|
| 56 | +@info "----------------------------------" |
| 57 | +@info "Reactivate docs environment" |
| 58 | +@info "----------------------------------" |
| 59 | +
|
| 60 | +# The final step, which is not part of the standard workflow |
| 61 | +# resets the environment to `docs`. |
| 62 | +# (it is necessary for the documentation generation only) |
| 63 | +ca_dir = joinpath(@__DIR__, "..", "..") |
| 64 | +docs_env = joinpath(ca_dir, "docs") |
| 65 | +Pkg.activate(docs_env) |
| 66 | +``` |
| 67 | + |
1 | 68 | # Julia scripts per Buildkite job
|
2 | 69 |
|
3 | 70 | ```@example
|
|
0 commit comments