]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Disable some MPI-only code if we haven't configured to use MPI.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 27 Jun 2013 16:09:46 +0000 (16:09 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 27 Jun 2013 16:09:46 +0000 (16:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@29893 0785d39b-7218-0410-832d-ea1e28bc413d

tests/tests.h

index 4dfffcbe917bea546bd1f93ace07e5115678fec0..b2feb8cb053f025cef930b0c22f4843bd1e273f7 100644 (file)
@@ -73,10 +73,12 @@ output_file_for_mpi (const std::string &directory)
 #endif
 }
 
+
 inline
 void
 mpi_initlog(const char* filename, bool console=false)
 {
+#ifdef DEAL_II_WITH_MPI
   unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
   if (myid == 0)
     {
@@ -89,8 +91,12 @@ mpi_initlog(const char* filename, bool console=false)
 //TODO: Remove this line and replace by test_mode()
       deallog.threshold_float(1.e-8);
     }
+#else
+  // can't use this function if not using MPI
+  Assert (false, ExcInternalError());
+#endif
 }
-  
+
 
 
 /* helper class to include the deallogs of all processors
@@ -101,6 +107,7 @@ class MPILogInitAll
     MPILogInitAll(const char* filename, bool console=false)
                    : m_filename(filename)
       {
+#ifdef DEAL_II_WITH_MPI
        unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
        deallogname = output_file_for_mpi(JobIdentifier::base_name(filename));
        if (myid != 0)
@@ -113,46 +120,55 @@ class MPILogInitAll
 //TODO: Remove this line and replace by test_mode()
        deallog.threshold_float(1.e-8);
        deallog.push(Utilities::int_to_string(myid));
+#else
+       // can't use this function if not using MPI
+       Assert (false, ExcInternalError());
+#endif
       }
 
     ~MPILogInitAll()
       {
+#ifdef DEAL_II_WITH_MPI
        unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
        unsigned int nproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD);
-       
+
        deallog.pop();
        if (myid!=0)
          {
            deallog.detach();
            deallogfile.close();
          }
-       
+
        MPI_Barrier(MPI_COMM_WORLD);
 
        if (myid==0)
-         {     
+         {
            for (unsigned int i=1;i<nproc;++i)
              {
                std::string filename = output_file_for_mpi(JobIdentifier::base_name(m_filename.c_str()))
                                       + Utilities::int_to_string(i);
                std::ifstream in(filename.c_str());
                Assert (in, ExcIO());
-               
+
                while (in)
                  {
                    std::string s;
                    std::getline(in, s);
                    deallog.get_file_stream() << s << "\n";
                  }
-               in.close();         
+               in.close();
                std::remove (filename.c_str());
              }
          }
+#else
+       // can't use this function if not using MPI
+       Assert (false, ExcInternalError());
+#endif
       }
   private:
 
     std::string m_filename;
-    
+
 };
 
 

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.