From fed53fb3397bceb1a4314386885895422c83f090 Mon Sep 17 00:00:00 2001 From: kanschat Date: Sun, 26 May 2013 21:38:09 +0000 Subject: [PATCH] Macro for opening MPI output files automatically git-svn-id: https://svn.dealii.org/trunk@29621 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/tests.h | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/tests/tests.h b/tests/tests.h index d61bccee46..2454dacb73 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -59,6 +59,39 @@ initlog(const char* filename, bool console=false) } +// append the directory name with an output file name that indicates +// the number of MPI processes +inline std::string +output_file_for_mpi (const std::string &directory) +{ +#ifdef DEAL_II_WITH_MPI + return (directory + "/ncpu_" + + Utilities::int_to_string (Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD)) + + "/output"); +#else + return (directory + "/ncpu_1/output"); +#endif +} + +inline +void +mpi_initlog(const char* filename, bool console=false) +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + if (myid == 0) + { + deallogname = output_file_for_mpi(JobIdentifier::base_name(filename)); + 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); + } +} + + #ifndef DEAL_II_STACKTRACE_SWITCH #define DEAL_II_STACKTRACE_SWITCH @@ -174,19 +207,6 @@ struct DeadlockKiller DEAL_II_NAMESPACE_CLOSE -// append the directory name with an output file name that indicates -// the number of MPI processes -std::string output_file_for_mpi (const std::string &directory) -{ -#ifdef DEAL_II_WITH_MPI - return (directory + "/ncpu_" + - Utilities::int_to_string (Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD)) + - "/output"); -#else - return (directory + "/ncpu_1/output"); -#endif -} - #endif // __tests_tests_h -- 2.39.5