improve and modernize error messages
This commit is contained in:
@ -35,8 +35,8 @@ using namespace LAMMPS_NS;
|
||||
|
||||
ComputePE::ComputePE(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR, "Illegal compute pe command");
|
||||
if (igroup) error->all(FLERR, "Compute pe must use group all");
|
||||
if (narg < 3) utils::missing_cmd_args(FLERR, "compute pe", error);
|
||||
if (igroup) error->all(FLERR, 1, "Compute pe must use group all");
|
||||
|
||||
scalar_flag = 1;
|
||||
extscalar = 1;
|
||||
@ -70,7 +70,7 @@ ComputePE::ComputePE(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg
|
||||
else if (strcmp(arg[iarg], "fix") == 0)
|
||||
fixflag = 1;
|
||||
else
|
||||
error->all(FLERR, "Illegal compute pe command");
|
||||
error->all(FLERR, iarg, "Unknown compute pe keyword {}", arg[iarg]);
|
||||
iarg++;
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ double ComputePE::compute_scalar()
|
||||
{
|
||||
invoked_scalar = update->ntimestep;
|
||||
if (update->eflag_global != invoked_scalar)
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, Error::NOLASTLINE, "Energy was not tallied on needed timestep");
|
||||
|
||||
double one = 0.0;
|
||||
if (pairflag && force->pair) one += force->pair->eng_vdwl + force->pair->eng_coul;
|
||||
|
||||
@ -40,7 +40,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg), vptr(nullptr), id_temp(nullptr), pstyle(nullptr)
|
||||
{
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR,"compute pressure", error);
|
||||
if (igroup) error->all(FLERR,"Compute pressure must use group all");
|
||||
if (igroup) error->all(FLERR, 1, "Compute pressure must use group all");
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
@ -58,9 +58,9 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
|
||||
id_temp = utils::strdup(arg[3]);
|
||||
auto icompute = modify->get_compute_by_id(id_temp);
|
||||
if (!icompute)
|
||||
error->all(FLERR,"Could not find compute pressure temperature ID {}", id_temp);
|
||||
error->all(FLERR, 3, "Could not find compute pressure temperature ID {}", id_temp);
|
||||
if (!icompute->tempflag)
|
||||
error->all(FLERR,"Compute pressure temperature ID {} does not compute temperature", id_temp);
|
||||
error->all(FLERR, 3, "Compute pressure temperature ID {} does not compute temperature", id_temp);
|
||||
}
|
||||
|
||||
// process optional args
|
||||
|
||||
@ -27,7 +27,7 @@ using namespace LAMMPS_NS;
|
||||
ComputeVACF::ComputeVACF(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg), id_fix(nullptr)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR, "Illegal compute vacf command");
|
||||
if (narg > 2) error->all(FLERR, 3, "Compute vacf does not accept any arguments");
|
||||
|
||||
vector_flag = 1;
|
||||
size_vector = 4;
|
||||
|
||||
@ -33,7 +33,7 @@ FixNVE::FixNVE(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
auto plain_style = utils::strip_style_suffix(style, lmp);
|
||||
if (utils::strmatch(plain_style, "^nve$") && narg > 3)
|
||||
error->all(FLERR, "Unsupported additional arguments for fix {}", style);
|
||||
error->all(FLERR, 3, "Unsupported additional arguments for fix {}", style);
|
||||
|
||||
dynamic_group_allow = 1;
|
||||
time_integrate = 1;
|
||||
|
||||
@ -262,11 +262,13 @@ void Modify::init()
|
||||
|
||||
for (i = 0; i < nfix; i++)
|
||||
if (!fix[i]->dynamic_group_allow && group->dynamic[fix[i]->igroup])
|
||||
error->all(FLERR, "Fix {} does not allow use with a dynamic group", fix[i]->style);
|
||||
error->all(FLERR, Error::NOLASTLINE, "Fix {} does not allow use with a dynamic group",
|
||||
fix[i]->style);
|
||||
|
||||
for (i = 0; i < ncompute; i++)
|
||||
if (!compute[i]->dynamic_group_allow && group->dynamic[compute[i]->igroup])
|
||||
error->all(FLERR, "Compute {} does not allow use with a dynamic group", compute[i]->style);
|
||||
error->all(FLERR, Error::NOLASTLINE, "Compute {} does not allow use with a dynamic group",
|
||||
compute[i]->style);
|
||||
|
||||
// warn if any particle is time integrated more than once
|
||||
|
||||
@ -834,13 +836,13 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
for (m = 0; exceptions[m] != nullptr; m++)
|
||||
if (strcmp(arg[2], exceptions[m]) == 0) break;
|
||||
if (exceptions[m] == nullptr)
|
||||
error->all(FLERR, "Fix {} command before simulation box is defined", arg[2]);
|
||||
error->all(FLERR, 2, "Fix {} command before simulation box is defined", arg[2]);
|
||||
}
|
||||
|
||||
// check group ID
|
||||
|
||||
int igroup = group->find(arg[1]);
|
||||
if (igroup == -1) error->all(FLERR, "Could not find fix group ID {}", arg[1]);
|
||||
if (igroup == -1) error->all(FLERR, 1, "Could not find fix group ID {}", arg[1]);
|
||||
|
||||
// if fix ID exists:
|
||||
// set newflag = 0 so create new fix in same location in fix list
|
||||
@ -874,7 +876,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
if (estyle == fix[ifix]->style) match = 1;
|
||||
}
|
||||
}
|
||||
if (!match) error->all(FLERR, "Replacing a fix, but new style != old style");
|
||||
if (!match) error->all(FLERR, 2, "Replacing a fix, but new style != old style");
|
||||
|
||||
if (fix[ifix]->igroup != igroup && comm->me == 0)
|
||||
error->warning(FLERR, "Replacing a fix, but new group != old group");
|
||||
@ -921,7 +923,8 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
fix[ifix] = fix_creator(lmp, narg, arg);
|
||||
}
|
||||
|
||||
if (fix[ifix] == nullptr) error->all(FLERR, utils::check_packages_for_style("fix", arg[2], lmp));
|
||||
if (fix[ifix] == nullptr)
|
||||
error->all(FLERR, 2, utils::check_packages_for_style("fix", arg[2], lmp));
|
||||
|
||||
// increment nfix and update fix_list vector (if new)
|
||||
|
||||
@ -1244,7 +1247,8 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||
|
||||
// error check
|
||||
|
||||
if (get_compute_by_id(arg[0])) error->all(FLERR, "Reuse of compute ID '{}'", arg[0]);
|
||||
if (get_compute_by_id(arg[0]))
|
||||
error->all(FLERR, Error::ARGZERO, "Reuse of compute ID '{}'", arg[0]);
|
||||
|
||||
// extend Compute list if necessary
|
||||
|
||||
|
||||
Reference in New Issue
Block a user