mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
parent
967622305c
commit
d7eb6e3852
5 changed files with 38 additions and 33 deletions
|
|
@ -254,7 +254,7 @@ foreach(test ${TESTS})
|
|||
add_test(NAME ${TEST_NAME}
|
||||
WORKING_DIRECTORY ${TEST_PATH}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $<TARGET_FILE:openmc>
|
||||
--mpi_exec)
|
||||
--mpi_exec $ENV{MPI_DIR}/bin/mpiexec)
|
||||
|
||||
else(${MPI_ENABLED})
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class Executor(object):
|
|||
def run_simulation(self, particles=None, threads=None,
|
||||
geometry_debug=False, restart_file=None,
|
||||
tracks=False, mpi_procs=1, output=True,
|
||||
openmc_exec='openmc'):
|
||||
openmc_exec='openmc', mpi_exec=None):
|
||||
"""Run an OpenMC simulation.
|
||||
|
||||
Parameters
|
||||
|
|
@ -107,7 +107,21 @@ class Executor(object):
|
|||
post_args += '-t'
|
||||
|
||||
if isinstance(mpi_procs, Integral) and mpi_procs > 1:
|
||||
pre_args += 'mpirun -n {0} '.format(mpi_procs)
|
||||
np_present = True
|
||||
else:
|
||||
np_present = False
|
||||
|
||||
if mpi_exec is not None and isinstance(mpi_exec, basestring):
|
||||
mpi_exec_present = True
|
||||
else:
|
||||
mpi_exec_present = False
|
||||
|
||||
if np_present or mpi_exec_present:
|
||||
if mpi_exec_present:
|
||||
pre_args += mpi_exec + ' '
|
||||
else:
|
||||
pre_args += 'mpirun '
|
||||
pre_args += '-n {0} '.format(mpi_procs)
|
||||
|
||||
command = pre_args + openmc_exec + ' ' + post_args
|
||||
|
||||
|
|
|
|||
|
|
@ -77,12 +77,6 @@ class SourceFileTestHarness(TestHarness):
|
|||
'Source file is not a binary or hdf5 file.'
|
||||
|
||||
def _run_openmc_restart(self):
|
||||
# Get the number of MPI processes.
|
||||
if self._opts.mpi_exec:
|
||||
mpi_procs = int(self._opts.mpi_np)
|
||||
else:
|
||||
mpi_procs = 1
|
||||
|
||||
# Get the name of the source file.
|
||||
source = glob.glob(os.path.join(os.getcwd(), 'source.10.*'))
|
||||
|
||||
|
|
@ -91,10 +85,7 @@ class SourceFileTestHarness(TestHarness):
|
|||
fh.write(settings2.format(source[0].split('.')[-1]))
|
||||
|
||||
# Run OpenMC.
|
||||
executor = Executor()
|
||||
returncode = executor.run_simulation(mpi_procs=mpi_procs,
|
||||
openmc_exec=self._opts.exe)
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
self._run_openmc()
|
||||
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
|
|
|
|||
|
|
@ -35,20 +35,21 @@ class StatepointRestartTestHarness(TestHarness):
|
|||
self._cleanup()
|
||||
|
||||
def _run_openmc_restart(self):
|
||||
# Get the number of MPI processes.
|
||||
if self._opts.mpi_exec:
|
||||
mpi_procs = int(self._opts.mpi_np)
|
||||
else:
|
||||
mpi_procs = 1
|
||||
|
||||
# Get the name of the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))
|
||||
|
||||
# Run OpenMC
|
||||
executor = Executor()
|
||||
returncode = executor.run_simulation(mpi_procs=mpi_procs,
|
||||
restart_file=statepoint,
|
||||
openmc_exec = self._opts.exe)
|
||||
|
||||
if self._opts.mpi_exec is not None:
|
||||
returncode = executor.run_simulation(mpi_procs=mpi_procs,
|
||||
restart_file=statepoint,
|
||||
openmc_exec=self._opts.exe,
|
||||
mpi_exec=self._opts.mpi_exec)
|
||||
|
||||
else:
|
||||
returncode = executor.run_simulation(openmc_exec=self._opts.exe)
|
||||
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -58,24 +58,23 @@ class TestHarness(object):
|
|||
def _parse_args(self):
|
||||
parser = OptionParser()
|
||||
parser.add_option('--exe', dest='exe', default='openmc')
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', action='store_true',
|
||||
default=False)
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default=None)
|
||||
parser.add_option('--mpi_np', dest='mpi_np', type=int, default=3)
|
||||
parser.add_option('--update', dest='update', action='store_true',
|
||||
default=False)
|
||||
(self._opts, self._args) = parser.parse_args()
|
||||
|
||||
def _run_openmc(self):
|
||||
print('******')
|
||||
print(self._opts.exe)
|
||||
if self._opts.mpi_exec:
|
||||
mpi_procs = self._opts.mpi_np
|
||||
else:
|
||||
mpi_procs = 1
|
||||
|
||||
executor = Executor()
|
||||
returncode = executor.run_simulation(mpi_procs=mpi_procs,
|
||||
openmc_exec=self._opts.exe)
|
||||
|
||||
if self._opts.mpi_exec is not None:
|
||||
returncode = executor.run_simulation(mpi_procs=mpi_procs,
|
||||
openmc_exec=self._opts.exe,
|
||||
mpi_exec=self._opts.mpi_exec)
|
||||
|
||||
else:
|
||||
returncode = executor.run_simulation(openmc_exec=self._opts.exe)
|
||||
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def _test_output_created(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue