Snapshot from this documentation build. SHA-256: 50ac8863788fd4b06cc77e15e6ba9eaeb9e45fe00860d263708b3c8d3c5dfa69
1 #!/usr/bin/env julia
2 using PMFGLM
3 using TOML
4 using Dates
5
6 isempty(ARGS) && error("usage: julia --project[=environments/metal] -t 4 scripts/run_suite.jl SUITE.toml [--execute] [--mhd-solver=glm|ct]")
7 path = abspath(first(ARGS))
8 suite = TOML.parsefile(path)
9 execute = "--execute" in ARGS
10 # --mhd-solver overrides run.mhd_solver of every case; without it each case uses its own
11 # (or the base config's) run.mhd_solver, default glm.
12 solver_override = nothing
13 for arg in ARGS[2:end]
14 if startswith(arg,"--mhd-solver=")
15 global solver_override = lowercase(split(arg,'=';limit=2)[2])
16 solver_override in ("glm","ct") || error("--mhd-solver must be glm or ct")
17 else
18 arg == "--execute" || error("unknown suite argument")
19 end
20 end
21 base = load_config(normpath(joinpath(dirname(path),suite["base_config"])))
22 outroot = normpath(joinpath(dirname(path),get(suite,"output_dir","../results/suite")))
23 labels = String[]
24 for case in suite["cases"]
25 label = case["label"]
26 occursin(r"^[a-zA-Z0-9_-]+$",label) || error("case label must be a simple directory name")
27 label in labels && error("duplicate case label $label")
28 push!(labels,label)
29 settings = deepcopy(base.settings)
30 for (section,values) in case
31 section=="label" && continue
32 values isa AbstractDict || error("suite overrides must be TOML tables")
33 merge!(get!(settings,section,Dict{String,Any}()),values)
34 end
35 solver_override === nothing || (get!(settings,"run",Dict{String,Any}())["mhd_solver"] = solver_override)
36 config = RunConfig(settings)
37 out = joinpath(outroot,label)
38 if execute
39 println("Starting serialized case ",label," (mhd_solver=",get(settings["run"],"mhd_solver","glm"),") at ",now());flush(stdout)
40 run_simulation(config;output_dir=out)
41 else
42 run_simulation(config;output_dir=out,dry_run=true)
43 println(label,": mhd_solver=",get(settings["run"],"mhd_solver","glm")," backend=",get(settings["run"],"backend","cpu")," N=",settings["run"]["n"]," -> ",out)
44 end
45 end
46 execute || println("Validated ",length(labels)," cases. Add --execute to run serially.")