X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/46e492935d31a36641b8e8a5cd27bd86e7df96c4..07516f0b1615a95f3e68d073adf4cfda584b99fa:/o815/sim.cpp diff --git a/o815/sim.cpp b/o815/sim.cpp index 6abf7c6..70fe482 100644 --- a/o815/sim.cpp +++ b/o815/sim.cpp @@ -3,6 +3,8 @@ #include "latlib/hypercache.h" #include "latlib/progress.h" +#include "latlib/datread.h" + o815::sim::sim(o815 *_O815, const int& _confmemSize) { O815 = _O815; log = O815->out->log; @@ -10,17 +12,39 @@ o815::sim::sim(o815 *_O815, const int& _confmemSize) { nequi = O815->comargs.nequi; nskip = O815->comargs.nskip; confmemSize = confmemSize; + + startConfiguration = NULL; + + if ( O815->comargs.startconfig != "" ) { + *log << "SIM: Fetching startconfig from " << O815->comargs.startconfig << endl; + + datread dataReader(confmemSize); + dataReader.openFile(O815->comargs.startconfig); + + if ( dataReader.fisopen() ) { + startConfiguration = new char[confmemSize]; + + if ( dataReader.readFullBlock(startConfiguration) < 0 ) { + *log << "SIM: Error while reading config from " << O815->comargs.startconfig << endl; + delete[] startConfiguration; + startConfiguration = NULL; + } + } + else { + *log << "SIM: Could not open startconfigfile " << O815->comargs.startconfig << endl; + } + } + } -void o815::sim::nextConfig() { - bool readnewconfig; - int nequileftReadConfig; - bool skippedInEqui = false; - bool readNoSingleConfig = true; - bool createdNoNewConfigs = true; - bool readAtLeastOneConfig; +o815::sim::~sim () +{ + if (startConfiguration != NULL) + delete[] startConfiguration; +} - readAtLeastOneConfig = hypercache::readC(); +void o815::sim::nextConfig() { + bool readAtLeastOneConfig = hypercache::readC(); /* equilibrate if necessary */ if (hypercache::getNEquiLeft() > 0) { @@ -32,23 +56,20 @@ void o815::sim::nextConfig() { _makeSweep(); while( equiProg.madeStep(iequi) ) *log << "SIM: " << equiProg.done()*100 << "% of equilibration done." << endl << flush; } - skippedInEqui = true; - createdNoNewConfigs = false; } - /* make skip if no config could be read */ - if ( (! readAtLeastOneConfig) ) { - cout << "SKIPPING" << endl; + /* make skip if no config could be read or one skip is left after equilibration */ + if ( (! readAtLeastOneConfig) || (hypercache::getNEquiLeft() >= 0) ) { for (int iskip=0; iskip