
from .dummy_comm import DummyCommunicator
try:
    from mpi4py import MPI
    comm = MPI.COMM_WORLD
    have_mpi = True
except ImportError:
    comm = DummyCommunicator()
    have_mpi = False

from .nuclide import *
from .chain import *
from .operator import *
from .reaction_rates import *
from .abc import *
from .results import *
from .results_list import *
from .integrator import *


from .dummy_comm import DummyCommunicator

try:
    from mpi4py import MPI

    comm = MPI.COMM_WORLD
    have_mpi = True
    # check if running with MPI and if hdf5 is MPI-enabled
    from h5py import get_config

    if not get_config().mpi and comm.size > 1:
        # Raise exception only on process 0
        if comm.rank:
            from sys import exit

            exit()
        raise RuntimeError(
            "Need MPI-enabled HDF5 install to perform depletion with MPI"
        )
except ImportError:
    comm = DummyCommunicator()
    have_mpi = False

from .nuclide import *
from .chain import *
from .operator import *
from .reaction_rates import *
from .abc import *
from .results import *
from .results_list import *
from .integrator import *

Check that hdf5 has MPI if performing depletion with MPI
Check that hdf5 has MPI if performing depletion with MPI

Check added in openmc/depletion/__init__.py.
Without this check, the exporting of the Results to hdf5 will
hang, as the second process attempts to write to a file
that has already been opened on another process.
This error is only raised after a full transport calculation
has been run.
The check raises a more helpful error directly at the import
from openmc.deplete, prior to transport calculations.

  
  from .dummy_comm import DummyCommunicator
+ 
  try:
      from mpi4py import MPI
+ 
      comm = MPI.COMM_WORLD
      have_mpi = True
+     # check if running with MPI and if hdf5 is MPI-enabled
+     from h5py import get_config
+ 
+     if not get_config().mpi and comm.size > 1:
+         # Raise exception only on process 0
+         if comm.rank:
+             from sys import exit
+ 
+             exit()
+         raise RuntimeError(
+             "Need MPI-enabled HDF5 install to perform depletion with MPI"
+         )
  except ImportError:
      comm = DummyCommunicator()
      have_mpi = False
  
  from .nuclide import *
  from .chain import *
  from .operator import *
  from .reaction_rates import *
  from .abc import *
  from .results import *
  from .results_list import *
  from .integrator import *
  
Check that hdf5 has MPI if performing depletion with MPI
## Code Before:

from .dummy_comm import DummyCommunicator
try:
    from mpi4py import MPI
    comm = MPI.COMM_WORLD
    have_mpi = True
except ImportError:
    comm = DummyCommunicator()
    have_mpi = False

from .nuclide import *
from .chain import *
from .operator import *
from .reaction_rates import *
from .abc import *
from .results import *
from .results_list import *
from .integrator import *

## Instruction:
Check that hdf5 has MPI if performing depletion with MPI
## Code After:

from .dummy_comm import DummyCommunicator

try:
    from mpi4py import MPI

    comm = MPI.COMM_WORLD
    have_mpi = True
    # check if running with MPI and if hdf5 is MPI-enabled
    from h5py import get_config

    if not get_config().mpi and comm.size > 1:
        # Raise exception only on process 0
        if comm.rank:
            from sys import exit

            exit()
        raise RuntimeError(
            "Need MPI-enabled HDF5 install to perform depletion with MPI"
        )
except ImportError:
    comm = DummyCommunicator()
    have_mpi = False

from .nuclide import *
from .chain import *
from .operator import *
from .reaction_rates import *
from .abc import *
from .results import *
from .results_list import *
from .integrator import *
