From ed602dad098caa7ed83c77e0f88afa96e87ab475 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Fri, 29 Jan 2016 14:55:34 +0100 Subject: [PATCH] Clear EOF bits before seeking otherwise we get garbage data --- external/external_build.cmake | 2 +- src/fortran.cpp | 1 + src/loadGadget.cpp | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/external/external_build.cmake b/external/external_build.cmake index bc3fe95..a1878d9 100644 --- a/external/external_build.cmake +++ b/external/external_build.cmake @@ -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) diff --git a/src/fortran.cpp b/src/fortran.cpp index 679f409..716d57b 100644 --- a/src/fortran.cpp +++ b/src/fortran.cpp @@ -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; } diff --git a/src/loadGadget.cpp b/src/loadGadget.cpp index 9f77bb4..2642aac 100644 --- a/src/loadGadget.cpp +++ b/src/loadGadget.cpp @@ -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&) {}