X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/7a385d92335a4707d5b0aae66e4850d137c1fe7d..7d78a412f4cde48ce35f8f4cbe77c2a333484fa8:/o815/o815.cpp?ds=sidebyside diff --git a/o815/o815.cpp b/o815/o815.cpp index 4c2b28d..630d680 100644 --- a/o815/o815.cpp +++ b/o815/o815.cpp @@ -2,6 +2,11 @@ #include #include +#include + +#ifndef MPI_DISABLED +#include +#endif #include "latlib/progress.h" @@ -10,8 +15,6 @@ using namespace std; extern int opterr; o815::o815(int argc, char **argv, const string& _programid, comoption specOps[], void (*helpHeader)()) { - long timestamp; - programid = _programid; comargs.nmeas = 100; @@ -25,11 +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); - - paraQ = new paraq(numprocs, 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"); @@ -90,23 +96,20 @@ o815::o815(int argc, char **argv, const string& _programid, comoption specOps[], exit(0); } + paraQ = new paraq(numprocs, rank); + + hypercache::addPara("lx", comargs.lsize[0]); + hypercache::addPara("lt", comargs.lsize[1]); +} + +void o815::postParaInit() { + long timestamp; + if(comargs.idonly) { cout << programid << headMaster() << endl << flush; exit(0); } - if(rank==0) { - timestamp = time(NULL); - for(int idest=1; idest0) - MPI_Recv(×tamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, &mpiStatus); - - out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs, timestamp); -} - -void o815::mainLoop() { if( comargs.showjobnum ) { for( int i=1; i<=paraQ->getTotalJobs(); i++ ) { if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " "; @@ -114,7 +117,11 @@ void o815::mainLoop() { cout << endl; exit(0); } + + out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs); +} +void o815::mainLoop() { *out->log << "OBS: Starting main loop." << endl; for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) @@ -125,6 +132,8 @@ void o815::mainLoop() { for (vector::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait) *out->log << *parait << "=" << (*paraQ)[*parait] << " "; *out->log << ">" << endl << flush; + + Sim->_newParas(); progress measProg(comargs.nmeas); @@ -133,21 +142,26 @@ void o815::mainLoop() { *out->log << " " << (*obsit)->obsid; *out->log << endl << flush; - Sim->toEquilibrate = true; - for( int imeas=0; imeas::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) { - if( hypercache::readO( (*obsit)->ocid ) != -1 ) { + bool readnewObs; + int nequileftNewObs; + + hypercache::readO( (*obsit)->ocid, &readnewObs, &nequileftNewObs ); + + if ( readnewObs && nequileftNewObs < 0 ) { + (*obsit)->meas(true, imeas); + } + else { if (!nextAlready) { Sim->nextConfig(); nextAlready = true; } - (*obsit)->meas(false); + (*obsit)->meas(false, imeas); hypercache::writeO( (*obsit)->ocid ); } - else - (*obsit)->meas(true); + } while( measProg.madeStep(imeas) ) *out->log << "O815: " << measProg.done()*100 << "% of measurements done." << endl << flush; @@ -239,7 +253,7 @@ o815::comoption* o815::getOptionByVal(int val) { for (vector::iterator opit = comOptions.begin(); opit != comOptions.end(); ++opit) if ( opit->val == val ) return &(*opit); - return NULL; + exit(1); } void o815::listArg(int *target, int tlen, char *listarg) { @@ -270,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()