Clear EOF bits before seeking otherwise we get garbage data

This commit is contained in:
Guilhem Lavaux 2016-01-29 14:55:34 +01:00
parent 450a9a4185
commit ed602dad09
3 changed files with 5 additions and 2 deletions

View File

@ -7,7 +7,7 @@ SET(EIGEN_URL "http://bitbucket.org/eigen/eigen/get/3.1.4.tar.gz" CACHE URL "URL
SET(GENGETOPT_URL "ftp://ftp.gnu.org/gnu/gengetopt/gengetopt-2.22.5.tar.gz" CACHE STRING "URL to download gengetopt from")
SET(HDF5_URL "http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.15/src/hdf5-1.8.15.tar.gz" CACHE STRING "URL to download HDF5 from")
SET(NETCDF_URL "http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.1.3.tar.gz" CACHE STRING "URL to download NetCDF from")
SET(BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.gz/download" CACHE STRING "URL to download Boost from")
SET(BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz/download" CACHE STRING "URL to download Boost from")
SET(GSL_URL "ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz" CACHE STRING "URL to download GSL from ")
mark_as_advanced(FFTW_URL EIGEN_URL HDF5_URL NETCDF_URL BOOST_URL GSL_URL)

View File

@ -78,6 +78,7 @@ int64_t UnformattedRead::position() const
void UnformattedRead::seek(int64_t pos)
{
f->clear();
f->seekg(pos, istream::beg);
checkPointRef = checkPointAccum = 0;
}

View File

@ -51,8 +51,9 @@ using namespace std;
void loadGadgetHeader(UnformattedRead *f, GadgetHeader& h, SimuData *data, int id)
{
f->beginCheckpoint();
for (int i = 0; i < 6; i++)
for (int i = 0; i < 6; i++) {
h.npart[i] = f->readInt32();
}
for (int i = 0; i < 6; i++)
h.mass[i] = f->readReal64();
data->time = h.time = f->readReal64();
@ -146,6 +147,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
f->endCheckpoint();
blockTable[block] = f->position();
f->skip(blocksize);
cout << "Got block '" << block << "', position = " << blockTable[block] << endl;
}
} catch (EndOfFileException&) {}