filedesc->filename = infile;
filedesc->doVirtualEquilibration = false;
- filedesc->readEquilibratedConfigs = 0;
+ filedesc->firstUsedConfig = true;
if( infile.size() < 4 ) return false;
void configcache::readConfig(bool& readnewconfig, int& nequileft, vector<unsigned long> *excludeFileHashes)
{
readnewconfig = false;
- nequileft = NEQUI;
if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return;
while(true)
{
vector<infiledesc>::iterator inFileIt = getNextInfile(excludeFileHashes);
+ int iDidVirtualSkips;
- if( (!inFile.is_open()) && inFileIt == inFiles.end() ) return;
+ if( (!inFile.is_open()) && inFileIt == inFiles.end() ) {
+ cout << "RETURNING..." << endl;
+ nequileft = nequileft_internal;
+ return;
+ }
while( (!inFile.is_open()) && inFiles.size() > 0 ) {
openFileDesc = *inFileIt;
if (openFileDesc.doVirtualEquilibration) {
if(log) *log << "CCACHE: Trying virtual equilibration." << endl << flush;
openFileDesc.doVirtualEquilibration = false;
- for (int iskip=0; iskip < (NEQUI-openFileDesc.nequi)/openFileDesc.nskip; iskip++) {
+ for (iDidVirtualSkips=0; iDidVirtualSkips < (NEQUI-openFileDesc.nequi)/openFileDesc.nskip; iDidVirtualSkips++) {
if( readFullBlock(tmpConfig, configSize) != configSize || ! inFile.is_open() )
break;
- else if ( (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip < nequileft ) {
+ else if ( (NEQUI-openFileDesc.nequi) - (iDidVirtualSkips+1)*openFileDesc.nskip < nequileft_internal ) {
memcpy(configMem, tmpConfig, configSize);
- nequileft = (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip;
+ nequileft_internal = NEQUI - openFileDesc.nequi - (iDidVirtualSkips+1)*openFileDesc.nskip;
+ cout << "blabla:" << nequileft_internal << endl;
readnewconfig = true;
+ openFileDesc.firstUsedConfig = false;
}
}
}
{
memcpy(configMem, tmpConfig, configSize);
readnewconfig = true;
- nequileft = NEQUI - openFileDesc.nequi - openFileDesc.readEquilibratedConfigs*openFileDesc.nskip;
- openFileDesc.readEquilibratedConfigs++;
+ if (openFileDesc.firstUsedConfig) {
+ openFileDesc.firstUsedConfig = false;
+ if (NEQUI < openFileDesc.nequi)
+ nequileft_internal = NEQUI - openFileDesc.nequi - iDidVirtualSkips*openFileDesc.nskip;
+ else
+ nequileft_internal = NEQUI - openFileDesc.nequi;
+ }
+ nequileft_internal -= openFileDesc.nskip;
+ cout << "sadasd:" << nequileft_internal << endl;
+ nequileft = nequileft_internal;
return;
}
else {