diff --git a/src/atom.cpp b/src/atom.cpp index 34ea253751..dfea9348c9 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -39,6 +39,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" #ifdef LMP_USER_INTEL #include "neigh_request.h" @@ -509,7 +510,7 @@ AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag) return avec_creator(lmp); } - error->all(FLERR,"Unknown atom style"); + error->all(FLERR,utils::check_packages_for_style("atom",style,lmp).c_str()); return NULL; } diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 893a4c7dc4..d5f286c077 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -25,6 +25,7 @@ #include "fix.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -96,7 +97,7 @@ void AtomVecBody::process_args(int narg, char **arg) #undef BodyStyle #undef BODY_CLASS - else error->all(FLERR,"Unknown body style"); + else error->all(FLERR,utils::check_packages_for_style("body",arg[0],lmp).c_str()); bptr->avec = this; icp = bptr->icp; diff --git a/src/domain.cpp b/src/domain.cpp index 86c4eb2c02..8c3ec97946 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -40,6 +40,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -1714,6 +1715,9 @@ void Domain::add_region(int narg, char **arg) return; } + if (strcmp(arg[1],"none") == 0) + error->all(FLERR,"Unrecognized region style 'none'"); + if (find_region(arg[0]) >= 0) error->all(FLERR,"Reuse of region ID"); // extend Region list if necessary @@ -1752,12 +1756,10 @@ void Domain::add_region(int narg, char **arg) } } - if (strcmp(arg[1],"none") == 0) error->all(FLERR,"Unknown region style"); if (region_map->find(arg[1]) != region_map->end()) { RegionCreator region_creator = (*region_map)[arg[1]]; regions[nregion] = region_creator(lmp, narg, arg); - } - else error->all(FLERR,"Unknown region style"); + } else error->all(FLERR,utils::check_packages_for_style("region",arg[1],lmp).c_str()); // initialize any region variables via init() // in case region is used between runs, e.g. to print a variable diff --git a/src/force.cpp b/src/force.cpp index 7ff5096ee4..2691cb3fd8 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -258,9 +258,7 @@ Pair *Force::new_pair(const char *style, int trysuffix, int &sflag) return pair_creator(lmp); } - char str[128]; - sprintf(str,"Unknown pair style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("pair",style,lmp).c_str()); return NULL; } @@ -373,9 +371,7 @@ Bond *Force::new_bond(const char *style, int trysuffix, int &sflag) return bond_creator(lmp); } - char str[128]; - sprintf(str,"Unknown bond style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("bond",style,lmp).c_str()); return NULL; } @@ -454,9 +450,7 @@ Angle *Force::new_angle(const char *style, int trysuffix, int &sflag) return angle_creator(lmp); } - char str[128]; - sprintf(str,"Unknown angle style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("angle",style,lmp).c_str()); return NULL; } @@ -536,9 +530,7 @@ Dihedral *Force::new_dihedral(const char *style, int trysuffix, int &sflag) return dihedral_creator(lmp); } - char str[128]; - sprintf(str,"Unknown dihedral style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("dihedral",style,lmp).c_str()); return NULL; } @@ -617,9 +609,7 @@ Improper *Force::new_improper(const char *style, int trysuffix, int &sflag) return improper_creator(lmp); } - char str[128]; - sprintf(str,"Unknown improper style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("improper",style,lmp).c_str()); return NULL; } @@ -702,9 +692,7 @@ KSpace *Force::new_kspace(const char *style, int trysuffix, int &sflag) return kspace_creator(lmp); } - char str[128]; - sprintf(str,"Unknown kspace style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("kspace",style,lmp).c_str()); return NULL; } diff --git a/src/modify.cpp b/src/modify.cpp index 7f43f035d2..69cdb424b2 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -893,11 +893,8 @@ void Modify::add_fix(int narg, char **arg, int trysuffix) fix[ifix] = fix_creator(lmp,narg,arg); } - if (fix[ifix] == NULL) { - char str[128]; - snprintf(str,128,"Unknown fix style %s",arg[2]); - error->all(FLERR,str); - } + if (fix[ifix] == NULL) + error->all(FLERR,utils::check_packages_for_style("fix",arg[2],lmp).c_str()); // check if Fix is in restart_global list // if yes, pass state info to the Fix so it can reset itself @@ -1195,11 +1192,8 @@ void Modify::add_compute(int narg, char **arg, int trysuffix) compute[ncompute] = compute_creator(lmp,narg,arg); } - if (compute[ncompute] == NULL) { - char str[128]; - snprintf(str,128,"Unknown compute style %s",arg[2]); - error->all(FLERR,str); - } + if (compute[ncompute] == NULL) + error->all(FLERR,utils::check_packages_for_style("compute",arg[2],lmp).c_str()); ncompute++; } diff --git a/src/output.cpp b/src/output.cpp index 884647f478..2dcf18e7eb 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -32,6 +32,7 @@ #include "write_restart.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -585,8 +586,7 @@ void Output::add_dump(int narg, char **arg) if (dump_map->find(arg[2]) != dump_map->end()) { DumpCreator dump_creator = (*dump_map)[arg[2]]; dump[ndump] = dump_creator(lmp, narg, arg); - } - else error->all(FLERR,"Unknown dump style"); + } else error->all(FLERR,utils::check_packages_for_style("dump",arg[2],lmp).c_str()); every_dump[ndump] = force->inumeric(FLERR,arg[3]); if (every_dump[ndump] <= 0) error->all(FLERR,"Illegal dump command"); diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 7a05f4b1b5..395f4c8edd 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -40,6 +40,7 @@ #include "variable.h" #include "error.h" #include "memory.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -266,7 +267,7 @@ void ReadDump::setup_reader(int narg, char **arg) // unrecognized style - else error->all(FLERR,"Unknown dump reader style"); + else error->all(FLERR,utils::check_packages_for_style("reader",readerstyle,lmp).c_str()); // pass any arguments to readers diff --git a/src/utils.cpp b/src/utils.cpp index 42140db0ba..8468b22d8c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -128,7 +128,7 @@ void utils::sfgets(const char *srcname, int srcline, char *s, int size, std::string utils::check_packages_for_style(std::string style, std::string name, LAMMPS *lmp) { - std::string errmsg = "Unrecognized " + style + " style " + name; + std::string errmsg = "Unrecognized " + style + " style '" + name + "'"; const char *pkg = lmp->match_style(style.c_str(),name.c_str()); if (pkg) { diff --git a/src/write_dump.cpp b/src/write_dump.cpp index 6c7375012e..072680a8a5 100644 --- a/src/write_dump.cpp +++ b/src/write_dump.cpp @@ -26,6 +26,7 @@ #include "input.h" #include "update.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -64,7 +65,7 @@ void WriteDump::command(int narg, char **arg) #include "style_dump.h" #undef DUMP_CLASS - else error->all(FLERR,"Unknown dump style"); + else error->all(FLERR,utils::check_packages_for_style("dump",arg[1],lmp).c_str()); if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]);