-
Notifications
You must be signed in to change notification settings - Fork 11
/
experiment.py
executable file
·60 lines (47 loc) · 1.53 KB
/
experiment.py
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
59
60
#! /usr/bin/env python
#
# This file is part of SPORE.
#
# Copyright (C) 2016, the SPORE team (see AUTHORS).
#
# SPORE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# SPORE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SPORE. If not, see <http://www.gnu.org/licenses/>.
#
# For more information see: https://github.com/IGITUGraz/spore-nest-module
#
import os
import sys
import subprocess
plotter = None
exitcode = -1
if "TEST_MODE" not in sys.argv[1:]:
# don't create plotter in test mode
try:
dev0 = open("/dev/null", "w")
plotter = subprocess.Popen([sys.executable, "./python/interface.py"], stdout=dev0)
except:
print("Error when running the plotter interface.")
try:
os.chdir("python")
if (sys.version_info[0] == 3):
music_filename = "run_py3.music"
else:
music_filename = "run.music"
print("Starting MUSIC/NEST simulation")
cmd = ["mpirun", "-np", "3", "music", music_filename]
cmd.extend(sys.argv[1:])
exitcode = subprocess.call(cmd)
finally:
if plotter is not None:
plotter.kill()
sys.exit(exitcode)