Unverified Commit 15e1b395 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

validate more numbers read from data files through using...

validate more numbers read from data files through using force->numeric()/force->inumeric() instead of atof()/atoi()
parent b727f0b1
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -780,19 +780,19 @@ void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values)
  if (nlocal == nmax) grow(0);
  if (nlocal == nmax) grow(0);


  tag[nlocal] = ATOTAGINT(values[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)
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");
    error->one(FLERR,"Invalid atom type in Atoms section of data file");


  q[nlocal] = atof(values[2]);
  q[nlocal] = force->numeric(FLERR,values[2]);


  x[nlocal][0] = coord[0];
  x[nlocal][0] = coord[0];
  x[nlocal][1] = coord[1];
  x[nlocal][1] = coord[1];
  x[nlocal][2] = coord[2];
  x[nlocal][2] = coord[2];


  mu[nlocal][0] = atof(values[6]);
  mu[nlocal][0] = force->numeric(FLERR,values[6]);
  mu[nlocal][1] = atof(values[7]);
  mu[nlocal][1] = force->numeric(FLERR,values[7]);
  mu[nlocal][2] = atof(values[8]);
  mu[nlocal][2] = force->numeric(FLERR,values[8]);
  mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
  mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
                       mu[nlocal][1]*mu[nlocal][1] +
                       mu[nlocal][1]*mu[nlocal][1] +
                       mu[nlocal][2]*mu[nlocal][2]);
                       mu[nlocal][2]*mu[nlocal][2]);
@@ -814,10 +814,10 @@ void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values)


int AtomVecDipole::data_atom_hybrid(int nlocal, char **values)
int AtomVecDipole::data_atom_hybrid(int nlocal, char **values)
{
{
  q[nlocal] = atof(values[0]);
  q[nlocal] = force->numeric(FLERR,values[0]);
  mu[nlocal][0] = atof(values[1]);
  mu[nlocal][0] = force->numeric(FLERR,values[1]);
  mu[nlocal][1] = atof(values[2]);
  mu[nlocal][1] = force->numeric(FLERR,values[2]);
  mu[nlocal][2] = atof(values[3]);
  mu[nlocal][2] = force->numeric(FLERR,values[3]);
  mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
  mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
                       mu[nlocal][1]*mu[nlocal][1] +
                       mu[nlocal][1]*mu[nlocal][1] +
                       mu[nlocal][2]*mu[nlocal][2]);
                       mu[nlocal][2]*mu[nlocal][2]);
+4 −4
Original line number Original line Diff line number Diff line
@@ -1632,9 +1632,9 @@ void AtomVecAngleKokkos::data_atom(double *coord, imageint imagetmp,
  if (nlocal == nmax) grow(0);
  if (nlocal == nmax) grow(0);
  atomKK->modified(Host,ALL_MASK);
  atomKK->modified(Host,ALL_MASK);


  h_tag(nlocal) = atoi(values[0]);
  h_tag(nlocal) = force->inumeric(FLERR,values[0]);
  h_molecule(nlocal) = atoi(values[1]);
  h_molecule(nlocal) = force->inumeric(FLERR,values[1]);
  h_type(nlocal) = atoi(values[2]);
  h_type(nlocal) = force->inumeric(FLERR,values[2]);
  if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
  if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");
    error->one(FLERR,"Invalid atom type in Atoms section of data file");


@@ -1661,7 +1661,7 @@ void AtomVecAngleKokkos::data_atom(double *coord, imageint imagetmp,


int AtomVecAngleKokkos::data_atom_hybrid(int nlocal, char **values)
int AtomVecAngleKokkos::data_atom_hybrid(int nlocal, char **values)
{
{
  h_molecule(nlocal) = atoi(values[0]);
  h_molecule(nlocal) = force->inumeric(FLERR,values[0]);
  h_num_bond(nlocal) = 0;
  h_num_bond(nlocal) = 0;
  h_num_angle(nlocal) = 0;
  h_num_angle(nlocal) = 0;
  return 1;
  return 1;
+2 −2
Original line number Original line Diff line number Diff line
@@ -823,8 +823,8 @@ void AtomVecAtomicKokkos::data_atom(double *coord, tagint imagetmp,
  int nlocal = atom->nlocal;
  int nlocal = atom->nlocal;
  if (nlocal == nmax) grow(0);
  if (nlocal == nmax) grow(0);


  h_tag[nlocal] = atoi(values[0]);
  h_tag[nlocal] = force->inumeric(FLERR,values[0]);
  h_type[nlocal] = atoi(values[1]);
  h_type[nlocal] = force->inumeric(FLERR,values[1]);
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");
    error->one(FLERR,"Invalid atom type in Atoms section of data file");


+4 −4
Original line number Original line Diff line number Diff line
@@ -1058,9 +1058,9 @@ void AtomVecBondKokkos::data_atom(double *coord, imageint imagetmp,
  if (nlocal == nmax) grow(0);
  if (nlocal == nmax) grow(0);
  atomKK->modified(Host,ALL_MASK);
  atomKK->modified(Host,ALL_MASK);


  h_tag(nlocal) = atoi(values[0]);
  h_tag(nlocal) = force->inumeric(FLERR,values[0]);
  h_molecule(nlocal) = atoi(values[1]);
  h_molecule(nlocal) = force->inumeric(FLERR,values[1]);
  h_type(nlocal) = atoi(values[2]);
  h_type(nlocal) = force->inumeric(FLERR,values[2]);
  if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
  if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");
    error->one(FLERR,"Invalid atom type in Atoms section of data file");


@@ -1086,7 +1086,7 @@ void AtomVecBondKokkos::data_atom(double *coord, imageint imagetmp,


int AtomVecBondKokkos::data_atom_hybrid(int nlocal, char **values)
int AtomVecBondKokkos::data_atom_hybrid(int nlocal, char **values)
{
{
  h_molecule(nlocal) = atoi(values[0]);
  h_molecule(nlocal) = force->inumeric(FLERR,values[0]);
  h_num_bond(nlocal) = 0;
  h_num_bond(nlocal) = 0;
  return 1;
  return 1;
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -959,12 +959,12 @@ void AtomVecChargeKokkos::data_atom(double *coord, imageint imagetmp,
  int nlocal = atom->nlocal;
  int nlocal = atom->nlocal;
  if (nlocal == nmax) grow(0);
  if (nlocal == nmax) grow(0);


  h_tag[nlocal] = atoi(values[0]);
  h_tag[nlocal] = force->inumeric(FLERR,values[0]);
  h_type[nlocal] = atoi(values[1]);
  h_type[nlocal] = force->inumeric(FLERR,values[1]);
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");
    error->one(FLERR,"Invalid atom type in Atoms section of data file");


  h_q[nlocal] = atof(values[2]);
  h_q[nlocal] = force->numeric(FLERR,values[2]);


  h_x(nlocal,0) = coord[0];
  h_x(nlocal,0) = coord[0];
  h_x(nlocal,1) = coord[1];
  h_x(nlocal,1) = coord[1];
@@ -988,7 +988,7 @@ void AtomVecChargeKokkos::data_atom(double *coord, imageint imagetmp,


int AtomVecChargeKokkos::data_atom_hybrid(int nlocal, char **values)
int AtomVecChargeKokkos::data_atom_hybrid(int nlocal, char **values)
{
{
  h_q[nlocal] = atof(values[0]);
  h_q[nlocal] = force->numeric(FLERR,values[0]);


  return 1;
  return 1;
}
}
Loading