################################################################################
#
# TRIQS: a Toolbox for Research in Interacting Quantum Systems
#
# Copyright (C) 2013 by M. Ferrero, O. Parcollet
#
# TRIQS is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
import os
[docs]
def check_for_mpi():
'''
Simple function checking if triqs has been called with
mpirun or without, by checking for typical MPI environment
variables. To enforce the MPI init TRIQS_FORCE_MPI_INIT
can be set manually as env variable.
Returns:
-------
is_mpi: bool
True if triqs called with mpirun
'''
is_mpi = False
# for OpenMPI:
if os.environ.get('OMPI_COMM_WORLD_RANK'):
is_mpi = True
# for MPICH and intel based MPI:
elif os.environ.get('PMI_RANK'):
is_mpi = True
elif os.environ.get('CRAY_MPICH_VERSION'):
is_mpi = True
# to force the MPI init manually
elif os.environ.get('TRIQS_FORCE_MPI_INIT'):
is_mpi = True
else:
print('Warning: could not identify MPI environment!')
return is_mpi
if check_for_mpi():
from .mpi_mpi4py import *
else:
from .mpi_nompi import *