Commit e542320f authored by ext-neveu_n's avatar ext-neveu_n
Browse files

Starting to add --quiet option

parent c2111cbc
......@@ -99,6 +99,7 @@ main method
def main(argv):
N = -1 # a running number; if given use it to label directory!
quiet = False
doTest = False
doKeep = False
doNobatch = False
......@@ -133,6 +134,8 @@ def main(argv):
elif arg.startswith("--help"):
printUsage()
exit()
elif arg.startswith("--quiet"):
quiet = True
elif arg.startswith("--"):
print(arg,'is not a valid option, see --help for the available options')
exit()
......@@ -183,7 +186,7 @@ def main(argv):
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)
qid = sim.run(N, baseFileName, restart_step, inputfilePath, tmplFile, oinpFile, restart_file, doTest, doKeep, doNobatch, info, queue, hypert, quiet)
if doNobatch:
print( "... finished!\n")
else:
......
......@@ -26,7 +26,7 @@ class Simulation:
else:
return True
def createDirectory(self, dirname, doKeep):
def createDirectory(self, dirname, doKeep, quiet):
# If there's already a directory remove it...
if os.path.isdir(self.dirname):
if doKeep:
......@@ -34,14 +34,15 @@ class Simulation:
print( self.dirname)
return False
else:
print( 'REMOVE existing directory {}'.format(self.dirname))
if quiet == False:
print( 'REMOVE existing directory {}'.format(self.dirname))
shutil.rmtree(self.dirname)
# create directory
os.mkdir(self.dirname)
return True
def run(self,N, baseFileName, restart_step, inputfilePath, tmplFile, oinpFile, restart_file, doTest, doKeep, doNobatch, info, queue, hypert):
def run(self,N, baseFileName, restart_step, inputfilePath, tmplFile, oinpFile, restart_file, doTest, doKeep, doNobatch, info, queue, hypert, quiet):
# make directory name indicating changed values
self.dirname = baseFileName
if N >= 0:
......@@ -55,7 +56,7 @@ class Simulation:
print("CORES not set bye bye")
sys.exit(1)
if self.createDirectory(self.dirname, doKeep) == False:
if self.createDirectory(self.dirname, doKeep, quiet) == False:
print( "Simulation results already exist")
return
os.chdir(self.dirname)
......@@ -102,24 +103,27 @@ class Simulation:
opalexe = '$OPAL_EXE_PATH/opal'
else:
opalexe = 'opal'
print( 'Simulation directory is {} using OPAL at {}'.format(self.dirname, os.environ.get('OPAL_EXE_PATH')))
print( 'Using templatefile at ' + inputfilePath)
print( 'Using fieldmaps at ' + fieldmapPath)
print( 'Parameter set in ' + oinpFile + ' are:')
if quiet == False:
print( 'Simulation directory is {} using OPAL at {}'.format(self.dirname, os.environ.get('OPAL_EXE_PATH')))
print( 'Using templatefile at ' + inputfilePath)
print( 'Using fieldmaps at ' + fieldmapPath)
print( 'Parameter set in ' + oinpFile + ' are:')
for s, value in sorted(self.opaldict.items()):
print( ' :::: ' + s + ' = ' + str(value))
if quiet == False:
print( ' :::: ' + s + ' = ' + str(value))
if not doNobatch:
#hostname = commands.getoutput("hostname")
hostname = (subprocess.check_output('hostname').decode('utf-8')).strip()
print("On host {}".format(hostname))
if quiet == False:
print("On host {}".format(hostname))
if os.getenv("SGE_TIME"):
print( "You use deprecated environment variable SGE_TIME. Please use in the future TIME")
time = os.getenv("SGE_TIME")
else:
print('You did not set a time limit. Using default: s_rt=23:59:00,h_rt=24:00:00')
time = os.getenv("TIME", "s_rt=23:59:00,h_rt=24:00:00")
if os.getenv("SGE_RAM"):
......@@ -158,7 +162,7 @@ class Simulation:
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)
self.WriteBebop(opalexe, oinpFile, CORES, time, ram, info, runfile, queue, hypert, quiet)
elif (hostname.startswith("cori")):
batchsys = 'SLURM'
......@@ -190,13 +194,15 @@ class Simulation:
sys.exit(1)
if doTest:
print( 'Done with setup of the OPAL simulation but not submitting the job (--test) \n\n\n')
if quiet == False:
print( 'Done with setup of the OPAL simulation but not submitting the job (--test) \n\n\n')
qid = -1
os.chdir('..')
return qid
if doNobatch:
print( 'Done with setup of the OPAL simulation and executing the job on {} cores...\n\n\n'.format(CORES))
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)
print( 'STD output is written to {}.out'.format(ofn))
#execommand = 'mpirun -np ' + str(CORES) + ' ' + opalexe + ' ' + oinpFile + ' 2>&1 | tee ' + ofn + '.out'
......@@ -212,10 +218,12 @@ class Simulation:
if batchsys == 'SLURM':
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))
if quiet == False:
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')
if quiet == False:
print( 'Done with setup of the OPAL simulation, please submit the job yourself')
os.chdir('..')
return qid
......@@ -417,7 +425,7 @@ class Simulation:
myfile.write(s1)
myfile.close()
def WriteBebop(self, opalexe, oinpFile, cores, time, ram, info, name, queue, hypert):
def WriteBebop(self, opalexe, oinpFile, cores, time, ram, info, name, queue, hypert, quiet):
# BDW and KNL Compute Nodes at ANL
# http://www.lcrc.anl.gov/for-users/using-lcrc/running-jobs/running-jobs-on-bebop/
if type(cores) is str:
......@@ -427,10 +435,12 @@ class Simulation:
#Checking that a valid queue is selected
#Adjusting number of cores for specified queue
if (queue=='bdw' or queue=='bdwall' or queue=='bdwd'):
print('Running on BDW')
if quiet == False:
print('Running on BDW')
coresPerNode = 36 * (hypert+1) # hypert == 0 -> no hyper threading
elif (queue=='knl' or queue=='knlall' or queue=='knld'):
print('Running on KNL')
if quiet == False:
print('Running on KNL')
coresPerNode = 64 * (hypert+1)
else:
print('You have picked a non-valid queue!! Your run will fail!!')
......@@ -502,7 +512,7 @@ class Simulation:
nodes = cores/coresPerNode
tasks_per_node = cores/nodes
print(nodes,cores, tasks_per_node)
#print(nodes,cores, tasks_per_node)
if cores < 512:
queue = 'debug-cache-quad'
......
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