From 266cb24bb3b0c97f49967dc06b5dd4c8907f9314 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 27 Aug 2022 16:19:02 -0400 Subject: [PATCH] improve error messages in set command --- src/set.cpp | 206 +++++++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 98 deletions(-) diff --git a/src/set.cpp b/src/set.cpp index 2843281d78..74ba370b29 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -61,8 +61,8 @@ void Set::command(int narg, char **arg) if (domain->box_exist == 0) error->all(FLERR,"Set command before simulation box is defined"); if (atom->natoms == 0) - error->all(FLERR,"Set command with no atoms existing"); - if (narg < 3) error->all(FLERR,"Illegal set command"); + error->all(FLERR,"Set command on system without atoms"); + if (narg < 4) error->all(FLERR,"Illegal set command: need at least four arguments"); // style and ID info @@ -71,7 +71,7 @@ void Set::command(int narg, char **arg) else if (strcmp(arg[0],"type") == 0) style = TYPE_SELECT; else if (strcmp(arg[0],"group") == 0) style = GROUP_SELECT; else if (strcmp(arg[0],"region") == 0) style = REGION_SELECT; - else error->all(FLERR,"Illegal set command"); + else error->all(FLERR,"Unknown set command style: {}", arg[0]); id = utils::strdup(arg[1]); select = nullptr; @@ -91,125 +91,125 @@ void Set::command(int narg, char **arg) origarg = iarg; if (strcmp(arg[iarg],"type") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set type", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); set(TYPE); iarg += 2; } else if (strcmp(arg[iarg],"type/fraction") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set type/fraction", error); newtype = utils::inumeric(FLERR,arg[iarg+1],false,lmp); fraction = utils::numeric(FLERR,arg[iarg+2],false,lmp); ivalue = utils::inumeric(FLERR,arg[iarg+3],false,lmp); if (newtype <= 0 || newtype > atom->ntypes) - error->all(FLERR,"Invalid value in set command"); + error->all(FLERR,"Invalid type value {} in set type/fraction command", newtype); if (fraction < 0.0 || fraction > 1.0) - error->all(FLERR,"Invalid value in set command"); + error->all(FLERR,"Invalid fraction value {} in set type/fraction command", fraction); if (ivalue <= 0) - error->all(FLERR,"Invalid random number seed in set command"); + error->all(FLERR,"Invalid random number seed {} in set type/fraction command", ivalue); setrandom(TYPE_FRACTION); iarg += 4; } else if (strcmp(arg[iarg],"type/ratio") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set type/ratio", error); newtype = utils::inumeric(FLERR,arg[iarg+1],false,lmp); fraction = utils::numeric(FLERR,arg[iarg+2],false,lmp); ivalue = utils::inumeric(FLERR,arg[iarg+3],false,lmp); if (newtype <= 0 || newtype > atom->ntypes) - error->all(FLERR,"Invalid value in set command"); + error->all(FLERR,"Invalid type value {} in set type/ratio command", newtype); if (fraction < 0.0 || fraction > 1.0) - error->all(FLERR,"Invalid value in set command"); + error->all(FLERR,"Invalid fraction value {} in set type/ratio command", fraction); if (ivalue <= 0) - error->all(FLERR,"Invalid random number seed in set command"); + error->all(FLERR,"Invalid random number seed {} in set type/ratio command", ivalue); setrandom(TYPE_RATIO); iarg += 4; } else if (strcmp(arg[iarg],"type/subset") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set type/subset", error); newtype = utils::inumeric(FLERR,arg[iarg+1],false,lmp); nsubset = utils::bnumeric(FLERR,arg[iarg+2],false,lmp); ivalue = utils::inumeric(FLERR,arg[iarg+3],false,lmp); if (newtype <= 0 || newtype > atom->ntypes) - error->all(FLERR,"Invalid value in set command"); + error->all(FLERR,"Invalid type value {} in set type/subset command", newtype); if (nsubset < 0) - error->all(FLERR,"Invalid value in set command"); + error->all(FLERR,"Invalid subset size {} in set type/subset command", nsubset); if (ivalue <= 0) - error->all(FLERR,"Invalid random number seed in set command"); + error->all(FLERR,"Invalid random number seed {} in set type/subset command", ivalue); setrandom(TYPE_SUBSET); iarg += 4; } else if (strcmp(arg[iarg],"mol") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set mol", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (!atom->molecule_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(MOLECULE); iarg += 2; } else if (strcmp(arg[iarg],"x") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set x", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); set(X); iarg += 2; } else if (strcmp(arg[iarg],"y") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set y", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); set(Y); iarg += 2; } else if (strcmp(arg[iarg],"z") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set z", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); set(Z); iarg += 2; } else if (strcmp(arg[iarg],"vx") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set vx", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); set(VX); iarg += 2; } else if (strcmp(arg[iarg],"vy") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set vy", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); set(VY); iarg += 2; } else if (strcmp(arg[iarg],"vz") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set vz", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); set(VZ); iarg += 2; } else if (strcmp(arg[iarg],"charge") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set charge", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->q_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(CHARGE); iarg += 2; } else if (strcmp(arg[iarg],"mass") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set mass", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->rmass_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(MASS); iarg += 2; } else if (strcmp(arg[iarg],"shape") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set shape", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else xvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (utils::strmatch(arg[iarg+2],"^v_")) varparse(arg[iarg+2],2); @@ -217,30 +217,30 @@ void Set::command(int narg, char **arg) if (utils::strmatch(arg[iarg+3],"^v_")) varparse(arg[iarg+3],3); else zvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (!atom->ellipsoid_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(SHAPE); iarg += 4; } else if (strcmp(arg[iarg],"length") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set length", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->line_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(LENGTH); iarg += 2; } else if (strcmp(arg[iarg],"tri") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set tri", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->tri_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(TRI); iarg += 2; } else if (strcmp(arg[iarg],"dipole") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set dipole", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else xvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (utils::strmatch(arg[iarg+2],"^v_")) varparse(arg[iarg+2],2); @@ -248,16 +248,16 @@ void Set::command(int narg, char **arg) if (utils::strmatch(arg[iarg+3],"^v_")) varparse(arg[iarg+3],3); else zvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (!atom->mu_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(DIPOLE); iarg += 4; } else if (strcmp(arg[iarg],"dipole/random") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "set dipole/random", error); ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); dvalue = utils::numeric(FLERR,arg[iarg+2],false,lmp); if (!atom->mu_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (ivalue <= 0) error->all(FLERR,"Invalid random number seed in set command"); if (dvalue <= 0.0) @@ -294,7 +294,7 @@ void Set::command(int narg, char **arg) iarg += 3; } else if (strcmp(arg[iarg],"quat") == 0) { - if (iarg+5 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+5 > narg) utils::missing_cmd_args(FLERR, "set quat", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else xvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (utils::strmatch(arg[iarg+2],"^v_")) varparse(arg[iarg+2],2); @@ -304,41 +304,41 @@ void Set::command(int narg, char **arg) if (utils::strmatch(arg[iarg+4],"^v_")) varparse(arg[iarg+4],4); else wvalue = utils::numeric(FLERR,arg[iarg+4],false,lmp); if (!atom->ellipsoid_flag && !atom->tri_flag && !atom->body_flag && !atom->quat_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(QUAT); iarg += 5; } else if (strcmp(arg[iarg],"quat/random") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set quat/random", error); ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (!atom->ellipsoid_flag && !atom->tri_flag && !atom->body_flag && !atom->quat_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (ivalue <= 0) error->all(FLERR,"Invalid random number seed in set command"); setrandom(QUAT_RANDOM); iarg += 2; } else if (strcmp(arg[iarg],"theta") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set theta", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = DEG2RAD * utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->line_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(THETA); iarg += 2; } else if (strcmp(arg[iarg],"theta/random") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set theta/random", error); ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (!atom->line_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (ivalue <= 0) error->all(FLERR,"Invalid random number seed in set command"); set(THETA_RANDOM); iarg += 2; } else if (strcmp(arg[iarg],"angmom") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set angmom", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else xvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (utils::strmatch(arg[iarg+2],"^v_")) varparse(arg[iarg+2],2); @@ -346,12 +346,12 @@ void Set::command(int narg, char **arg) if (utils::strmatch(arg[iarg+3],"^v_")) varparse(arg[iarg+3],3); else zvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (!atom->angmom_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(ANGMOM); iarg += 4; } else if (strcmp(arg[iarg],"omega") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set omega", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else xvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (utils::strmatch(arg[iarg+2],"^v_")) varparse(arg[iarg+2],2); @@ -359,26 +359,35 @@ void Set::command(int narg, char **arg) if (utils::strmatch(arg[iarg+3],"^v_")) varparse(arg[iarg+3],3); else zvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (!atom->omega_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(OMEGA); iarg += 4; - } else if (strcmp(arg[iarg],"diameter") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + } else if (strcmp(arg[iarg],"radius/atom") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set radius/atom", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->radius_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); + set(RADIUS_ATOM); + iarg += 2; + + } else if (strcmp(arg[iarg],"diameter") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set diameter", error); + if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); + else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); + if (!atom->radius_flag) + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(DIAMETER); iarg += 2; } else if (strcmp(arg[iarg],"density") == 0 || (strcmp(arg[iarg],"density/disc") == 0)) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set density", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->rmass_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (dvalue <= 0.0) error->all(FLERR,"Invalid density in set command"); discflag = 0; if (strcmp(arg[iarg],"density/disc") == 0) { @@ -390,17 +399,17 @@ void Set::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"volume") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set volume", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->vfrac_flag) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (dvalue <= 0.0) error->all(FLERR,"Invalid volume in set command"); set(VOLUME); iarg += 2; } else if (strcmp(arg[iarg],"image") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "set image", error); ximageflag = yimageflag = zimageflag = 0; if (strcmp(arg[iarg+1],"NULL") != 0) { ximageflag = 1; @@ -430,74 +439,74 @@ void Set::command(int narg, char **arg) iarg += 4; } else if (strcmp(arg[iarg],"bond") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set bond", error); ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (atom->avec->bonds_allow == 0) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (ivalue <= 0 || ivalue > atom->nbondtypes) error->all(FLERR,"Invalid value in set command"); topology(BOND); iarg += 2; } else if (strcmp(arg[iarg],"angle") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set angle", error); ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (atom->avec->angles_allow == 0) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (ivalue <= 0 || ivalue > atom->nangletypes) error->all(FLERR,"Invalid value in set command"); topology(ANGLE); iarg += 2; } else if (strcmp(arg[iarg],"dihedral") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set dihedral", error); ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (atom->avec->dihedrals_allow == 0) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (ivalue <= 0 || ivalue > atom->ndihedraltypes) error->all(FLERR,"Invalid value in set command"); topology(DIHEDRAL); iarg += 2; } else if (strcmp(arg[iarg],"improper") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set improper", error); ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (atom->avec->impropers_allow == 0) - error->all(FLERR,"Cannot set this attribute for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); if (ivalue <= 0 || ivalue > atom->nimpropertypes) error->all(FLERR,"Invalid value in set command"); topology(IMPROPER); iarg += 2; } else if (strcmp(arg[iarg],"sph/e") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set sph/e", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->esph_flag) - error->all(FLERR,"Cannot set meso/e for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(SPH_E); iarg += 2; } else if (strcmp(arg[iarg],"sph/cv") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set sph/cv", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->cv_flag) - error->all(FLERR,"Cannot set meso/cv for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(SPH_CV); iarg += 2; } else if (strcmp(arg[iarg],"sph/rho") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set sph/rho", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->rho_flag) - error->all(FLERR,"Cannot set meso/rho for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(SPH_RHO); iarg += 2; } else if (strcmp(arg[iarg],"edpd/temp") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set edpd/temp", error); if (strcmp(arg[iarg+1],"NULL") == 0) dvalue = -1.0; else if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else { @@ -505,12 +514,12 @@ void Set::command(int narg, char **arg) if (dvalue < 0.0) error->all(FLERR,"Illegal set command"); } if (!atom->edpd_flag) - error->all(FLERR,"Cannot set edpd/temp for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(EDPD_TEMP); iarg += 2; } else if (strcmp(arg[iarg],"edpd/cv") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set edpd/cv", error); if (strcmp(arg[iarg+1],"NULL") == 0) dvalue = -1.0; else if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else { @@ -518,12 +527,12 @@ void Set::command(int narg, char **arg) if (dvalue < 0.0) error->all(FLERR,"Illegal set command"); } if (!atom->edpd_flag) - error->all(FLERR,"Cannot set edpd/cv for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(EDPD_CV); iarg += 2; } else if (strcmp(arg[iarg],"cc") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "set cc", error); if (strcmp(arg[iarg+1],"NULL") == 0) dvalue = -1.0; else if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else { @@ -532,31 +541,30 @@ void Set::command(int narg, char **arg) if (cc_index < 1) error->all(FLERR,"Illegal set command"); } if (!atom->tdpd_flag) - error->all(FLERR,"Cannot set cc for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(CC); iarg += 3; } else if (strcmp(arg[iarg],"smd/mass/density") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set smd/mass/density", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->smd_flag) - error->all(FLERR,"Cannot set smd/mass/density for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(SMD_MASS_DENSITY); iarg += 2; } else if (strcmp(arg[iarg],"smd/contact/radius") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set smd/contact/radius", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (!atom->smd_flag) - error->all(FLERR,"Cannot set smd/contact/radius " - "for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(SMD_CONTACT_RADIUS); iarg += 2; } else if (strcmp(arg[iarg],"dpd/theta") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set dpd/theta", error); if (strcmp(arg[iarg+1],"NULL") == 0) dvalue = -1.0; else if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else { @@ -564,12 +572,12 @@ void Set::command(int narg, char **arg) if (dvalue < 0.0) error->all(FLERR,"Illegal set command"); } if (!atom->dpd_flag) - error->all(FLERR,"Cannot set dpd/theta for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(DPDTHETA); iarg += 2; } else if (strcmp(arg[iarg],"epsilon") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set epsilon", error); if (strcmp(arg[iarg+1],"NULL") == 0) dvalue = -1.0; else if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else { @@ -577,7 +585,7 @@ void Set::command(int narg, char **arg) if (dvalue < 0.0) error->all(FLERR,"Illegal set command"); } if (!atom->dielectric_flag) - error->all(FLERR,"Cannot set epsilon for this atom style"); + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(EPSILON); iarg += 2; @@ -588,16 +596,17 @@ void Set::command(int narg, char **arg) int flag,cols; ArgInfo argi(arg[iarg],ArgInfo::DNAME|ArgInfo::INAME); const char *pname = argi.get_name(); - if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set", error); index_custom = atom->find_custom(argi.get_name(),flag,cols); - if (index_custom < 0) error->all(FLERR,"Custom property {} does not exist",pname); + if (index_custom < 0) + error->all(FLERR,"Set keyword or custom property {} does not exist",pname); switch (argi.get_type()) { case ArgInfo::INAME: if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (flag != 0) error->all(FLERR,"Custom property {} is not integer",pname); + if (flag != 0) error->all(FLERR,"Set command custom property {} is not integer",pname); if (argi.get_dim() == 0) { if (cols > 0) @@ -621,14 +630,15 @@ void Set::command(int narg, char **arg) if (argi.get_dim() == 0) { if (cols > 0) - error->all(FLERR,"Set command custom floating-point property is not a vector"); + error->all(FLERR,"Set command custom double property {} is not a vector",pname); set(DVEC); } else if (argi.get_dim() == 1) { if (cols == 0) - error->all(FLERR,"Set command custom floating-point property is not an array"); + error->all(FLERR,"Set command custom double property {} is not an array",pname); icol_custom = argi.get_index1(); if (icol_custom <= 0 || icol_custom > cols) - error->all(FLERR,"Set command per-atom custom integer array is accessed out-of-range"); + error->all(FLERR,"Set command per-atom custom double array {} is " + "accessed out-of-range",pname); set(DARRAY); } else error->all(FLERR,"Illegal set command"); break; @@ -657,8 +667,8 @@ void Set::command(int narg, char **arg) // free local memory - delete [] id; - delete [] select; + delete[] id; + delete[] select; } /* ---------------------------------------------------------------------- @@ -668,7 +678,7 @@ void Set::command(int narg, char **arg) void Set::selection(int n) { - delete [] select; + delete[] select; select = new int[n]; int nlo,nhi; @@ -1457,9 +1467,9 @@ void Set::varparse(const char *name, int m) int ivar = input->variable->find(name+2); if (ivar < 0) - error->all(FLERR,"Variable name for set command does not exist"); + error->all(FLERR,"Variable name {} for set command does not exist", name); if (!input->variable->atomstyle(ivar)) - error->all(FLERR,"Variable for set command is invalid style"); + error->all(FLERR,"Variable {} for set command is invalid style", name); if (m == 1) { varflag1 = 1; ivar1 = ivar;