scripts/run_pmf.jl

Snapshot from this documentation build. SHA-256: b2cb910ae02f671214632c5d112bdfeff371ca7a352873f798c7f0f1de74574b

    1 #!/usr/bin/env julia
    2 using PMFGLM
    3 
    4 function cli(args)
    5     if isempty(args) || "--help" in args
    6         println("Usage: julia --project[=environments/metal] -t auto scripts/run_pmf.jl CONFIG.toml --output=RUN_DIR [--backend=cpu|metal|cuda] [--mhd-solver=glm|ct] [--dry-run]")
    7         return
    8     end
    9     config = load_config(first(args))
   10     output = nothing
   11     dry = false
   12     for arg in args[2:end]
   13         if startswith(arg,"--output=")
   14             output = split(arg,'=';limit=2)[2]
   15         elseif startswith(arg,"--backend=")
   16             get!(config.settings,"run",Dict{String,Any}())["backend"] = split(arg,'=';limit=2)[2]
   17         elseif startswith(arg,"--mhd-solver=")
   18             solver = lowercase(split(arg,'=';limit=2)[2])
   19             solver in ("glm","ct") || error("--mhd-solver must be glm or ct")
   20             get!(config.settings,"run",Dict{String,Any}())["mhd_solver"] = solver
   21         elseif arg == "--dry-run"
   22             dry = true
   23         else
   24             error("unknown argument: $arg")
   25         end
   26     end
   27     output === nothing && error("--output=RUN_DIR is required")
   28     result = run_simulation(config;output_dir=output,dry_run=dry)
   29     if dry
   30         import_print = PMFGLM.TOML.print
   31         import_print(stdout,result;sorted=true)
   32     else
   33         println(result)
   34     end
   35 end
   36 cli(ARGS)