diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 1b709a65c2..cf6374ab2d 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -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)); } } diff --git a/src/USER-MANIFOLD/fix_manifoldforce.cpp b/src/USER-MANIFOLD/fix_manifoldforce.cpp index d389b9787e..26d209e7a9 100644 --- a/src/USER-MANIFOLD/fix_manifoldforce.cpp +++ b/src/USER-MANIFOLD/fix_manifoldforce.cpp @@ -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) { diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp index 5d5bdea156..a45d62a588 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp @@ -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; } diff --git a/src/USER-MISC/dihedral_table.cpp b/src/USER-MISC/dihedral_table.cpp index 30e6192275..a81037cad6 100644 --- a/src/USER-MISC/dihedral_table.cpp +++ b/src/USER-MISC/dihedral_table.cpp @@ -1183,10 +1183,8 @@ void DihedralTable::spline_table(Table *tb) } } // for (int i=0; ininput; 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)