From 6a2ee1062c15faaa6ad0a6d798d71123f6fa9172 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Thu, 30 May 2013 00:35:40 +0000 Subject: [PATCH] add MPILogInitAll helper class for mpi tests git-svn-id: https://svn.dealii.org/trunk@29666 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/tests.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/tests.h b/tests/tests.h index 2454dacb73..90fc33ab82 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -90,6 +90,68 @@ mpi_initlog(const char* filename, bool console=false) deallog.threshold_float(1.e-8); } } + + + +/* helper class to include the deallogs of all processors + on proc 0 */ +class MPILogInitAll +{ + public: + MPILogInitAll(const char* filename, bool console=false) + : m_filename(filename) + { + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + deallogname = output_file_for_mpi(JobIdentifier::base_name(filename)); + if (myid != 0) + deallogname = deallogname + Utilities::int_to_string(myid); + deallogfile.open(deallogname.c_str()); + deallog.attach(deallogfile); + if (!console) + deallog.depth_console(0); + +//TODO: Remove this line and replace by test_mode() + deallog.threshold_float(1.e-8); + deallog.push(Utilities::int_to_string(myid)); + } + + ~MPILogInitAll() + { + deallog.pop(); + MPI_Barrier(MPI_COMM_WORLD); + + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + unsigned int nproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + if (myid==0) + { + for (unsigned int i=1;i