X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/46e492935d31a36641b8e8a5cd27bd86e7df96c4..a477390b3aa6eea3a7d822a0499816eb0e2bf499:/hypercache.cpp?ds=inline diff --git a/hypercache.cpp b/hypercache.cpp index 0f8d856..b2a0b25 100644 --- a/hypercache.cpp +++ b/hypercache.cpp @@ -10,6 +10,7 @@ vector hypercache::Os; int hypercache::NEQUI; int hypercache::NSKIP; int hypercache::nequileft; +pair hypercache::mostEquilibratedConfig; void hypercache::initCache(configcache **cache, const string& cacheid, const int& nequi, const int& nskip, const string& datadir, @@ -55,6 +56,7 @@ void hypercache::setPara(const string& parid, const double& val) { (*osit)->setPara(parid, val); nequileft = NEQUI; + mostEquilibratedConfig.first = NEQUI; } void hypercache::finalize() { @@ -76,12 +78,11 @@ bool hypercache::readC() { C->readConfig(readnewconfig_nonex, nequileftReadConfig_nonex, &parentConfigs); if (readnewconfig_nonex) { - cout << ":" << nequileftReadConfig_nonex << endl; nequileft = nequileftReadConfig_nonex; readAtLeastOneConfig = true; } - if ( nequileft < 0 ) + if ( nequileft < 0 && readnewconfig_nonex ) activeCFile = fileOfPath(C->getInFileName()); else activeCFile = ""; @@ -117,6 +118,22 @@ bool hypercache::readC() { free(tmpconfig); } + /* storing most equilibrated config */ + if ( nequileft < mostEquilibratedConfig.first && readAtLeastOneConfig ) { + *log << "HYPERCACHE: Storing a copy of so far most equilibrated config with nequileft = " << nequileft << endl << flush; + mostEquilibratedConfig.first = nequileft; + memcpy(mostEquilibratedConfig.second, C->getConfigMem(), C->getConfigSize()); + } + + + /* injecting back most equilibrated config if nothing could be used anymore */ + if ( nequileft > 0 && mostEquilibratedConfig.first < nequileft ) { + *log << "HYPERCACHE: Injecting back most equilibrated stored config with nequileft = " << mostEquilibratedConfig.first << endl << flush; + nequileft = mostEquilibratedConfig.first; + memcpy(C->getConfigMem(), mostEquilibratedConfig.second, C->getConfigSize()); + readAtLeastOneConfig = false; + } + return readAtLeastOneConfig; }