]> git.treefish.org Git - phys/latlib.git/blobdiff - o815/o815.cpp
Added writeoutdir sequencing for equal timestamps.
[phys/latlib.git] / o815 / o815.cpp
index cc72a149b5073edeea5a0f8498a73b7d18ab8373..630d6803a4471c9ddfeccdde07097978c4f02f44 100644 (file)
@@ -2,8 +2,11 @@
 
 #include <sstream>
 #include <iomanip>
+#include <cstring>
 
+#ifndef MPI_DISABLED
 #include <mpi.h>
+#endif
 
 #include "latlib/progress.h"
 
@@ -25,9 +28,14 @@ o815::o815(int argc, char **argv, const string& _programid, comoption specOps[],
   comargs.idonly = false;
   comargs.showjobnum = false;
 
+#ifndef MPI_DISABLED
   MPI_Init(&argc, &argv);
   MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+#else
+  numprocs = 1;
+  rank = 0;
+#endif
 
   addComOption("lsize",  required_argument, NULL,                'L', "define lattice size",                   "xsize:tsize");
   addComOption("nmeas",  required_argument, NULL,                'N', "set number of measurements",            "nmeas");
@@ -110,15 +118,7 @@ void o815::postParaInit() {
     exit(0);
   }
   
-  if(rank==0) {
-    timestamp = time(NULL);
-    for(int idest=1; idest<numprocs; idest++)
-      MPI_Send(&timestamp, 1, MPI_LONG, idest, 123, MPI_COMM_WORLD);
-  }
-  else if(rank>0)
-    MPI_Recv(&timestamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
-  
-  out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs, timestamp);
+  out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs);
 }
 
 void o815::mainLoop() {
@@ -284,13 +284,17 @@ string o815::headMaster()
 
 o815::~o815() {
   if(comargs.outdir=="") {
+#ifndef MPI_DISABLED
     MPI_Barrier(MPI_COMM_WORLD);
+#endif
     if(rank==0)
       cout << "#end" << endl << flush;
   }
   hypercache::finalize();
   delete out;
+#ifndef MPI_DISABLED
   MPI_Finalize();
+#endif
 }
 
 int o815::nextParas()