42 #include "Tpetra_Details_checkGlobalError.hpp"
44 #include "Teuchos_CommHelpers.hpp"
45 #include "Teuchos_TestForException.hpp"
53 checkGlobalError(std::ostream& globalOutputStream,
54 const bool localSuccess,
55 const char localErrorMessage[],
56 const char globalErrorMessageHeader[],
57 const Teuchos::Comm<int>& comm)
59 using Teuchos::outArg;
60 using Teuchos::REDUCE_MIN;
61 using Teuchos::reduceAll;
64 int lclGood = localSuccess ? 1 : 0;
66 reduceAll(comm, REDUCE_MIN, lclGood, outArg(gblGood));
68 const int myRank = comm.getRank();
70 globalOutputStream << endl << globalErrorMessageHeader
74 if (localSuccess || localErrorMessage ==
nullptr) {
78 std::ostringstream lclMsg;
80 constexpr
int numStars = 60;
81 for (
int star = 0; star < numStars; ++star) {
84 lclMsg << endl <<
"Proc " << myRank <<
": "
85 << localErrorMessage << endl;
89 #ifdef HAVE_TEUCHOS_MPI
90 (void) MPI_Abort(MPI_COMM_WORLD, -1);
92 TEUCHOS_TEST_FOR_EXCEPTION
93 (
true, std::runtime_error,
"Tpetra reports a global error.");
94 #endif // HAVE_TEUCHOS_MPI
Declaration of a function that prints strings from each process.
void gathervPrint(std::ostream &out, const std::string &s, const Teuchos::Comm< int > &comm)
On Process 0 in the given communicator, print strings from each process in that communicator, in rank order.