X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/f2373be314dc298d602b1939cde3d5ae990dd07f..81106ca76faf22180d0cd4bc1402847378e4ff68:/o815/o815.cpp?ds=sidebyside diff --git a/o815/o815.cpp b/o815/o815.cpp index a2b35e8..f92d37f 100644 --- a/o815/o815.cpp +++ b/o815/o815.cpp @@ -2,6 +2,8 @@ #include +#include "latlib/progress.h" + o815::o815(int argc, char **argv, const string& _programid) { long timestamp; @@ -31,14 +33,6 @@ o815::o815(int argc, char **argv, const string& _programid) { exit(0); } - if( comargs.showjobnum ) { - for( int i=1; i<=paraQ->getTotalJobs(); i++ ) { - if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " "; - } - cout << endl; - exit(0); - } - if(rank==0) { timestamp = time(NULL); for(int idest=1; idest::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) { - (*obsit)->start(); - } - - for (int i=0; i<100; i++) { - for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) { - (*obsit)->meas(); - } + if( comargs.showjobnum ) { + for( int i=1; i<=paraQ->getTotalJobs(); i++ ) { + if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " "; + } + cout << endl; + exit(0); } - for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) { - (*obsit)->finish(); - } + *out->log << "OBS: Starting main loop." << endl; + + for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) + (*obsit)->start(); - //MPI_Finalize(); + while( nextParas() ) { + *out->log << endl << "O815: < "; + for (vector::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait) + *out->log << *parait << "=" << (*paraQ)[*parait] << " "; + *out->log << ">" << endl << flush; + + progress measProg(comargs.nmeas); + + *out->log << "OBS: Starting measurement of observables:"; + for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) + *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 ) { + if (!nextAlready) { + Sim->nextConfig(); + nextAlready = true; + } + (*obsit)->meas(false); + hypercache::writeO( (*obsit)->ocid ); + } + else + (*obsit)->meas(true); + } + while( measProg.madeStep(imeas) ) + *out->log << "O815: " << measProg.done()*100 << "% of measurements done." << endl << flush; + } + for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) + (*obsit)->finish(); + } } void o815::parseArgs(int argc, char **argv) { @@ -145,9 +172,23 @@ o815::~o815() { if(rank==0) cout << "#end" << endl << flush; } - - cout << "bu:" << rank << endl; - + hypercache::finalize(); delete out; MPI_Finalize(); } + +int o815::nextParas() +{ + if( paraQ->nextParas() ) { + for (vector::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait) + hypercache::setPara(*parait, (*paraQ)[*parait]); + return 1; + } + else + return 0; +} + +void o815::addPara(const string& paraid, const double& paraDefault) { + hypercache::addPara(paraid); + paraQ->setDefault(paraid, paraDefault); +}