-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathjob.py
More file actions
58 lines (51 loc) · 1.75 KB
/
Copy pathjob.py
File metadata and controls
58 lines (51 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
"""
runs a job
"""
import argparse
from pathlib import Path
import gemini3d.job
import sys
from time import monotonic
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("config_file", help="path to config*.nml file")
p.add_argument("out_dir", help="simulation output directory")
p.add_argument("-mpiexec", help="path to desired mpiexec executable")
p.add_argument("-gemexe", help="path to desired gemini.bin")
p.add_argument("-n", "--cpu", help="number of CPU cores", type=int, default=0)
p.add_argument("-f", "--force", help="force regeneration of simulation", action="store_true")
p.add_argument(
"-out_format", help="override Fortran output file format", choices=["h5", "nc", "raw"]
)
P = p.parse_args()
ret = -1
params = {
"config_file": Path(P.config_file).expanduser(),
"out_dir": Path(P.out_dir).expanduser().resolve(),
"mpiexec": P.mpiexec,
"gemexe": P.gemexe,
"force": P.force,
"out_format": P.out_format,
"cpu_count": P.cpu,
}
tic = monotonic()
try:
ret = gemini3d.job.runner(params)
except FileNotFoundError:
print(
"\nA necessary simulation input file was not found."
"\nThis can mean that the simulation initialization script wasn't run first.\n",
file=sys.stderr,
)
raise
except EnvironmentError as excp:
print(excp, file=sys.stderr)
print(
"If you need to build Gemini, from the Gemini directory:\n\n",
"cmake -B build\n",
"cmake --build build\n",
file=sys.stderr,
)
print(f"job.py ran in {monotonic() - tic:.3f} seconds.")
raise SystemExit(ret)