replace atoi() with suitable utility functions

This commit is contained in:
Axel Kohlmeyer
2022-12-09 16:56:17 -05:00
parent f24cb96517
commit b0accb4ebf
3 changed files with 9 additions and 9 deletions

View File

@ -120,8 +120,8 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
// If ngpu is 0, autoset ngpu to the number of devices per node matching // If ngpu is 0, autoset ngpu to the number of devices per node matching
// best device // best device
int ngpu = atoi(arg[3]); int ngpu = utils::inumeric(FLERR, arg[3], false, lmp);
if (ngpu < 0) error->all(FLERR,"Illegal package gpu command"); if (ngpu < 0) error->all(FLERR,"Illegal number of GPUs ({}) in package gpu command", ngpu);
// Negative value indicate GPU package should find the best device ID // Negative value indicate GPU package should find the best device ID
int first_gpu_id = -1; int first_gpu_id = -1;

View File

@ -98,9 +98,7 @@ ComputeMLIAP::ComputeMLIAP(LAMMPS *lmp, int narg, char **arg) :
descriptorflag = 1; descriptorflag = 1;
} else if (strcmp(arg[iarg],"gradgradflag") == 0) { } else if (strcmp(arg[iarg],"gradgradflag") == 0) {
if (iarg+1 > narg) error->all(FLERR,"Illegal compute mliap command"); if (iarg+1 > narg) error->all(FLERR,"Illegal compute mliap command");
gradgradflag = atoi(arg[iarg+1]); gradgradflag = utils::logical(FLERR, arg[iarg+1], false, lmp);
if (gradgradflag != 0 && gradgradflag != 1)
error->all(FLERR,"Illegal compute mliap command");
iarg += 2; iarg += 2;
} else } else
error->all(FLERR,"Illegal compute mliap command"); error->all(FLERR,"Illegal compute mliap command");

View File

@ -4274,12 +4274,14 @@ void FixBondReact::readID(char *strarg, int iconstr, int myrxn, int i)
if (isalpha(strarg[0])) { if (isalpha(strarg[0])) {
constraints[iconstr][myrxn].idtype[i] = FRAG; // fragment vs. atom ID flag constraints[iconstr][myrxn].idtype[i] = FRAG; // fragment vs. atom ID flag
int ifragment = onemol->findfragment(strarg); int ifragment = onemol->findfragment(strarg);
if (ifragment < 0) error->one(FLERR,"Fix bond/react: Molecule fragment does not exist"); if (ifragment < 0)
error->one(FLERR,"Fix bond/react: Molecule fragment {} does not exist", strarg);
constraints[iconstr][myrxn].id[i] = ifragment; constraints[iconstr][myrxn].id[i] = ifragment;
} else { } else {
constraints[iconstr][myrxn].idtype[i] = ATOM; // fragment vs. atom ID flag constraints[iconstr][myrxn].idtype[i] = ATOM; // fragment vs. atom ID flag
int iatom = atoi(strarg); int iatom = utils::inumeric(FLERR, strarg, true, lmp);
if (iatom > onemol->natoms) error->one(FLERR,"Fix bond/react: Invalid template atom ID in map file"); if (iatom > onemol->natoms)
error->one(FLERR,"Fix bond/react: Invalid template atom ID {} in map file", strarg);
constraints[iconstr][myrxn].id[i] = iatom; constraints[iconstr][myrxn].id[i] = iatom;
} }
} }
@ -4287,7 +4289,7 @@ void FixBondReact::readID(char *strarg, int iconstr, int myrxn, int i)
void FixBondReact::open(char *file) void FixBondReact::open(char *file)
{ {
fp = fopen(file,"r"); fp = fopen(file,"r");
if (fp == nullptr) error->one(FLERR, "Fix bond/react: Cannot open map file {}",file); if (fp == nullptr) error->one(FLERR, "Fix bond/react: Cannot open map file {}", file);
} }
void FixBondReact::readline(char *line) void FixBondReact::readline(char *line)