]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Macro for opening MPI output files automatically
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 26 May 2013 21:38:09 +0000 (21:38 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 26 May 2013 21:38:09 +0000 (21:38 +0000)
git-svn-id: https://svn.dealii.org/trunk@29621 0785d39b-7218-0410-832d-ea1e28bc413d

tests/tests.h

index d61bccee4632813ae139423c928ac75acaf65730..2454dacb734ea694e811f091c049803a92ab3d14 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.