validate more numbers read from data files through using force->numeric()/force->inumeric() instead of atof()/atoi()

This commit is contained in:
Axel Kohlmeyer
2019-07-07 15:52:21 -04:00
parent b727f0b126
commit 15e1b39531
34 changed files with 247 additions and 247 deletions

View File

@ -1141,16 +1141,16 @@ void AtomVecEllipsoid::data_atom(double *coord, imageint imagetmp,
if (nlocal == nmax) grow(0);
tag[nlocal] = ATOTAGINT(values[0]);
type[nlocal] = atoi(values[1]);
type[nlocal] = force->inumeric(FLERR,values[1]);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one(FLERR,"Invalid atom type in Atoms section of data file");
ellipsoid[nlocal] = atoi(values[2]);
ellipsoid[nlocal] = force->inumeric(FLERR,values[2]);
if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1;
else if (ellipsoid[nlocal] == 1) ellipsoid[nlocal] = 0;
else error->one(FLERR,"Invalid ellipsoidflag in Atoms section of data file");
rmass[nlocal] = atof(values[3]);
rmass[nlocal] = force->numeric(FLERR,values[3]);
if (rmass[nlocal] <= 0.0)
error->one(FLERR,"Invalid density in Atoms section of data file");
@ -1178,12 +1178,12 @@ void AtomVecEllipsoid::data_atom(double *coord, imageint imagetmp,
int AtomVecEllipsoid::data_atom_hybrid(int nlocal, char **values)
{
ellipsoid[nlocal] = atoi(values[0]);
ellipsoid[nlocal] = force->inumeric(FLERR,values[0]);
if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1;
else if (ellipsoid[nlocal] == 1) ellipsoid[nlocal] = 0;
else error->one(FLERR,"Invalid atom type in Atoms section of data file");
rmass[nlocal] = atof(values[1]);
rmass[nlocal] = force->numeric(FLERR,values[1]);
if (rmass[nlocal] <= 0.0)
error->one(FLERR,"Invalid density in Atoms section of data file");
@ -1202,17 +1202,17 @@ void AtomVecEllipsoid::data_atom_bonus(int m, char **values)
if (nlocal_bonus == nmax_bonus) grow_bonus();
double *shape = bonus[nlocal_bonus].shape;
shape[0] = 0.5 * atof(values[0]);
shape[1] = 0.5 * atof(values[1]);
shape[2] = 0.5 * atof(values[2]);
shape[0] = 0.5 * force->numeric(FLERR,values[0]);
shape[1] = 0.5 * force->numeric(FLERR,values[1]);
shape[2] = 0.5 * force->numeric(FLERR,values[2]);
if (shape[0] <= 0.0 || shape[1] <= 0.0 || shape[2] <= 0.0)
error->one(FLERR,"Invalid shape in Ellipsoids section of data file");
double *quat = bonus[nlocal_bonus].quat;
quat[0] = atof(values[3]);
quat[1] = atof(values[4]);
quat[2] = atof(values[5]);
quat[3] = atof(values[6]);
quat[0] = force->numeric(FLERR,values[3]);
quat[1] = force->numeric(FLERR,values[4]);
quat[2] = force->numeric(FLERR,values[5]);
quat[3] = force->numeric(FLERR,values[6]);
MathExtra::qnormalize(quat);
// reset ellipsoid mass
@ -1230,12 +1230,12 @@ void AtomVecEllipsoid::data_atom_bonus(int m, char **values)
void AtomVecEllipsoid::data_vel(int m, char **values)
{
v[m][0] = atof(values[0]);
v[m][1] = atof(values[1]);
v[m][2] = atof(values[2]);
angmom[m][0] = atof(values[3]);
angmom[m][1] = atof(values[4]);
angmom[m][2] = atof(values[5]);
v[m][0] = force->numeric(FLERR,values[0]);
v[m][1] = force->numeric(FLERR,values[1]);
v[m][2] = force->numeric(FLERR,values[2]);
angmom[m][0] = force->numeric(FLERR,values[3]);
angmom[m][1] = force->numeric(FLERR,values[4]);
angmom[m][2] = force->numeric(FLERR,values[5]);
}
/* ----------------------------------------------------------------------
@ -1244,9 +1244,9 @@ void AtomVecEllipsoid::data_vel(int m, char **values)
int AtomVecEllipsoid::data_vel_hybrid(int m, char **values)
{
angmom[m][0] = atof(values[0]);
angmom[m][1] = atof(values[1]);
angmom[m][2] = atof(values[2]);
angmom[m][0] = force->numeric(FLERR,values[0]);
angmom[m][1] = force->numeric(FLERR,values[1]);
angmom[m][2] = force->numeric(FLERR,values[2]);
return 3;
}