Commit dc3c5e59 authored by snuverink_j's avatar snuverink_j
Browse files

import cleaning; fix --info command line option; improve logic

parent e756b264
......@@ -9,8 +9,7 @@ Script that launches OPAL simulations
import sys,re,os,string,fileinput,shutil,glob
#import commands
import sys,os,shutil,glob
import subprocess
from simulation import Simulation
from runoptpilot import Runoptpilot
......@@ -70,7 +69,7 @@ once all range variables are fixed to a value. A list entry has the following
['name of var', start_value, end_value, step_value]
def traverseRanges(list, opaldict, args):
def traverseRanges(list, opaldict, args, doNobatch):
head = list[0]
tail = list[1:]
curval = head[1][0]
......@@ -85,12 +84,12 @@ def traverseRanges(list, opaldict, args):
#run simulation
sim = Simulation(opaldict)
qid =*args)
if args[10]:
if doNobatch:
print("... finished!\n")
print("SGE-ID= {}\n".format(qid))
traverseRanges(tail, opaldict, args)
traverseRanges(tail, opaldict, args, doNobatch)
curval = curval + step
......@@ -129,6 +128,8 @@ def main(argv):
doNobatch = True
elif arg.startswith("--optPilot"):
doOptPilot = True
elif arg.startswith("--info"):
info = arg.split("=")[1]
elif arg.startswith("--queue"):
queue = arg.split("=")[1]
elif arg.startswith("--help"):
......@@ -217,7 +218,7 @@ def main(argv):
#run simulations of all possible combinations
args = [N, baseFileName, restart_step, inputfilePath, tmplFile, oinpFile, restart_file, doTest, doKeep, doNobatch, info, queue, hypert, quiet]
traverseRanges(list(ranges.items()), opaldict, args)
traverseRanges(list(ranges.items()), opaldict, args, doNobatch)
# clean up
os.system("rm -f *.bak ")
......@@ -6,9 +6,8 @@ Simulation class handles batch job related things
@version: 0.1
import sys,re,os,string,fileinput,shutil,glob, subprocess #,commands
import time
import numpy as np
import sys,os,shutil, subprocess
#import numpy as np
class Simulation:
......@@ -16,16 +15,6 @@ class Simulation:
self.opaldict = opaldict
self.dirname = ""
def isOldMpiVersion(self):
mpistr = os.environ.get('OPENMPI')
mpiver = mpistr.partition("-")[2].partition('-')[0]
mpiv = mpiver.split(".")
if mpiv[0] == "1" and mpiv[1] >= "4":
return False
return True
def createDirectory(self, dirname, doKeep, quiet):
# If there's already a directory remove it...
if os.path.isdir(self.dirname):
......@@ -196,15 +185,14 @@ class Simulation:
print("Hostname not known bye bye")
qid = -1
if doTest:
if quiet == False:
print( 'Done with setup of the OPAL simulation but not submitting the job (--test) \n\n\n')
qid = -1
return qid
if doNobatch:
elif doNobatch:
if quiet == False:
print( 'Done with setup of the OPAL simulation and executing the job on {} cores...\n\n\n'.format(CORES))
ofn, fileExtension = os.path.splitext(oinpFile)
......@@ -215,13 +203,15 @@ class Simulation:
# There is a solution described at
with open(outfileName,'w') as outfile:
qid =['mpirun', '-np', str(CORES), opalexe, oinpFile], stdout=outfile, stderr=outfile)
return -1
qid = ""
if batchsys == 'SLURM':
qid =['sbatch', runfile, '|', 'awk','\'{print $3}\''])
if batchsys == 'SLURM' or batchsys == 'COBALT':
if batchsys == 'SLURM':
command = 'sbatch'
elif batchsys == 'COBALT':
command = 'qsub'
qid =[command, runfile, '|', 'awk','\'{print $3}\''])
if quiet == False:
print( 'Done with setup of the OPAL simulation and submitting the job with {} cores \n\n\n'.format(CORES))
......@@ -229,12 +219,11 @@ class Simulation:
if quiet == False:
print( 'Done with setup of the OPAL simulation, please submit the job yourself')
if batchsys == 'COBALT':
qid =['qsub', runfile, '|', 'awk','\'{print $3}\''])
print( 'Done with setup of the OPAL simulation and submitting the job with {} cores \n\n\n'.format(CORES))
print("Batch system", batchsys, "not known!")
return qid
return qid
def WriteCori(self, opalexe, oinpFile, cores, time, ram, info, name):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment