7 from argparse
import ArgumentParser
10 parser = ArgumentParser()
11 parser.add_argument(
"states_file")
12 parser.add_argument(
"--no_mpi", action=
"store_true")
13 parser.add_argument(
"--id", nargs=
'?', default=
"tmp")
14 args = parser.parse_args()
16 output_dir = os.path.abspath(
"tmp")
20 from sumatra.projects
import load_project
21 output_dir = os.path.join(os.path.abspath(load_project().data_store.root), args.id)
25 current_path = os.path.dirname(os.path.realpath(__file__))
27 if not os.path.exists(output_dir):
28 os.makedirs(output_dir)
32 output_file = os.path.join(output_dir, os.path.split(states_file)[-1])
34 build_path = os.path.abspath(os.path.join(current_path,
"..",
"..",
"..",
"build"))
35 project_path = os.path.abspath(os.path.join(current_path,
"..",
".."))
37 print "Building in:\n", build_path
39 if not os.path.exists(build_path):
40 os.makedirs(build_path)
41 subprocess.call([
"qmake", project_path,
"CONFIG+=nogui"], cwd=build_path)
42 subprocess.call([
"make",
"-j",
"8"], cwd=build_path)
44 staterunner_path = os.path.join(build_path,
"tools",
"staterunner")
45 lib_path = os.path.join(
"..",
"..",
"src")
47 env = dict(os.environ)
48 env[
'LD_LIBRARY_PATH'] = lib_path
51 run_argument = [
"./staterunner", states_file, output_file]
53 run_argument = [
"mpirun",
"-n",
"8",
"./staterunner", states_file, output_file]
54 print " ".join(run_argument)
55 proc = subprocess.call(run_argument, cwd=staterunner_path, env=env)
57 print "Results saved to this directory:\n", output_dir +
"/*"