[MOAB-dev] r2016 - MOAB/trunk/parallel

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Tue Jul 15 18:43:27 CDT 2008


Author: kraftche
Date: 2008-07-15 18:43:26 -0500 (Tue, 15 Jul 2008)
New Revision: 2016

Modified:
   MOAB/trunk/parallel/parallel_hdf5_test.cc
Log:
add -p flag to pause all procs for 30 secons, allowing a debugger to be attached to one or more of them

Modified: MOAB/trunk/parallel/parallel_hdf5_test.cc
===================================================================
--- MOAB/trunk/parallel/parallel_hdf5_test.cc	2008-07-15 21:22:00 UTC (rev 2015)
+++ MOAB/trunk/parallel/parallel_hdf5_test.cc	2008-07-15 23:43:26 UTC (rev 2016)
@@ -8,6 +8,7 @@
 
 #include <iostream>
 #include <mpi.h>
+#include <unistd.h>
 
 #define STRINGIFY_(X) #X
 #define STRINGIFY(X) STRINGIFY_(X)
@@ -29,19 +30,31 @@
 void test_var_length_parallel();
 
 bool KeepTmpFiles = false;
+bool PauseOnStart = false;
 
 int main( int argc, char* argv[] )
 {
   int err = MPI_Init( &argc, &argv );
   CHECK(!err);
 
-  if (argc == 2 && !strcmp(argv[1],"-k"))
-    KeepTmpFiles = true;
-  else if (argc != 1) {
-    std::cerr << "Usage: " << argv[0] << " [-k]" << std::endl;
-    return 1;
+  for (int i = 1; i < argc; ++i) {
+    if (!strcmp( argv[i], "-k"))
+      KeepTmpFiles = true;
+    else if (!strcmp( argv[i], "-p"))
+      PauseOnStart = true;
+    else {
+      std::cerr << "Usage: " << argv[0] << " [-k] [-p]" << std::endl;
+      return 1;
+    }
   }
   
+  if (PauseOnStart) {
+    int rank;
+    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+    printf("Rank %2d PID %lu\n", rank, (unsigned long)getpid());
+    sleep(30);
+  }
+  
   int result = 0;
   result += RUN_TEST( test_write_elements );
   result += RUN_TEST( test_write_shared_sets );
@@ -79,10 +92,14 @@
     CHECK_ERR(rval);
   }
   
+  if (procnum == 0 && KeepTmpFiles)
+    std::cout << "Wrote file: \"" << tmp_filename << "\"\n";
+  
   moab.delete_mesh();
   if (procnum == 0) {
     rval = moab.load_file( tmp_filename, set );
-    remove( tmp_filename );
+    if (!KeepTmpFiles)
+      remove( tmp_filename );
     CHECK_ERR(rval);
   }
 }




More information about the moab-dev mailing list