Use unittest.Mock for MPI when collecting proc_time

This commit is contained in:
Andrew Johnson 2019-06-26 17:52:27 -05:00
parent 8deda73647
commit 544cbd0c39
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB
2 changed files with 5 additions and 4 deletions

View file

@ -5,16 +5,17 @@ openmc.deplete
A depletion front-end tool.
"""
from unittest import Mock
from .dummy_comm import DummyCommunicator
try:
from mpi4py import MPI
comm = MPI.COMM_WORLD
have_mpi = True
mpi_sum = MPI.SUM
except ImportError:
comm = DummyCommunicator()
have_mpi = False
mpi_sum = lambda x: x
MPI = Mock()
from .nuclide import *
from .chain import *

View file

@ -10,7 +10,7 @@ from warnings import warn
import numpy as np
import h5py
from . import comm, have_mpi, mpi_sum
from . import comm, have_mpi, MPI
from .reaction_rates import ReactionRates
_VERSION_RESULTS = (1, 0)
@ -452,7 +452,7 @@ class Results(object):
results.power = power
results.proc_time = proc_time
if results.proc_time is not None:
results.proc_time = comm.reduce(proc_time, op=mpi_sum)
results.proc_time = comm.reduce(proc_time, op=MPI.SUM)
results.export_to_hdf5("depletion_results.h5", step_ind)