From a7d2847140835283503d3bd75fe56488dc16c8b3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 17 Mar 2020 16:43:34 -0400 Subject: [PATCH] parse image flags only for valid numbers and requize imz == 0 for 2d-systems --- src/atom.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 1396eb596c..26fb6cc304 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -973,12 +973,19 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset, error->all(FLERR,"Incorrect atom format in data file"); } - if (imageflag) - imagedata = ((imageint) (atoi(values[iptr]) + IMGMAX) & IMGMASK) | - (((imageint) (atoi(values[iptr+1]) + IMGMAX) & IMGMASK) << IMGBITS) | - (((imageint) (atoi(values[iptr+2]) + IMGMAX) & IMGMASK) << IMG2BITS); - else imagedata = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; + int imx = 0; + int imy = 0; + int imz = 0; + if (imageflag) { + imx = utils::inumeric(FLERR,values[iptr],true,lmp); + imy = utils::inumeric(FLERR,values[iptr+1],true,lmp); + imz = utils::inumeric(FLERR,values[iptr+2],true,lmp); + if ((domain->dimension == 2) && (imz != 0)) + error->one(FLERR,"Z-direction image flag must be 0 for 2d-systems"); + } + imagedata = ((imageint) (imx + IMGMAX) & IMGMASK) | + (((imageint) (imy + IMGMAX) & IMGMASK) << IMGBITS) | + (((imageint) (imz + IMGMAX) & IMGMASK) << IMG2BITS); xdata[0] = atof(values[xptr]); xdata[1] = atof(values[xptr+1]);