improved error messages in fix_addforce,fix_indent,fix_setforce,fix_temp_rescale,fix_wall_reflect and thermo.cpp
This commit is contained in:
@ -38,7 +38,7 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), estr(nullptr),
|
||||
idregion(nullptr), region(nullptr), sforce(nullptr)
|
||||
{
|
||||
if (narg < 6) error->all(FLERR, "Illegal fix addforce command");
|
||||
if (narg < 6) utils::missing_cmd_args(FLERR, "fix addforce", error);
|
||||
|
||||
dynamic_group_allow = 1;
|
||||
scalar_flag = 1;
|
||||
@ -77,25 +77,25 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) :
|
||||
int iarg = 6;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "every") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix addforce command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix addforce every", error);
|
||||
nevery = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
if (nevery <= 0) error->all(FLERR, "Illegal fix addforce command");
|
||||
if (nevery <= 0) error->all(FLERR, "Invalid fix addforce every argument: {}", nevery);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg], "region") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix addforce command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix addforce region", error);
|
||||
region = domain->get_region_by_id(arg[iarg + 1]);
|
||||
if (!region) error->all(FLERR, "Region {} for fix addforce does not exist", arg[iarg + 1]);
|
||||
idregion = utils::strdup(arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg], "energy") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix addforce command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix addforce energy", error);
|
||||
if (utils::strmatch(arg[iarg + 1], "^v_")) {
|
||||
estr = utils::strdup(arg[iarg + 1] + 2);
|
||||
} else
|
||||
error->all(FLERR, "Illegal fix addforce command");
|
||||
error->all(FLERR, "Invalid fix addforce energy argument: {}", arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
} else
|
||||
error->all(FLERR, "Illegal fix addforce command");
|
||||
error->all(FLERR, "Unknown fix addforce keyword: {}", arg[iarg]);
|
||||
}
|
||||
|
||||
force_flag = 0;
|
||||
|
||||
@ -83,7 +83,7 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (cdim == 0 && !pstr) pvalue *= xscale;
|
||||
else if (cdim == 1 && !pstr) pvalue *= yscale;
|
||||
else if (cdim == 2 && !pstr) pvalue *= zscale;
|
||||
} else error->all(FLERR,"Illegal fix indent command");
|
||||
} else error->all(FLERR,"Unknown fix indent keyword: {}", istyle);
|
||||
|
||||
varflag = 0;
|
||||
if (xstr || ystr || zstr || rstr || pstr) varflag = 1;
|
||||
@ -121,37 +121,37 @@ void FixIndent::init()
|
||||
if (xstr) {
|
||||
xvar = input->variable->find(xstr);
|
||||
if (xvar < 0)
|
||||
error->all(FLERR,"Variable name for fix indent does not exist");
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", xstr);
|
||||
if (!input->variable->equalstyle(xvar))
|
||||
error->all(FLERR,"Variable for fix indent is invalid style");
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", xstr);
|
||||
}
|
||||
if (ystr) {
|
||||
yvar = input->variable->find(ystr);
|
||||
if (yvar < 0)
|
||||
error->all(FLERR,"Variable name for fix indent does not exist");
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", ystr);
|
||||
if (!input->variable->equalstyle(yvar))
|
||||
error->all(FLERR,"Variable for fix indent is not equal style");
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", ystr);
|
||||
}
|
||||
if (zstr) {
|
||||
zvar = input->variable->find(zstr);
|
||||
if (zvar < 0)
|
||||
error->all(FLERR,"Variable name for fix indent does not exist");
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", zstr);
|
||||
if (!input->variable->equalstyle(zvar))
|
||||
error->all(FLERR,"Variable for fix indent is not equal style");
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", zstr);
|
||||
}
|
||||
if (rstr) {
|
||||
rvar = input->variable->find(rstr);
|
||||
if (rvar < 0)
|
||||
error->all(FLERR,"Variable name for fix indent does not exist");
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", rstr);
|
||||
if (!input->variable->equalstyle(rvar))
|
||||
error->all(FLERR,"Variable for fix indent is not equal style");
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", rstr);
|
||||
}
|
||||
if (pstr) {
|
||||
pvar = input->variable->find(pstr);
|
||||
if (pvar < 0)
|
||||
error->all(FLERR,"Variable name for fix indent does not exist");
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", pstr);
|
||||
if (!input->variable->equalstyle(pvar))
|
||||
error->all(FLERR,"Variable for fix indent is not equal style");
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", pstr);
|
||||
}
|
||||
|
||||
if (utils::strmatch(update->integrate_style,"^respa")) {
|
||||
|
||||
@ -37,7 +37,7 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), idregion(nullptr),
|
||||
region(nullptr), sforce(nullptr)
|
||||
{
|
||||
if (narg < 6) error->all(FLERR, "Illegal fix setforce command");
|
||||
if (narg < 6) utils::missing_cmd_args(FLERR, "fix setforce", error);
|
||||
|
||||
dynamic_group_allow = 1;
|
||||
vector_flag = 1;
|
||||
@ -77,13 +77,13 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
|
||||
int iarg = 6;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "region") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix setforce command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix setforce region", error);
|
||||
region = domain->get_region_by_id(arg[iarg + 1]);
|
||||
if (!region) error->all(FLERR, "Region {} for fix setforce does not exist", arg[iarg + 1]);
|
||||
idregion = utils::strdup(arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
} else
|
||||
error->all(FLERR, "Illegal fix setforce command");
|
||||
error->all(FLERR, "Unknown fix setforce keyword: {}", arg[iarg]);
|
||||
}
|
||||
|
||||
force_flag = 0;
|
||||
|
||||
@ -40,10 +40,10 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg),
|
||||
tstr(nullptr), id_temp(nullptr), tflag(0)
|
||||
{
|
||||
if (narg < 8) error->all(FLERR,"Illegal fix temp/rescale command");
|
||||
if (narg < 8) utils::missing_cmd_args(FLERR, "fix temp/rescale", error);
|
||||
|
||||
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
|
||||
if (nevery <= 0) error->all(FLERR,"Illegal fix temp/rescale command");
|
||||
if (nevery <= 0) error->all(FLERR, "Invalid fix temp/rescale argument: {}", nevery);
|
||||
|
||||
restart_global = 1;
|
||||
scalar_flag = 1;
|
||||
@ -106,9 +106,9 @@ void FixTempRescale::init()
|
||||
if (tstr) {
|
||||
tvar = input->variable->find(tstr);
|
||||
if (tvar < 0)
|
||||
error->all(FLERR,"Variable name for fix temp/rescale does not exist");
|
||||
error->all(FLERR,"Variable {} for fix temp/rescale does not exist", tstr);
|
||||
if (input->variable->equalstyle(tvar)) tstyle = EQUAL;
|
||||
else error->all(FLERR,"Variable for fix temp/rescale is invalid style");
|
||||
else error->all(FLERR,"Variable {} for fix temp/rescale is invalid style", tstr);
|
||||
}
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
@ -195,7 +195,7 @@ void FixTempRescale::end_of_step()
|
||||
int FixTempRescale::modify_param(int narg, char **arg)
|
||||
{
|
||||
if (strcmp(arg[0],"temp") == 0) {
|
||||
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
|
||||
if (narg < 2) utils::missing_cmd_args(FLERR, "fix_modify temp", error);
|
||||
if (tflag) {
|
||||
modify->delete_compute(id_temp);
|
||||
tflag = 0;
|
||||
@ -205,7 +205,7 @@ int FixTempRescale::modify_param(int narg, char **arg)
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Could not find fix_modify temperature ID");
|
||||
error->all(FLERR,"Could not find fix_modify temperature ID {}", arg[1]);
|
||||
temperature = modify->compute[icompute];
|
||||
|
||||
if (temperature->tempflag == 0)
|
||||
|
||||
@ -35,7 +35,7 @@ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg),
|
||||
nwall(0)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR,"Illegal fix wall/reflect command");
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "fix wall/reflect", error);
|
||||
|
||||
// let child class process all args
|
||||
|
||||
@ -53,7 +53,7 @@ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) :
|
||||
if ((strcmp(arg[iarg],"xlo") == 0) || (strcmp(arg[iarg],"xhi") == 0) ||
|
||||
(strcmp(arg[iarg],"ylo") == 0) || (strcmp(arg[iarg],"yhi") == 0) ||
|
||||
(strcmp(arg[iarg],"zlo") == 0) || (strcmp(arg[iarg],"zhi") == 0)) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix wall/reflect command");
|
||||
if (iarg+2 > narg) error->all(FLERR, "Illegal fix wall/reflect {} command: missing argument(s)", arg[iarg]);
|
||||
|
||||
int newwall;
|
||||
if (strcmp(arg[iarg],"xlo") == 0) newwall = XLO;
|
||||
@ -86,26 +86,26 @@ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) :
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg],"units") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal wall/reflect command");
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix wall/reflect units", error);
|
||||
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
||||
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
|
||||
else error->all(FLERR,"Illegal fix wall/reflect command");
|
||||
else error->all(FLERR,"Unknown fix wall/reflect units argument: {}", arg[iarg+1]);
|
||||
iarg += 2;
|
||||
|
||||
} else error->all(FLERR,"Illegal fix wall/reflect command");
|
||||
} else error->all(FLERR,"Unknown fix wall/reflect keyword: {}", arg[iarg]);
|
||||
}
|
||||
|
||||
// error check
|
||||
|
||||
if (nwall == 0) error->all(FLERR,"Illegal fix wall command");
|
||||
if (nwall == 0) utils::missing_cmd_args(FLERR, "fix wall/reflect", error);
|
||||
|
||||
for (int m = 0; m < nwall; m++) {
|
||||
if ((wallwhich[m] == XLO || wallwhich[m] == XHI) && domain->xperiodic)
|
||||
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
||||
error->all(FLERR,"Cannot use fix wall/reflect in xperiodic dimension");
|
||||
if ((wallwhich[m] == YLO || wallwhich[m] == YHI) && domain->yperiodic)
|
||||
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
||||
error->all(FLERR,"Cannot use fix wall/reflect in yperiodic dimension");
|
||||
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->zperiodic)
|
||||
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
||||
error->all(FLERR,"Cannot use fix wall/reflect in zperiodic dimension");
|
||||
}
|
||||
|
||||
for (int m = 0; m < nwall; m++)
|
||||
@ -170,9 +170,9 @@ void FixWallReflect::init()
|
||||
if (wallstyle[m] != VARIABLE) continue;
|
||||
varindex[m] = input->variable->find(varstr[m]);
|
||||
if (varindex[m] < 0)
|
||||
error->all(FLERR,"Variable name for fix wall/reflect does not exist");
|
||||
error->all(FLERR,"Variable {} for fix wall/reflect does not exist", varstr[m]);
|
||||
if (!input->variable->equalstyle(varindex[m]))
|
||||
error->all(FLERR,"Variable for fix wall/reflect is invalid style");
|
||||
error->all(FLERR,"Variable {} for fix wall/reflect is invalid style", varstr[m]);
|
||||
}
|
||||
|
||||
int nrigid = 0;
|
||||
|
||||
@ -498,14 +498,14 @@ bigint Thermo::lost_check()
|
||||
|
||||
void Thermo::modify_params(int narg, char **arg)
|
||||
{
|
||||
if (narg == 0) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (narg == 0) utils::missing_cmd_args(FLERR, "thermo_modify", error);
|
||||
|
||||
modified = 1;
|
||||
|
||||
int iarg = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "temp") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify temp", error);
|
||||
if (index_temp < 0) error->all(FLERR, "Thermo style does not use temp");
|
||||
delete[] id_compute[index_temp];
|
||||
id_compute[index_temp] = utils::strdup(arg[iarg + 1]);
|
||||
@ -540,7 +540,7 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "press") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify press", error);
|
||||
if (index_press_scalar < 0 && index_press_vector < 0)
|
||||
error->all(FLERR, "Thermo style does not use press");
|
||||
|
||||
@ -563,7 +563,7 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "lost") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify lost", error);
|
||||
if (strcmp(arg[iarg + 1], "ignore") == 0)
|
||||
lostflag = Thermo::IGNORE;
|
||||
else if (strcmp(arg[iarg + 1], "warn") == 0)
|
||||
@ -571,11 +571,11 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
else if (strcmp(arg[iarg + 1], "error") == 0)
|
||||
lostflag = Thermo::ERROR;
|
||||
else
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
error->all(FLERR, "Unknown thermo_modify lost argument: {}", arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "lost/bond") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify lost/bond", error);
|
||||
if (strcmp(arg[iarg + 1], "ignore") == 0)
|
||||
lostbond = Thermo::IGNORE;
|
||||
else if (strcmp(arg[iarg + 1], "warn") == 0)
|
||||
@ -583,11 +583,11 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
else if (strcmp(arg[iarg + 1], "error") == 0)
|
||||
lostbond = Thermo::ERROR;
|
||||
else
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
error->all(FLERR, "Unknown thermo_modify lost/bond argument: {}", arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "warn") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify warn", error);
|
||||
if (strcmp(arg[iarg + 1], "ignore") == 0)
|
||||
error->set_maxwarn(-1);
|
||||
else if (strcmp(arg[iarg + 1], "always") == 0)
|
||||
@ -604,18 +604,18 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "norm") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify norm", error);
|
||||
normuserflag = 1;
|
||||
normuser = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "flush") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify flush", error);
|
||||
flushflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "line") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify line", error);
|
||||
if (strcmp(arg[iarg + 1], "one") == 0)
|
||||
lineflag = ONELINE;
|
||||
else if (strcmp(arg[iarg + 1], "multi") == 0)
|
||||
@ -623,16 +623,16 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
else if (strcmp(arg[iarg + 1], "yaml") == 0)
|
||||
lineflag = YAMLLINE;
|
||||
else
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
error->all(FLERR, "Unknown thermo_modify line argument: {}", arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "colname") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify colname", error);
|
||||
if (strcmp(arg[iarg + 1], "default") == 0) {
|
||||
for (auto item : keyword_user) item.clear();
|
||||
iarg += 2;
|
||||
} else {
|
||||
if (iarg + 3 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "thermo_modify colname", error);
|
||||
int icol = -1;
|
||||
if (utils::is_integer(arg[iarg + 1])) {
|
||||
icol = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
@ -646,12 +646,12 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
}
|
||||
}
|
||||
if ((icol < 0) || (icol >= nfield_initial))
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
error->all(FLERR, "Invalid thermo_modify colname argument: {}", arg[iarg + 1]);
|
||||
keyword_user[icol] = arg[iarg + 2];
|
||||
iarg += 3;
|
||||
}
|
||||
} else if (strcmp(arg[iarg], "format") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify format", error);
|
||||
|
||||
if (strcmp(arg[iarg + 1], "none") == 0) {
|
||||
format_line_user.clear();
|
||||
@ -663,7 +663,7 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (iarg + 3 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "thermo_modify format", error);
|
||||
|
||||
if (strcmp(arg[iarg + 1], "line") == 0) {
|
||||
format_line_user = arg[iarg + 2];
|
||||
@ -692,13 +692,13 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
}
|
||||
}
|
||||
if (icol < 0 || icol >= nfield_initial + 1)
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
error->all(FLERR, "Invalid thermo_modify format argument: {}", arg[iarg + 1]);
|
||||
format_column_user[icol] = arg[iarg + 2];
|
||||
}
|
||||
iarg += 3;
|
||||
|
||||
} else
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
error->all(FLERR, "Unknown thermo_modify keyword: {}", arg[iarg]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user