#include <sstream>
+#include "latlib/progress.h"
+
o815::o815(int argc, char **argv, const string& _programid) {
long timestamp;
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<numprocs; idest++)
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 << " ";
+ }
+ cout << endl;
+ exit(0);
+ }
+
+ *out->log << "OBS: Starting main loop." << endl;
+
+ for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
+ (*obsit)->start();
+
+ while( nextParas() ) {
+ *out->log << endl << "O815: < ";
+ for (vector<string>::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<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
+ *out->log << " " << (*obsit)->obsid;
+ *out->log << endl << flush;
+
+ for( int imeas=0; imeas<comargs.nmeas; imeas++ ) {
+ bool nextAlready = false;
+ for (vector<obs*>::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<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
+ (*obsit)->finish();
+ }
+}
+
void o815::parseArgs(int argc, char **argv) {
int opt = 0;
return hm.str();
}
+o815::~o815() {
+ if(comargs.outdir=="") {
+ MPI_Barrier(MPI_COMM_WORLD);
+ if(rank==0)
+ cout << "#end" << endl << flush;
+ }
+ hypercache::finalize();
+ delete out;
+ MPI_Finalize();
+}
+
+int o815::nextParas()
+{
+ if( paraQ->nextParas() ) {
+ for (vector<string>::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);
+}