triqs.utility.mpi.check_for_mpi

triqs.utility.mpi.check_for_mpi()[source]

Detect whether the current process was launched under MPI.

Inspects a small set of environment variables commonly exported by MPI launchers:

  • OMPI_COMM_WORLD_RANK – Open MPI.

  • PMI_RANK – MPICH and Intel MPI.

  • PMIX_RANK – PMIx (used by srun / Slurm with PMIx support).

  • CRAY_MPICH_VERSION – Cray MPICH.

  • TRIQS_FORCE_MPI_INIT – escape hatch: when set (to any value), MPI initialisation is forced even though none of the launcher variables above are present.

Returns True if any of them is set. Otherwise, it prints a warning to stdout and returns False.

Returns:
bool

True if an MPI environment is detected, False otherwise.