This commit is contained in:
Axel Kohlmeyer
2021-03-22 21:36:25 -04:00
parent 56121a524c
commit ca1496e028
4 changed files with 34 additions and 59 deletions

View File

@ -477,12 +477,10 @@ void PairKIM::coeff(int narg, char **arg)
if (paramname == str_name_str) break;
}
if (param_index >= numberOfParameters) {
auto msg = fmt::format("Wrong argument for pair coefficients.\n"
"This Model does not have the requested "
"'{}' parameter", paramname);
error->all(FLERR,msg);
}
if (param_index >= numberOfParameters)
error->all(FLERR,fmt::format("Wrong argument for pair coefficients.\n"
"This Model does not have the requested "
"'{}' parameter", paramname));
// Get the index_range for the requested parameter
int nlbound(0);
@ -492,12 +490,10 @@ void PairKIM::coeff(int narg, char **arg)
std::string argtostr(arg[i++]);
// Check to see if the indices range contains only integer numbers & :
if (argtostr.find_first_not_of("0123456789:") != std::string::npos) {
auto msg = fmt::format("Illegal index_range.\nExpected integer "
"parameter(s) instead of '{}' in "
"index_range", argtostr);
error->all(FLERR,msg);
}
if (argtostr.find_first_not_of("0123456789:") != std::string::npos)
error->all(FLERR,fmt::format("Illegal index_range.\nExpected integer"
" parameter(s) instead of '{}' in "
"index_range", argtostr));
std::string::size_type npos = argtostr.find(':');
if (npos != std::string::npos) {
@ -507,21 +503,17 @@ void PairKIM::coeff(int narg, char **arg)
nubound = atoi(words[1].c_str());
if (nubound < 1 || nubound > extent ||
nlbound < 1 || nlbound > nubound) {
auto msg = fmt::format("Illegal index_range '{}-{}' for '{}' "
"parameter with the extent of '{}'",
nlbound, nubound, paramname, extent);
error->all(FLERR,msg);
}
nlbound < 1 || nlbound > nubound)
error->all(FLERR,fmt::format("Illegal index_range '{}-{}' for '{}' "
"parameter with the extent of '{}'",
nlbound, nubound, paramname, extent));
} else {
nlbound = atoi(argtostr.c_str());
if (nlbound < 1 || nlbound > extent) {
auto msg = fmt::format("Illegal index '{}' for '{}' parameter "
"with the extent of '{}'", nlbound,
paramname, extent);
error->all(FLERR,msg);
}
if (nlbound < 1 || nlbound > extent)
error->all(FLERR,fmt::format("Illegal index '{}' for '{}' parameter "
"with the extent of '{}'", nlbound,
paramname, extent));
nubound = nlbound;
}
@ -551,11 +543,10 @@ void PairKIM::coeff(int narg, char **arg)
} else
error->all(FLERR,"Wrong parameter type to update");
} else {
auto msg = fmt::format("Wrong number of variable values for pair "
"coefficients.\n'{}' values are requested "
"for '{}' parameter", nubound - nlbound + 1,
paramname);
error->all(FLERR,msg);
error->all(FLERR,fmt::format("Wrong number of variable values for pair "
"coefficients.\n'{}' values are requested "
"for '{}' parameter", nubound - nlbound + 1,
paramname));
}
}

View File

@ -58,22 +58,16 @@ FixManifoldForce::FixManifoldForce(LAMMPS *lmp, int narg, char **arg) :
ptr_m = create_manifold(m_name,lmp,narg,arg);
// Construct manifold from factory:
if (!ptr_m) {
char msg[2048];
snprintf(msg,2048,"Manifold pointer for manifold '%s' was NULL for some reason", arg[3]);
error->all(FLERR,msg);
}
if (!ptr_m)
error->all(FLERR,fmt::format("Manifold pointer for manifold '{}' "
"was NULL for some reason", arg[3]));
// After constructing the manifold, you can safely make
// room for the parameters
nvars = ptr_m->nparams();
if (narg < nvars+4) {
char msg[2048];
sprintf(msg,"Manifold %s needs at least %d argument(s)!",
m_name, nvars);
error->all(FLERR,msg);
}
if (narg < nvars+4)
error->all(FLERR,fmt::format("Manifold {} needs at least {} "
"argument(s)!", m_name, nvars));
ptr_m->params = new double[nvars];
if (ptr_m->params == nullptr) {

View File

@ -95,9 +95,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg,
max_iter = utils::numeric( FLERR, arg[4] ,false,lmp);
ptr_m = create_manifold(arg[5], lmp, narg, arg);
if (!ptr_m) {
error->all(FLERR,"Error creating manifold pointer");
}
if (!ptr_m) error->all(FLERR,"Error creating manifold pointer");
nvars = ptr_m->nparams();
tstrs = new char*[nvars];
@ -105,17 +103,13 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg,
tstyle = new int[nvars];
is_var = new int[nvars];
if (!tstrs || !tvars || !tstyle || !is_var) {
if (!tstrs || !tvars || !tstyle || !is_var)
error->all(FLERR, "Error creating manifold arg arrays");
}
// Check if you have enough args:
if (6 + nvars > narg) {
char msg[2048];
sprintf(msg, "Not enough args for manifold %s, %d expected but got %d\n",
ptr_m->id(), nvars, narg - 6);
error->all(FLERR, msg);
}
if (6 + nvars > narg)
error->all(FLERR,fmt::format("Not enough args for manifold {}, {} expected "
"but got {}\n",ptr_m->id(),nvars, narg - 6));
// Loop over manifold args:
for (int i = 0; i < nvars; ++i) {
int len = 0, offset = 0;
@ -154,9 +148,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg,
}
argi += 2;
} else if (error_on_unknown_keyword) {
char msg[2048];
sprintf(msg,"Error parsing arg \"%s\".\n", arg[argi]);
error->all(FLERR, msg);
error->all(FLERR,fmt::format("Error parsing arg \"{}\".\n",arg[argi]));
} else {
argi += 1;
}

View File

@ -1183,10 +1183,8 @@ void DihedralTable::spline_table(Table *tb)
}
} // for (int i=0; i<tb->ninput; i++)
if ((num_disagreements > tb->ninput/2) && (num_disagreements > 2)) {
std::string msg("Dihedral table has inconsistent forces and energies. (Try \"NOF\".)\n");
error->all(FLERR, msg);
}
if ((num_disagreements > tb->ninput/2) && (num_disagreements > 2))
error->all(FLERR,"Dihedral table has inconsistent forces and energies. (Try \"NOF\".)\n");
} // check for consistency if (! tb->f_unspecified)