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