diff --git a/src/reader_native.cpp b/src/reader_native.cpp index 10cd1f47a4..dd1a032bda 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -68,8 +68,6 @@ int ReaderNative::read_time(bigint &ntimestep) delete[] unit_style; magic_string = nullptr; unit_style = nullptr; - ichunk = 0; - iatom_chunk = 0; fread(&ntimestep, sizeof(bigint), 1, fp); @@ -268,6 +266,10 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, read_buf(labelline, sizeof(char), len); labelline[len] = '\0'; } + + read_buf(&nchunk, sizeof(int), 1); + ichunk = 0; + iatom_chunk = 0; } else { int rv; @@ -462,16 +464,10 @@ void ReaderNative::read_atoms(int n, int nfield, double **fields) error->one(FLERR,"Unexpected end of dump file"); } - // if this is the beginning of the atom block - if (ichunk == 0 && iatom_chunk == 0) - read_buf(&nchunk, sizeof(int), 1); + // read chunks until n atoms have been read + int m = size_one*iatom_chunk; - // read chunk and write as size_one values per line - // until end of timestep or end of the reading buffer - int m=size_one*iatom_chunk; - bool continue_reading = (n>0); - bool continue_chunks = (ichunk