replace a few more cases of atoi()/atof() with utils::*numeric() functions
This commit is contained in:
@ -1752,7 +1752,7 @@ void Atom::set_mass(const char *file, int line, int /*narg*/, char **arg)
|
|||||||
if (lo < 1 || hi > ntypes) error->all(file,line,"Invalid type for mass set");
|
if (lo < 1 || hi > ntypes) error->all(file,line,"Invalid type for mass set");
|
||||||
|
|
||||||
for (int itype = lo; itype <= hi; itype++) {
|
for (int itype = lo; itype <= hi; itype++) {
|
||||||
mass[itype] = atof(arg[1]);
|
mass[itype] = utils::numeric(FLERR,arg[1],false,lmp);
|
||||||
mass_setflag[itype] = 1;
|
mass_setflag[itype] = 1;
|
||||||
|
|
||||||
if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value");
|
if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value");
|
||||||
|
|||||||
@ -148,8 +148,8 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (iarg+3 > narg) error->all(FLERR,"Illegal compute reduce command");
|
if (iarg+3 > narg) error->all(FLERR,"Illegal compute reduce command");
|
||||||
if (mode != MINN && mode != MAXX)
|
if (mode != MINN && mode != MAXX)
|
||||||
error->all(FLERR,"Compute reduce replace requires min or max mode");
|
error->all(FLERR,"Compute reduce replace requires min or max mode");
|
||||||
int col1 = atoi(arg[iarg+1]) - 1;
|
int col1 = utils::inumeric(FLERR,arg[iarg+1],false,lmp) - 1;
|
||||||
int col2 = atoi(arg[iarg+2]) - 1;
|
int col2 = utils::inumeric(FLERR,arg[iarg+2],false,lmp) - 1;
|
||||||
if (col1 < 0 || col1 >= nvalues || col2 < 0 || col2 >= nvalues)
|
if (col1 < 0 || col1 >= nvalues || col2 < 0 || col2 >= nvalues)
|
||||||
error->all(FLERR,"Illegal compute reduce command");
|
error->all(FLERR,"Illegal compute reduce command");
|
||||||
if (col1 == col2) error->all(FLERR,"Illegal compute reduce command");
|
if (col1 == col2) error->all(FLERR,"Illegal compute reduce command");
|
||||||
|
|||||||
@ -254,13 +254,19 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
|||||||
|
|
||||||
if ((m = atom->map(itag)) >= 0) {
|
if ((m = atom->map(itag)) >= 0) {
|
||||||
for (j = 0; j < nvalue; j++) {
|
for (j = 0; j < nvalue; j++) {
|
||||||
if (style[j] == MOLECULE) atom->molecule[m] = ATOTAGINT(values[j+1]);
|
if (style[j] == MOLECULE) {
|
||||||
else if (style[j] == CHARGE) atom->q[m] = atof(values[j+1]);
|
atom->molecule[m] = utils::tnumeric(FLERR,values[j+1],false,lmp);
|
||||||
else if (style[j] == RMASS) atom->rmass[m] = atof(values[j+1]);
|
} else if (style[j] == CHARGE) {
|
||||||
else if (style[j] == INTEGER)
|
atom->q[m] = utils::numeric(FLERR,values[j+1],false,lmp);
|
||||||
atom->ivector[index[j]][m] = atoi(values[j+1]);
|
} else if (style[j] == RMASS) {
|
||||||
else if (style[j] == DOUBLE)
|
atom->rmass[m] = utils::numeric(FLERR,values[j+1],false,lmp);
|
||||||
atom->dvector[index[j]][m] = atof(values[j+1]);
|
} else if (style[j] == INTEGER) {
|
||||||
|
atom->ivector[index[j]][m] = utils::inumeric(FLERR,values[j+1],
|
||||||
|
false,lmp);
|
||||||
|
} else if (style[j] == DOUBLE) {
|
||||||
|
atom->dvector[index[j]][m] = utils::numeric(FLERR,values[j+1],
|
||||||
|
true,lmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -564,9 +564,9 @@ void KSpace::modify_params(int narg, char **arg)
|
|||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"kmax/ewald") == 0) {
|
} else if (strcmp(arg[iarg],"kmax/ewald") == 0) {
|
||||||
if (iarg+4 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
if (iarg+4 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
||||||
kx_ewald = atoi(arg[iarg+1]);
|
kx_ewald = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
ky_ewald = atoi(arg[iarg+2]);
|
ky_ewald = utils::inumeric(FLERR,arg[iarg+2],false,lmp);
|
||||||
kz_ewald = atoi(arg[iarg+3]);
|
kz_ewald = utils::inumeric(FLERR,arg[iarg+3],false,lmp);
|
||||||
if (kx_ewald < 0 || ky_ewald < 0 || kz_ewald < 0)
|
if (kx_ewald < 0 || ky_ewald < 0 || kz_ewald < 0)
|
||||||
error->all(FLERR,"Bad kspace_modify kmax/ewald parameter");
|
error->all(FLERR,"Bad kspace_modify kmax/ewald parameter");
|
||||||
if (kx_ewald > 0 && ky_ewald > 0 && kz_ewald > 0)
|
if (kx_ewald > 0 && ky_ewald > 0 && kz_ewald > 0)
|
||||||
@ -583,15 +583,15 @@ void KSpace::modify_params(int narg, char **arg)
|
|||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"force/disp/real") == 0) {
|
} else if (strcmp(arg[iarg],"force/disp/real") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
||||||
accuracy_real_6 = atof(arg[iarg+1]);
|
accuracy_real_6 = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"force/disp/kspace") == 0) {
|
} else if (strcmp(arg[iarg],"force/disp/kspace") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
||||||
accuracy_kspace_6 = atof(arg[iarg+1]);
|
accuracy_kspace_6 = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"eigtol") == 0) {
|
} else if (strcmp(arg[iarg],"eigtol") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command");
|
||||||
splittol = atof(arg[iarg+1]);
|
splittol = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
if (splittol >= 1.0)
|
if (splittol >= 1.0)
|
||||||
error->all(FLERR,"Kspace_modify eigtol must be smaller than one");
|
error->all(FLERR,"Kspace_modify eigtol must be smaller than one");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user