From cb92a1553cf1f383f156cd8b4ac6909ec4073756 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 25 Sep 2022 17:36:31 -0400 Subject: [PATCH] improve error messages --- src/ML-PACE/pair_pace.cpp | 8 +++---- src/ML-PACE/pair_pace_extrapolation.cpp | 28 ++++++++++--------------- src/fix_pair.cpp | 2 +- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/ML-PACE/pair_pace.cpp b/src/ML-PACE/pair_pace.cpp index 4e4f226f0a..a08d6d9cdc 100644 --- a/src/ML-PACE/pair_pace.cpp +++ b/src/ML-PACE/pair_pace.cpp @@ -239,7 +239,7 @@ void PairPACE::allocate() void PairPACE::settings(int narg, char **arg) { - if (narg > 3) error->all(FLERR, "Illegal pair_style command."); + if (narg > 3) utils::missing_cmd_args(FLERR, "pair_style pace", error); // ACE potentials are parameterized in metal units if (strcmp("metal", update->unit_style) != 0) @@ -259,7 +259,7 @@ void PairPACE::settings(int narg, char **arg) chunksize = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else - error->all(FLERR, "Illegal pair_style command"); + error->all(FLERR, "Unknown pair_style pace keyword: {}", arg[iarg]); } if (comm->me == 0) { @@ -350,8 +350,8 @@ void PairPACE::coeff(int narg, char **arg) void PairPACE::init_style() { - if (atom->tag_enable == 0) error->all(FLERR, "Pair style PACE requires atom IDs"); - if (force->newton_pair == 0) error->all(FLERR, "Pair style PACE requires newton pair on"); + if (atom->tag_enable == 0) error->all(FLERR, "Pair style pace requires atom IDs"); + if (force->newton_pair == 0) error->all(FLERR, "Pair style pace requires newton pair on"); // request a full neighbor list neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/ML-PACE/pair_pace_extrapolation.cpp b/src/ML-PACE/pair_pace_extrapolation.cpp index 0ffafb21fc..b07a904292 100644 --- a/src/ML-PACE/pair_pace_extrapolation.cpp +++ b/src/ML-PACE/pair_pace_extrapolation.cpp @@ -270,12 +270,12 @@ void PairPACEExtrapolation::compute(int eflag, int vflag) void PairPACEExtrapolation::allocate() { allocated = 1; - int n = atom->ntypes; + int np1 = atom->ntypes + 1; - memory->create(setflag, n + 1, n + 1, "pair:setflag"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); - memory->create(map, n + 1, "pair:map"); - memory->create(scale, n + 1, n + 1, "pair:scale"); + memory->create(setflag, np1, np1, "pair:setflag"); + memory->create(cutsq, np1, np1, "pair:cutsq"); + memory->create(map, np1, "pair:map"); + memory->create(scale, np1, np1, "pair:scale"); } /* ---------------------------------------------------------------------- @@ -284,14 +284,10 @@ void PairPACEExtrapolation::allocate() void PairPACEExtrapolation::settings(int narg, char **arg) { - if (narg > 0) { - error->all(FLERR, - "Illegal pair_style command. Correct form:\n\tpair_style pace/extrapolation "); - } + if (narg > 0) error->all(FLERR, "Pair style pace/extrapolation supports no keywords"); - if (comm->me == 0) { + if (comm->me == 0) utils::logmesg(lmp, "ACE/AL version: {}.{}.{}\n", VERSION_YEAR, VERSION_MONTH, VERSION_DAY); - } } /* ---------------------------------------------------------------------- @@ -301,10 +297,7 @@ void PairPACEExtrapolation::settings(int narg, char **arg) void PairPACEExtrapolation::coeff(int narg, char **arg) { - if (narg < 5) - error->all(FLERR, - "Incorrect args for pair coefficients. Correct form:\npair_coeff * * " - " elem1 elem2 ..."); + if (narg < 5) utils::missing_cmd_args(FLERR, "pair_coeff", error); if (!allocated) allocate(); @@ -401,8 +394,9 @@ void PairPACEExtrapolation::coeff(int narg, char **arg) void PairPACEExtrapolation::init_style() { - if (atom->tag_enable == 0) error->all(FLERR, "Pair style PACE requires atom IDs"); - if (force->newton_pair == 0) error->all(FLERR, "Pair style PACE requires newton pair on"); + if (atom->tag_enable == 0) error->all(FLERR, "Pair style pace/extrapolation requires atom IDs"); + if (force->newton_pair == 0) + error->all(FLERR, "Pair style pace/extrapolation requires newton pair on"); // request a full neighbor list neighbor->add_request(this, NeighConst::REQ_FULL); diff --git a/src/fix_pair.cpp b/src/fix_pair.cpp index 1f32866d63..d33324805d 100644 --- a/src/fix_pair.cpp +++ b/src/fix_pair.cpp @@ -363,7 +363,7 @@ int FixPair::modify_param(int narg, char **arg) { while (iarg < narg) { if (strcmp(arg[iarg], "every") == 0) { nevery = utils::inumeric(FLERR, arg[iarg+1], false, lmp); - if (nevery < 1) error->all(FLERR, "Illegal fix_modify pair command"); + if (nevery < 1) error->all(FLERR, "Illegal fix_modify pair every value: {}", nevery); iarg += 2; processed_args+=2; } else