From 2c903e7f44c97cb7efc6bd5f7bb0c35ab847c3d3 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Fri, 21 Sep 2018 14:18:58 +0200 Subject: [PATCH] Force no output for non rank 0 mpi processes --- src/utils/PastisUtils.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/utils/PastisUtils.cpp b/src/utils/PastisUtils.cpp index 2744e38a7..72764650f 100644 --- a/src/utils/PastisUtils.cpp +++ b/src/utils/PastisUtils.cpp @@ -19,6 +19,18 @@ std::string initialize(int& argc, char* argv[]) { MPI_Init(&argc, &argv); + { + const int mpi_rank + =[](){ + int mpi_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + return mpi_rank; + }(); + if (mpi_rank != 0) { + pout.setOutput(null_stream); + } + } + long unsigned number = 10; std::string filename; @@ -118,10 +130,9 @@ void finalize() return mpi_size; }(); - std::cout << rang::fgB::green << "Terminating process " << rang::fg::reset - << rang::fgB::yellow << mpi_rank << rang::fg::reset << " of " - << rang::style::bold << mpi_size << rang::style::reset << '\n';; - + pout() << rang::fgB::green << "Terminating process " << rang::fg::reset + << rang::fgB::yellow << mpi_rank << rang::fg::reset << " of " + << rang::style::bold << mpi_size << rang::style::reset << '\n';; Kokkos::finalize(); MPI_Finalize(); -- GitLab