44 #if defined(HAVE_TPETRACORE_MPI)
45 # include "Teuchos_DefaultMpiComm.hpp"
47 # include "Teuchos_Comm.hpp"
48 #endif // defined(HAVE_TPETRACORE_MPI)
53 #if defined(HAVE_TPETRACORE_MPI)
56 (void) MPI_Initialized (&isInitialized);
65 #endif // defined(HAVE_TPETRACORE_MPI)
70 #if defined(HAVE_TPETRACORE_MPI)
73 (void) MPI_Finalized (&isFinalized);
79 return isFinalized != 0;
82 #endif // defined(HAVE_TPETRACORE_MPI)
85 #if defined(HAVE_TPETRACORE_MPI)
86 bool isMpiComm (
const Teuchos::Comm<int>& comm)
88 using mpi_comm_type = Teuchos::MpiComm<int>;
89 return dynamic_cast<const mpi_comm_type* > (&comm) !=
nullptr;
92 bool isMpiComm (
const Teuchos::Comm<int>& )
96 #endif // defined(HAVE_TPETRACORE_MPI)
98 int getRankHarmlessly (
const Teuchos::Comm<int>& comm)
100 if (mpiIsInitialized () && ! mpiIsFinalized () && isMpiComm (comm)) {
101 return comm.getRank ();
113 const std::string& s,
114 const Teuchos::Comm<int>* comm)
116 if (comm ==
nullptr || getRankHarmlessly (*comm) == 0) {