This commit is contained in:
Guilhem Lavaux 2021-01-24 09:31:01 +01:00
parent 014f7f9564
commit cb9e97e2c1
3 changed files with 10 additions and 8 deletions

View File

@ -410,7 +410,7 @@ def loadGadget(str filename, int snapshot_id, int gadgetFormat = 1, bool loadPos
with nogil: with nogil:
data = loadGadgetMulti(filename_bs, snapshot_id, flags, gadgetFormat) data = loadGadgetMulti(filename_bs, snapshot_id, flags, gadgetFormat)
if data == <SimuData*>0: if data == <SimuData*>0:
return None raise RuntimeError("File could not be read")
return PySimulationAdaptor(wrap_simudata(data, flags)) return PySimulationAdaptor(wrap_simudata(data, flags))

View File

@ -139,14 +139,16 @@ void UnformattedRead::beginCheckpoint(bool bufferRecord)
void UnformattedRead::endCheckpoint(bool autodrop) void UnformattedRead::endCheckpoint(bool autodrop)
{ {
bool always_fail = false;
if (recordBuffer != 0) { if (recordBuffer != 0) {
delete[] recordBuffer; delete[] recordBuffer;
recordBuffer = 0; recordBuffer = 0;
} }
if (cSize == Check_32bits) { if (cSize == Check_32bits) {
if (checkPointAccum >= 1<<32UL) { if (checkPointAccum >= 1UL<<32UL) {
always_fail = true; always_fail = true;
checkPointAccum %= (1<<32UL); checkPointAccum %= (1UL<<32UL);
} }
} }

View File

@ -221,7 +221,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
cerr << "Invalid format while reading header" << endl; cerr << "Invalid format while reading header" << endl;
delete data; delete data;
delete f; delete f;
return 0; throw;
} }
@ -275,7 +275,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
cerr << "Invalid format while reading positions" << endl; cerr << "Invalid format while reading positions" << endl;
delete f; delete f;
delete data; delete data;
return 0; throw;
} }
} else { } else {
@ -292,7 +292,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
{ {
delete f; delete f;
delete data; delete data;
return 0; throw;
} }
} }
@ -317,7 +317,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
cerr << "Invalid format while reading velocities" << endl; cerr << "Invalid format while reading velocities" << endl;
delete f; delete f;
delete data; delete data;
return 0; throw;
} }
// THE VELOCITIES ARE IN PHYSICAL COORDINATES // THE VELOCITIES ARE IN PHYSICAL COORDINATES
@ -367,7 +367,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
cerr << "Invalid unformatted access while reading ID" << endl; cerr << "Invalid unformatted access while reading ID" << endl;
delete f; delete f;
delete data; delete data;
return 0; throw;
} }
} else { } else {
f->skip(2*4); f->skip(2*4);