diff --git a/src/loadGadget.cpp b/src/loadGadget.cpp index 4ccbe00..542fbfa 100644 --- a/src/loadGadget.cpp +++ b/src/loadGadget.cpp @@ -172,9 +172,9 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id, ssize_t NumPart = 0, NumPartTotal = 0; #define ENSURE2(name,out_sz) { \ + int64_t sz; \ if (GadgetFormat == 2) { \ BlockMap::iterator iter = blockTable.find(name); \ - int64_t sz; \ if (iter == blockTable.end()) { \ std::cerr << "GADGET2: Cannot find block named '" << name << "'" << endl; \ if (data) delete data; \ @@ -184,7 +184,14 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id, f->seek(iter->second.position); \ sz = iter->second.size; \ out_sz = sz;\ + } else if (GadgetFormat==1) { \ + int64_t oldpos = f->position(); \ + f->beginCheckpoint(); \ + out_sz = f->getBlockSize(); \ + f->endCheckpoint(true); \ + f->seek(oldpos); \ } \ +\ } #define ENSURE(name) ENSURE2(name,sz);