]> git.treefish.org Git - phys/latlib.git/blobdiff - o815/o815.cpp
Revert "Let outdir be created from rank 0."
[phys/latlib.git] / o815 / o815.cpp
index 956ad2e543a6582616a7d501885aa05096c811b2..b68a38b061df92d0741b4a3bdb6ab0f3ce1093e1 100644 (file)
@@ -2,6 +2,11 @@
 
 #include <sstream>
 #include <iomanip>
+#include <cstring>
+
+#ifndef MPI_DISABLED
+#include <mpi.h>
+#endif
 
 #include "latlib/progress.h"
 
@@ -23,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,12 +120,16 @@ void o815::postParaInit() {
   
   if(rank==0) {
     timestamp = time(NULL);
+#ifndef MPI_DISABLED
     for(int idest=1; idest<numprocs; idest++)
       MPI_Send(&timestamp, 1, MPI_LONG, idest, 123, MPI_COMM_WORLD);
+#endif
   }
+#ifndef MPI_DISABLED
   else if(rank>0)
-    MPI_Recv(&timestamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, &mpiStatus);
-  
+    MPI_Recv(&timestamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+#endif  
+
   out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs, timestamp);
 }
 
@@ -149,14 +163,14 @@ void o815::mainLoop() {
        hypercache::readO( (*obsit)->ocid, &readnewObs, &nequileftNewObs );
 
        if ( readnewObs && nequileftNewObs < 0 ) {
-         (*obsit)->meas(true);
+         (*obsit)->meas(true, imeas);
        }
        else {
          if (!nextAlready) {
            Sim->nextConfig();
            nextAlready = true;
          }
-         (*obsit)->meas(false);
+         (*obsit)->meas(false, imeas);
          hypercache::writeO( (*obsit)->ocid );
        }
          
@@ -282,13 +296,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()