Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
OPAL
runOPAL
Commits
34a0aeea
Commit
34a0aeea
authored
Feb 20, 2018
by
ext-neveu_n
Browse files
replacing getoutput function for slurm jobs
parent
00df063f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
runOPAL/runOPAL.py
runOPAL/runOPAL.py
+6
-5
runOPAL/simulation.py
runOPAL/simulation.py
+13
-13
No files found.
runOPAL/runOPAL.py
View file @
34a0aeea
...
...
@@ -17,8 +17,9 @@ from runoptpilot import Runoptpilot
from
opaldict
import
OpalDict
def
getNearestRestartStep
(
restart_pos
,
fn
):
# print 'pos= ',restart_pos,' fn= ',fn
#res = commands.getoutput('H5getStep ' + str(restart_pos) + " " + fn);
print
(
'pos= '
,
restart_pos
,
' fn= '
,
fn
)
res
=
subprocess
.
check_output
(
'H5getStep '
+
str
(
restart_pos
)
+
" "
+
fn
);
return
int
(
res
.
split
(
"="
)[
2
])
def
getBaseName
():
...
...
@@ -87,7 +88,7 @@ def traverseRanges(list, opaldict, args):
if
args
[
10
]:
print
(
"... finished!
\n
"
)
else
:
print
(
"SGE-ID=
"
,
qid
,
'
\n
'
)
print
(
"SGE-ID=
{}
\n
"
.
format
(
qid
)
)
else
:
traverseRanges
(
tail
,
opaldict
,
args
)
curval
=
curval
+
step
...
...
@@ -179,14 +180,14 @@ def main(argv):
if
doNobatch
:
print
(
"... finished!
\n
"
)
else
:
print
(
"SGE-ID=
"
,
qid
,
'
\n
'
)
print
(
"SGE-ID=
{}
\n
"
.
format
(
qid
))
elif
not
opaldict
.
hasRanges
():
sim
=
Simulation
(
opaldict
)
qid
=
sim
.
run
(
N
,
baseFileName
,
restart_step
,
inputfilePath
,
tmplFile
,
oinpFile
,
restart_file
,
doTest
,
doKeep
,
doNobatch
,
info
,
queue
,
hypert
)
if
doNobatch
:
print
(
"... finished!
\n
"
)
else
:
print
(
"SGE-ID=
"
,
qid
,
'
\n
'
)
print
(
"SGE-ID=
{}
\n
"
.
format
(
qid
)
)
else
:
ranges
=
opaldict
.
Range
()
...
...
runOPAL/simulation.py
View file @
34a0aeea
...
...
@@ -112,8 +112,8 @@ class Simulation:
if
not
doNobatch
:
#hostname = commands.getoutput("hostname")
hostname
=
subprocess
.
check_output
(
'hostname'
)
print
(
"On host
"
,
hostname
.
strip
(
))
hostname
=
(
subprocess
.
check_output
(
'hostname'
)
.
decode
(
'utf-8'
)).
strip
()
print
(
"On host
{}"
.
format
(
hostname
))
if
os
.
getenv
(
"SGE_TIME"
):
print
(
"You use deprecated environment variable SGE_TIME. Please use in the future TIME"
)
...
...
@@ -134,7 +134,7 @@ class Simulation:
queue
=
os
.
getenv
(
"SGE_QUEUE"
,
"prime_bd.q"
)
# Merlin5
if
(
hostname
.
startswith
(
b
"merlin-l"
)):
if
(
hostname
.
startswith
(
"merlin-l"
)):
batchsys
=
'SLURM'
runfile
=
'run.merlin5'
time
=
os
.
getenv
(
"SLURM_TIME"
,
"24:00:00"
)
...
...
@@ -143,27 +143,27 @@ class Simulation:
self
.
WriteMerlin5
(
opalexe
,
oinpFile
,
CORES
,
time
,
ram
,
info
,
runfile
,
partition
)
# ANL blues.lcrc.anl.gov
elif
(
hostname
.
startswith
(
b
"blogin"
)):
elif
(
hostname
.
startswith
(
"blogin"
)):
batchsys
=
'PBS'
runfile
=
'run.blues'
self
.
WritePBSBlues
(
opalexe
,
oinpFile
,
CORES
,
time
,
ram
,
info
,
queue
)
elif
(
hostname
.
startswith
(
b
"bebop"
)
or
hostname
.
startswith
(
b
"bdw"
)
or
hostname
.
startswith
(
b
"knl"
)):
elif
(
hostname
.
startswith
(
"bebop"
)
or
hostname
.
startswith
(
"bdw"
)
or
hostname
.
startswith
(
"knl"
)):
batchsys
=
'SLURM'
runfile
=
'run.bebop'
self
.
WriteBebop
(
opalexe
,
oinpFile
,
CORES
,
time
,
ram
,
info
,
runfile
,
queue
,
hypert
)
elif
(
hostname
.
startswith
(
b
"cori"
)):
elif
(
hostname
.
startswith
(
"cori"
)):
batchsys
=
'SLURM'
runfile
=
'run.cori'
self
.
WriteCori
(
opalexe
,
oinpFile
,
CORES
,
time
,
ram
,
info
,
runfile
)
elif
(
hostname
.
startswith
(
b
"edison"
)):
elif
(
hostname
.
startswith
(
"edison"
)):
batchsys
=
'SLURM'
runfile
=
'run.edison'
self
.
WriteEdison
(
opalexe
,
oinpFile
,
CORES
,
time
,
ram
,
info
,
runfile
)
elif
(
hostname
.
startswith
(
b
"daint"
)):
elif
(
hostname
.
startswith
(
"daint"
)):
batchsys
=
'SLURM'
runfile
=
'run.daint'
time
=
os
.
getenv
(
"SLURM_TIME"
,
"24:00:00"
)
...
...
@@ -171,7 +171,7 @@ class Simulation:
partition
=
os
.
getenv
(
"SLURM_PARTITION"
,
"normal"
)
self
.
WritePizDaint
(
opalexe
,
oinpFile
,
CORES
,
time
,
ram
,
info
,
runfile
,
partition
)
elif
(
hostname
.
startswith
(
b
"eofe"
)):
elif
(
hostname
.
startswith
(
"eofe"
)):
batchsys
=
'SLURM'
runfile
=
'run.engaging'
time
=
os
.
getenv
(
"SLURM_TIME"
,
"24:00:00"
)
...
...
@@ -191,17 +191,17 @@ class Simulation:
if
doNobatch
:
print
(
'Done with setup of the OPAL simulation and executing the job on '
+
str
(
CORES
)
+
' cores...
\n\n\n
'
)
ofn
,
fileExtension
=
os
.
path
.
splitext
(
oinpFile
)
print
(
'STD output is written to
'
+
ofn
+
'.out'
)
print
(
'STD output is written to
{}.out'
.
format
(
ofn
)
)
execommand
=
'mpirun -np '
+
str
(
CORES
)
+
' '
+
opalexe
+
' '
+
oinpFile
+
' 2>&1 | tee '
+
ofn
+
'.out'
qid
=
commands
.
get
output
(
execommand
)
qid
=
subprocess
.
check_
output
(
execommand
)
os
.
chdir
(
'..'
)
return
-
1
else
:
qid
=
""
if
batchsys
==
'SLURM'
:
qid
=
commands
.
getoutput
(
'sbatch
'
+
runfile
+
' | awk
\'
{print $3}
\'
'
)
print
(
'Done with setup of the OPAL simulation and submitting the job with
'
,
CORES
,
'
cores
\n\n\n
'
)
qid
=
subprocess
.
call
([
'sbatch
'
,
runfile
,
'|'
,
'awk'
,
'
\'
{print $3}
\'
'
]
)
print
(
'Done with setup of the OPAL simulation and submitting the job with
{}
cores
\n\n\n
'
.
format
(
CORES
)
)
elif
batchsys
==
'PBS'
:
print
(
'Done with setup of the OPAL simulation, please submit the job yourself'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment