From: kanschat Date: Sun, 26 May 2013 21:38:09 +0000 (+0000) Subject: Macro for opening MPI output files automatically X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fed53fb3397bceb1a4314386885895422c83f090;p=dealii-svn.git Macro for opening MPI output files automatically git-svn-id: https://svn.dealii.org/trunk@29621 0785d39b-7218-0410-832d-ea1e28bc413d --- 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