[MOAB-dev] r4165 - in MOAB/trunk/src: . moab

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Mon Sep 27 15:20:08 CDT 2010


Author: kraftche
Date: 2010-09-27 15:20:08 -0500 (Mon, 27 Sep 2010)
New Revision: 4165

Modified:
   MOAB/trunk/src/Core.cpp
   MOAB/trunk/src/moab/Core.hpp
Log:
make sure MPI is initialized before trying to initialize MPE

Modified: MOAB/trunk/src/Core.cpp
===================================================================
--- MOAB/trunk/src/Core.cpp	2010-09-27 20:07:31 UTC (rev 4164)
+++ MOAB/trunk/src/Core.cpp	2010-09-27 20:20:08 UTC (rev 4165)
@@ -156,9 +156,20 @@
 ErrorCode Core::initialize()
 {
 #ifdef USE_MPI
-  writeMPELog = ! MPE_Initialized_logging();
-  if (writeMPELog)
-    MPE_Init_log();
+  int flag;
+  if (MPI_SUCCESS == MPI_Initialized(&flag)) {
+    mpiFinalize = !flag;
+    if (mpiFinalize) {
+      char argv0[] = "MOAB";
+      int one = 1;
+      char* argv[] = { argv0, 0 };
+      char** ptr = argv;
+      MPI_Init( &one, &ptr );
+    }
+    writeMPELog = ! MPE_Initialized_logging();
+    if (writeMPELog)
+      MPE_Init_log();
+  }
 #endif
 
   geometricDimension = 3;
@@ -248,6 +259,8 @@
       logfile = default_log;
     MPE_Finish_log( logfile );
   }
+  if (mpiFinalize)
+    MPI_Finalize();
 #endif
 }
 

Modified: MOAB/trunk/src/moab/Core.hpp
===================================================================
--- MOAB/trunk/src/moab/Core.hpp	2010-09-27 20:07:31 UTC (rev 4164)
+++ MOAB/trunk/src/moab/Core.hpp	2010-09-27 20:20:08 UTC (rev 4165)
@@ -1238,6 +1238,7 @@
   ReaderWriterSet* readerWriterSet;
 
   Error* mError;
+  bool mpiFinalize;
   int writeMPELog;
 };
 



More information about the moab-dev mailing list