correct parsing of arguments with nmax appended at the end

This commit is contained in:
Axel Kohlmeyer
2023-08-04 21:37:12 -04:00
parent 7adb2d7bcf
commit db0c892d24

View File

@ -38,16 +38,11 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
nmaxval = MAXSMALLINT;
nindex = 0;
int iarg = 4;
if (strcmp(arg[iarg], "nmax") == 0) {
nmaxval = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
if (nmaxval < 1) error->all(FLERR, "Invalid nmax value");
iarg += 2;
}
// parse values
int iarg = 4;
values.clear();
while (iarg < narg) {
ArgInfo argi(arg[iarg]);
@ -61,10 +56,23 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR, "Invalid fix vector argument: {}", arg[iarg]);
if (val.which == ArgInfo::NONE) break;
values.push_back(val);
++iarg;
}
while (iarg < narg) {
if (strcmp(arg[iarg], "nmax") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix vector nmax", error);
nmaxval = utils::bnumeric(FLERR, arg[iarg + 1], false, lmp);
if (nmaxval < 1) error->all(FLERR, "Invalid nmax value");
iarg += 2;
} else {
error->all(FLERR, "Unknown fix vector keyword: {}", arg[iarg]);
}
}
// setup and error check
// for fix inputs, check that fix frequency is acceptable
// this fix produces either a global vector or array