Commit 72e14e0d authored by bellotti_r's avatar bellotti_r
Browse files

Added code that allows to run commands after OPAL has finished; improved documentation

parent 04c6689c
......@@ -91,7 +91,8 @@ class Simulation:
def run(self, N, baseFileName, inputfilePath, tmplFile, oinpFile,
doTest, doKeep, doNobatch, doOptimize, info, queue, hypert, quiet,
preCommand=''):
preCommand='',
postCommand=''):
'''
Run an OPAL simulation.
......@@ -112,14 +113,15 @@ class Simulation:
then the data file must be called mysim.data
and the base name is mysim
inputfilePath: str
Path to the directory that contains the .in file
(if running an optimisation).
If running a single simulation: Path to the directory that
contains the .tmpl file(s)
Path to the directory that contains the .data file
tmplFile: str
Path to the .tmpl file
oinpFile: str
Path to the .in file (called Opal in file)
Path to the .in file (called Opal in file) that will be written.
Can be a relative or an absolute path.
The parent directory must already exist.
The other output files (.h5, .stat, .lbal) are also written
to the parent directory of oinpFile.
doTest: bool
if True, does everything but submitting the job
doKeep: bool
......@@ -142,6 +144,9 @@ class Simulation:
preCommand: str (optional)
Shell commands to prepend to the launcher in the SLURM script.
Needed to e. g. load modules before launching the job.
postCommand: str (optional)
Sheel commands to append to the launcher in the SLURM script.
Useful for cleanup actions etc.
'''
# make directory name indicating changed values
self.dirname = baseFileName
......@@ -262,7 +267,8 @@ class Simulation:
ram = os.getenv("SLURM_RAM", "36")
partition = os.getenv("SLURM_PARTITION", "daily")
self.WriteMerlin6(opalexe, oinpFile, CORES, time,
ram, info, runfile, partition, preCommand)
ram, info, runfile, partition,
preCommand, postCommand)
# ANL theta.alcf.anl.gov
elif (hostname.startswith("theta")):
......@@ -478,7 +484,7 @@ class Simulation:
myfile.close()
def WriteMerlin6(self, opalexe, oinpFile, cores, time,
ram, info, name, partition, preCommand):
ram, info, name, partition, preCommand, postCommand):
# ADA this is for the new PSI Merlin6
title = oinpFile.partition(".")[0]
myfile = open(name, 'w')
......@@ -500,6 +506,7 @@ class Simulation:
s1 += "#SBATCH --sockets-per-node=2 \n"
s1 += preCommand + '\n'
s1 += f"mpirun {opalexe} {oinpFile} --info {str(info)}\n"
s1 += postCommand + '\n'
myfile.write(s1)
myfile.close()
......
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