From 7d17aa8c6bde2e49502401aa190a900bd4688362 Mon Sep 17 00:00:00 2001 From: Alex Schmidt Date: Thu, 18 Apr 2013 20:32:50 +0200 Subject: [PATCH] ... --- o815/o815.cpp | 47 ++++++++++++++++++++++++++++++++++++----------- o815/o815.h | 5 +++-- o815/obs.cpp | 4 ++-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/o815/o815.cpp b/o815/o815.cpp index 9cd3f7b..29f5fd3 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; @@ -57,18 +59,35 @@ void o815::mainLoop() { (*obsit)->start(); 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 measurements." << endl << flush; + + 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(); } - - /* - for (int i=0; i<100; i++) { - for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) { - (*obsit)->meas(); - } - } - */ - - for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) - (*obsit)->finish(); } void o815::parseArgs(int argc, char **argv) { @@ -148,6 +167,7 @@ o815::~o815() { if(rank==0) cout << "#end" << endl << flush; } + hypercache::finalize(); delete out; MPI_Finalize(); } @@ -162,3 +182,8 @@ int o815::nextParas() else return 0; } + +void o815::addPara(const string& paraid, const double& paraDefault) { + hypercache::addPara(paraid); + paraQ->setDefault(paraid, paraDefault); +} diff --git a/o815/o815.h b/o815/o815.h index 33693b0..467eca9 100644 --- a/o815/o815.h +++ b/o815/o815.h @@ -21,9 +21,10 @@ class o815 { public: obs(const string& _obsid, const string& _datadesc, o815 *_O815, const int& _obsmemSize); void finish(); - void meas(); + void meas(bool loadedobs); void start(); string getDataDesc() { return datadesc; }; + int ocid; private: virtual void _meas(bool loadedobs)=0; virtual void _finish()=0; @@ -33,7 +34,6 @@ class o815 { char *obsMem; string obsid, simid, datadesc; ostream *out, *log; - int ocid; }; class sim { @@ -71,6 +71,7 @@ class o815 { sim* Sim; void mainLoop(); string headMaster(); + void addPara(const string& paraid, const double& paraDefault); private: MPI_Status mpiStatus; diff --git a/o815/obs.cpp b/o815/obs.cpp index 70aa8b6..ee785a7 100644 --- a/o815/obs.cpp +++ b/o815/obs.cpp @@ -18,8 +18,8 @@ void o815::obs::start() { _start(); } -void o815::obs::meas() { - _meas(true); +void o815::obs::meas(bool loadedobs) { + _meas(loadedobs); } o815::obs::obs(const string& _obsid, const string& _datadesc, o815 *_O815, const int& obsmemSize) { -- 2.39.5