]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Utilities::System::job_supports_mpi.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Aug 2009 21:27:59 +0000 (21:27 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Aug 2009 21:27:59 +0000 (21:27 +0000)
git-svn-id: https://svn.dealii.org/trunk@19268 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/utilities.h
deal.II/base/source/utilities.cc
deal.II/doc/news/changes.h

index 2e9da44e0e1162441675cd839bf97df5499dc922..bdc90f9c0cfda07518ecf784c537858f77ca7149 100644 (file)
@@ -23,7 +23,8 @@
 #if defined(DEAL_II_COMPILER_SUPPORTS_MPI) || defined(DEAL_II_USE_PETSC)
 #include <mpi.h>
 #else
-typedef int MPI_Comm;
+//typedef int MPI_Comm;
+#include <mpi.h>
 #endif
 
 #ifdef DEAL_II_USE_TRILINOS
@@ -229,6 +230,23 @@ namespace Utilities
                                       */
     std::string get_time ();
 
+                                    /**
+                                     * Return whether (i) deal.II has
+                                     * been compiled to support MPI
+                                     * (for example by compiling with
+                                     * <code>CXX=mpiCC</code>) and if
+                                     * so whether (ii)
+                                     * <code>MPI_Init()</code> has
+                                     * been called (for example using
+                                     * the
+                                     * Utilities::System::MPI_InitFinalize
+                                     * class). In other words, the
+                                     * result indicates whether the
+                                     * current job is running under
+                                     * MPI.
+                                     */
+    bool job_supports_mpi ();
+    
                                     /**
                                      * Return the number of MPI processes
                                      * there exist in the given communicator
index 93dfdb25ce04fc434ae5e2ac4a0d7d6ebe7fea28..6a14aa3f33bbce923b36ad4eddf9300049961de7 100644 (file)
@@ -445,6 +445,15 @@ namespace Utilities
 
     
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+
+    bool job_supports_mpi ()
+    {
+      int MPI_has_been_started = 0;
+      MPI_Initialized(&MPI_has_been_started);
+
+      return (MPI_has_been_started > 0);
+    }
+    
                                 // Unfortunately, we have to work
                                 // around an oddity in the way PETSc
                                 // and some gcc versions interact. If
@@ -506,6 +515,13 @@ namespace Utilities
     
 #else
     
+    bool job_supports_mpi ()
+    {
+      return false;
+    }
+
+
+
     unsigned int get_n_mpi_processes (const MPI_Comm &)
     {
       return 1;
index bb51e567f152c30aab1c4548c5cce0a7ad68de17..b5944929ba955639811227c8908c9457549dbd0d 100644 (file)
@@ -169,6 +169,15 @@ inconvenience this causes.
 <h3>base</h3>
 
 <ol>
+  <li>
+  <p>
+  New: The Utilities::System::job_supports_mpi() can be used to query whether
+  the current job runs under MPI or not.
+  <br>
+  (WB 2009/08/14)
+  </p>
+  </li>
+
   <li>
   <p>
   New: The Utilities::Trilinos::comm_self function return an MPI

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.