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);
62 return isInitialized != 0;
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) {
bool isInitialized()
Whether Tpetra is in an initialized state.
void printOnce(std::ostream &out, const std::string &s, const Teuchos::Comm< int > *comm)
Print on one process of the given communicator, or at least try to do so (if MPI is not initialized)...
Declaration of Tpetra::Details::printOnce.
bool mpiIsFinalized()
Has MPI_Finalize been called (on this process)?
bool mpiIsInitialized()
Has MPI_Init been called (on this process)?