From 899fa8166a6d871068f4afaa9887fcd455c3aa7f Mon Sep 17 00:00:00 2001 From: Fernando Posada Date: Mon, 8 Aug 2022 17:31:42 -0400 Subject: [PATCH 1/9] Initial modifications LAMMPS code clinic 2022 --- src/fix_nh.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index cb0408a50c..d62b13d858 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -658,19 +658,19 @@ void FixNH::init() // set temperature and pressure ptrs - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Temperature ID for fix nvt/npt does not exist"); - temperature = modify->compute[icompute]; + auto icompute = modify->get_compute_by_id(id_temp); + if (!icompute) + error->all(FLERR,"Temperature ID {} for fix nvt/npt does not exist", id_temp); + temperature = icompute; if (temperature->tempbias) which = BIAS; else which = NOBIAS; if (pstat_flag) { - icompute = modify->find_compute(id_press); - if (icompute < 0) - error->all(FLERR,"Pressure ID for fix npt/nph does not exist"); - pressure = modify->compute[icompute]; + icompute = modify->get_compute_by_id(id_press); + if (!icompute) + error->all(FLERR,"Pressure ID {} for fix npt/nph does not exist", id_press); + pressure = icompute; } // set timesteps and frequencies @@ -1411,10 +1411,10 @@ int FixNH::modify_param(int narg, char **arg) delete [] id_temp; id_temp = utils::strdup(arg[1]); - int icompute = modify->find_compute(arg[1]); - if (icompute < 0) - error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + auto icompute = modify->get_compute_by_id(arg[1]); + if (!icompute) + error->all(FLERR,"Could not find fix_modify temperature ID {}", arg[1]); + temperature = icompute; if (temperature->tempflag == 0) error->all(FLERR, @@ -1425,10 +1425,10 @@ int FixNH::modify_param(int narg, char **arg) // reset id_temp of pressure to new temperature ID if (pstat_flag) { - icompute = modify->find_compute(id_press); - if (icompute < 0) - error->all(FLERR,"Pressure ID for fix modify does not exist"); - modify->compute[icompute]->reset_extra_compute_fix(id_temp); + icompute = modify->get_compute_by_id(id_press); + if (!icompute) + error->all(FLERR,"Pressure ID {} for fix modify does not exist", id_press); + icompute->reset_extra_compute_fix(id_temp); } return 2; @@ -1443,9 +1443,9 @@ int FixNH::modify_param(int narg, char **arg) delete [] id_press; id_press = utils::strdup(arg[1]); - int icompute = modify->find_compute(arg[1]); - if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID"); - pressure = modify->compute[icompute]; + auto icompute = modify->get_compute_by_id(arg[1]); + if (!icompute) error->all(FLERR,"Could not find fix_modify pressure ID {}", arg[1]); + pressure = icompute; if (pressure->pressflag == 0) error->all(FLERR,"Fix_modify pressure ID does not compute pressure"); From 6873ebb17a9371f215bf75da47e60ceca68aea3d Mon Sep 17 00:00:00 2001 From: Fernando Posada Date: Tue, 9 Aug 2022 14:01:49 -0400 Subject: [PATCH 2/9] LAMMPS code clinic 2022 project 2: Replacing find_compute with get_compute_by_id where possible. --- src/compute_angmom_chunk.cpp | 7 ++----- src/compute_chunk_spread_atom.cpp | 28 +++++++++++++--------------- src/fix_nh.cpp | 22 +++++++++------------- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/compute_angmom_chunk.cpp b/src/compute_angmom_chunk.cpp index 226e0cd646..a44e577de0 100644 --- a/src/compute_angmom_chunk.cpp +++ b/src/compute_angmom_chunk.cpp @@ -185,11 +185,8 @@ void ComputeAngmomChunk::lock_enable() void ComputeAngmomChunk::lock_disable() { - int icompute = modify->find_compute(idchunk); - if (icompute >= 0) { - cchunk = dynamic_cast(modify->compute[icompute]); - cchunk->lockcount--; - } + cchunk = dynamic_cast(modify->get_compute_by_id(idchunk)); + if(cchunk) cchunk->lockcount--; } /* ---------------------------------------------------------------------- diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 3781e83aa7..a68174e058 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -89,21 +89,21 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : for (int i = 0; i < nvalues; i++) { if (which[i] == ArgInfo::COMPUTE) { - int icompute = modify->find_compute(ids[i]); - if (icompute < 0) - error->all(FLERR,"Compute ID for compute chunk/spread/atom does not exist"); + auto icompute = modify->get_compute_by_id(ids[i]); + if (!icompute) + error->all(FLERR,"Compute ID {} for compute chunk/spread/atom does not exist", ids[i]); - if (!utils::strmatch(modify->compute[icompute]->style,"/chunk$")) + if (!utils::strmatch(icompute->style,"/chunk$")) error->all(FLERR,"Compute for compute chunk/spread/atom " "does not calculate per-chunk values"); if (argindex[i] == 0) { - if (!modify->compute[icompute]->vector_flag) + if (!icompute->vector_flag) error->all(FLERR,"Compute chunk/spread/atom compute does not calculate global vector"); } else { - if (!modify->compute[icompute]->array_flag) + if (!icompute->array_flag) error->all(FLERR,"Compute chunk/spread/atom compute does not calculate global array"); - if (argindex[i] > modify->compute[icompute]->size_array_cols) + if (argindex[i] > icompute->size_array_cols) error->all(FLERR,"Compute chunk/spread/atom compute array is accessed out-of-range"); } @@ -164,14 +164,13 @@ void ComputeChunkSpreadAtom::init() if (which[m] == ArgInfo::COMPUTE) { int icompute = modify->find_compute(ids[m]); if (icompute < 0) - error->all(FLERR,"Compute ID for compute chunk/spread/atom " - "does not exist"); + error->all(FLERR,"Compute ID {} for compute chunk/spread/atom does not exist", ids[m]); value2index[m] = icompute; } else if (which[m] == ArgInfo::FIX) { int ifix = modify->find_fix(ids[m]); if (ifix < 0) - error->all(FLERR,"Fix ID for compute chunk/spread/atom does not exist"); + error->all(FLERR,"Fix ID {} for compute chunk/spread/atom does not exist", ids[m]); value2index[m] = ifix; } } @@ -181,12 +180,11 @@ void ComputeChunkSpreadAtom::init() void ComputeChunkSpreadAtom::init_chunk() { - int icompute = modify->find_compute(idchunk); - if (icompute < 0) - error->all(FLERR,"Chunk/atom compute does not exist for compute chunk/spread/atom"); - cchunk = dynamic_cast( modify->compute[icompute]); + cchunk = dynamic_cast( modify->get_compute_by_id(idchunk)); + if (!cchunk) + error->all(FLERR,"Chunk/atom compute does not exist for compute chunk/spread/atom {}", idchunk); if (strcmp(cchunk->style,"chunk/atom") != 0) - error->all(FLERR,"Compute chunk/spread/atom does not use chunk/atom compute"); + error->all(FLERR,"Compute chunk/spread/atom {} does not use chunk/atom compute", idchunk); } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index d62b13d858..ecabfde86b 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -658,19 +658,17 @@ void FixNH::init() // set temperature and pressure ptrs - auto icompute = modify->get_compute_by_id(id_temp); - if (!icompute) + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) error->all(FLERR,"Temperature ID {} for fix nvt/npt does not exist", id_temp); - temperature = icompute; if (temperature->tempbias) which = BIAS; else which = NOBIAS; if (pstat_flag) { - icompute = modify->get_compute_by_id(id_press); - if (!icompute) + pressure = modify->get_compute_by_id(id_press); + if (!pressure) error->all(FLERR,"Pressure ID {} for fix npt/nph does not exist", id_press); - pressure = icompute; } // set timesteps and frequencies @@ -1411,10 +1409,9 @@ int FixNH::modify_param(int narg, char **arg) delete [] id_temp; id_temp = utils::strdup(arg[1]); - auto icompute = modify->get_compute_by_id(arg[1]); - if (!icompute) + temperature = modify->get_compute_by_id(arg[1]); + if (!temperature) error->all(FLERR,"Could not find fix_modify temperature ID {}", arg[1]); - temperature = icompute; if (temperature->tempflag == 0) error->all(FLERR, @@ -1425,7 +1422,7 @@ int FixNH::modify_param(int narg, char **arg) // reset id_temp of pressure to new temperature ID if (pstat_flag) { - icompute = modify->get_compute_by_id(id_press); + auto icompute = modify->get_compute_by_id(id_press); if (!icompute) error->all(FLERR,"Pressure ID {} for fix modify does not exist", id_press); icompute->reset_extra_compute_fix(id_temp); @@ -1443,9 +1440,8 @@ int FixNH::modify_param(int narg, char **arg) delete [] id_press; id_press = utils::strdup(arg[1]); - auto icompute = modify->get_compute_by_id(arg[1]); - if (!icompute) error->all(FLERR,"Could not find fix_modify pressure ID {}", arg[1]); - pressure = icompute; + pressure = modify->get_compute_by_id(arg[1]); + if (!pressure) error->all(FLERR,"Could not find fix_modify pressure ID {}", arg[1]); if (pressure->pressflag == 0) error->all(FLERR,"Fix_modify pressure ID does not compute pressure"); From af1c7721579284d1777080d3b5ebbd0c72b58dfd Mon Sep 17 00:00:00 2001 From: Jiancheng Chen <2742581175@qq.com> Date: Thu, 11 Aug 2022 19:08:11 +0800 Subject: [PATCH 3/9] made some changes on minimize.cpp --- src/minimize.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/minimize.cpp b/src/minimize.cpp index e9c6ec25b3..f4743d1815 100644 --- a/src/minimize.cpp +++ b/src/minimize.cpp @@ -31,7 +31,7 @@ Minimize::Minimize(LAMMPS *lmp) : Command(lmp) {} void Minimize::command(int narg, char **arg) { - if (narg != 4) error->all(FLERR, "Illegal minimize command"); + if (narg != 4) error->all(FLERR,"Illegal minimize command: expected 4 arguments but found {}", narg); if (domain->box_exist == 0) error->all(FLERR, "Minimize command before simulation box is defined"); @@ -44,7 +44,8 @@ void Minimize::command(int narg, char **arg) update->nsteps = utils::inumeric(FLERR, arg[2], false, lmp); update->max_eval = utils::inumeric(FLERR, arg[3], false, lmp); - if (update->etol < 0.0 || update->ftol < 0.0) error->all(FLERR, "Illegal minimize command"); + if (update->etol < 0.0) error->all(FLERR, "Illegal minimize energy tolerance: {}", update->etol); + if (update->ftol < 0.0) error->all(FLERR, "Illegal minimize force tolerance: {}", update->ftol); if (lmp->citeme) lmp->citeme->flush(); update->whichflag = 2; From 6d624b782d22120f05be28cc23c180135a2886c4 Mon Sep 17 00:00:00 2001 From: Jiancheng Chen <2742581175@qq.com> Date: Fri, 12 Aug 2022 12:12:22 +0800 Subject: [PATCH 4/9] made some changes on neighbor.cpp --- src/neighbor.cpp | 82 ++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/src/neighbor.cpp b/src/neighbor.cpp index b6b095ddf4..1a7516cbce 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -1164,7 +1164,6 @@ void Neighbor::morph_unique() if (irq->cutoff != cutneighmax) { irq->unique = 1; - } else { irq->cut = 0; irq->cutoff = 0.0; @@ -1808,7 +1807,6 @@ void Neighbor::print_pairwise_info() out += " "; if (lists[i]->bin_method == 0) out += "bin: none\n"; else out += fmt::format("bin: {}\n",binnames[lists[i]->bin_method-1]); - } utils::logmesg(lmp,out); } @@ -2582,60 +2580,58 @@ void Neighbor::modify_params(int narg, char **arg) int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"every") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid every keyword: expected 1 every argument"); every = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (every <= 0) error->all(FLERR,"Illegal neigh_modify command"); + if (every <= 0) error->all(FLERR, "Invalid every argument: {}", every); iarg += 2; } else if (strcmp(arg[iarg],"delay") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid delay keyword: expected 1 delay argument"); delay = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (delay < 0) error->all(FLERR,"Illegal neigh_modify command"); + if (delay < 0) error->all(FLERR, "Invalid delay argument: {}", delay); iarg += 2; } else if (strcmp(arg[iarg],"check") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid check keyword: expected 1 check argument"); dist_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"once") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid once keyword: expected 1 once argument"); build_once = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"page") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid page keyword: expected 1 page argument"); old_pgsize = pgsize; pgsize = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"one") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid one keyword: expected 1 one argument"); old_oneatom = oneatom; oneatom = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"binsize") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid binsize keyword: expected 1 binsize argument"); binsize_user = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (binsize_user <= 0.0) binsizeflag = 0; else binsizeflag = 1; iarg += 2; } else if (strcmp(arg[iarg],"cluster") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid cluster keyword: expected 1 cluster argument"); cluster_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; - } else if (strcmp(arg[iarg],"include") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid include keyword: expected 1 include argument"); includegroup = group->find(arg[iarg+1]); - if (includegroup < 0) - error->all(FLERR,"Invalid group ID in neigh_modify command"); - if (includegroup && (atom->firstgroupname == nullptr || - strcmp(arg[iarg+1],atom->firstgroupname) != 0)) - error->all(FLERR, - "Neigh_modify include group != atom_modify first group"); + if (includegroup == -1) + error->all(FLERR, "Invalid include keyword: group {} not found", arg[iarg+1]); + if (atom->firstgroupname == nullptr) + error->all(FLERR, "Invalid include keyword: atom_modify first command must be used"); + if (strcmp(arg[iarg+1],atom->firstgroupname) != 0) + error->all(FLERR, "Neigh_modify include group != atom_modify first group: {}", atom->firstgroupname); iarg += 2; - } else if (strcmp(arg[iarg],"exclude") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) error->all(FLERR, "Invalid exclude keyword: loss exclude arguments"); if (strcmp(arg[iarg+1],"type") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+4 > narg) error->all(FLERR, "Invalid exclude type keyword: expected 2 type arguments"); if (nex_type == maxex_type) { maxex_type += EXDELTA; memory->grow(ex1_type,maxex_type,"neigh:ex1_type"); @@ -2645,9 +2641,8 @@ void Neighbor::modify_params(int narg, char **arg) ex2_type[nex_type] = utils::inumeric(FLERR,arg[iarg+3],false,lmp); nex_type++; iarg += 4; - } else if (strcmp(arg[iarg+1],"group") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+4 > narg) error->all(FLERR, "Invalid exclude group keyword: expected 2 group arguments"); if (nex_group == maxex_group) { maxex_group += EXDELTA; memory->grow(ex1_group,maxex_group,"neigh:ex1_group"); @@ -2655,14 +2650,15 @@ void Neighbor::modify_params(int narg, char **arg) } ex1_group[nex_group] = group->find(arg[iarg+2]); ex2_group[nex_group] = group->find(arg[iarg+3]); - if (ex1_group[nex_group] == -1 || ex2_group[nex_group] == -1) - error->all(FLERR,"Invalid group ID in neigh_modify command"); + if (ex1_group[nex_group] == -1) + error->all(FLERR, "Invalid exclude group keyword: group {} not found", arg[iarg+2]); + if (ex2_group[nex_group] == -1) + error->all(FLERR, "Invalid exclude group keyword: group {} not found", arg[iarg+3]); nex_group++; iarg += 4; - } else if (strcmp(arg[iarg+1],"molecule/inter") == 0 || strcmp(arg[iarg+1],"molecule/intra") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+3 > narg) error->all(FLERR, "Invalid exclude molecule keyword: expected 1 molecule argument"); if (atom->molecule_flag == 0) error->all(FLERR,"Neigh_modify exclude molecule " "requires atom attribute molecule"); @@ -2676,30 +2672,28 @@ void Neighbor::modify_params(int narg, char **arg) } ex_mol_group[nex_mol] = group->find(arg[iarg+2]); if (ex_mol_group[nex_mol] == -1) - error->all(FLERR,"Invalid group ID in neigh_modify command"); + error->all(FLERR, "Invalid exclude keyword:group {} not found", arg[iarg+2]); if (strcmp(arg[iarg+1],"molecule/intra") == 0) ex_mol_intra[nex_mol] = 1; else ex_mol_intra[nex_mol] = 0; nex_mol++; iarg += 3; - } else if (strcmp(arg[iarg+1],"none") == 0) { nex_type = nex_group = nex_mol = 0; iarg += 2; - - } else error->all(FLERR,"Illegal neigh_modify command"); + } else error->all(FLERR,"Invalid exclude keyword: {} argument doesn't exist", arg[iarg+1]); } else if (strcmp(arg[iarg],"collection/interval") == 0) { if (style != Neighbor::MULTI) error->all(FLERR,"Cannot use collection/interval command without multi setting"); if (iarg+2 > narg) - error->all(FLERR,"Invalid collection/interval command"); + error->all(FLERR, "Invalid collection/interval keyword: number of custom collections isn't set"); ncollections = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (ncollections < 1) - error->all(FLERR,"Invalid collection/interval command"); - if (iarg+1+ncollections > narg) - error->all(FLERR,"Invalid collection/interval command"); + error->all(FLERR, "Invalid collection/interval keyword: illegal number of custom collections: {}", ncollections); + if (iarg+2+ncollections > narg) + error->all(FLERR, "Invalid collection/interval keyword: expected {} separate lists of types", ncollections); int i; @@ -2728,12 +2722,12 @@ void Neighbor::modify_params(int narg, char **arg) error->all(FLERR,"Cannot use collection/type command without multi setting"); if (iarg+2 > narg) - error->all(FLERR,"Invalid collection/type command"); + error->all(FLERR, "Invalid collection/type keyword: number of custom collections isn't set"); ncollections = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (ncollections < 1) - error->all(FLERR,"Invalid collection/interval command"); - if (iarg+1+ncollections > narg) - error->all(FLERR,"Invalid collection/type command"); + error->all(FLERR, "Invalid collection/type keyword: illegal number of custom collections: {}", ncollections); + if (iarg+2+ncollections > narg) + error->all(FLERR, "Invalid collection/type keyword: expected {} separate lists of types", ncollections); int ntypes = atom->ntypes; int nlo, nhi, i, k; @@ -2774,7 +2768,7 @@ void Neighbor::modify_params(int narg, char **arg) } iarg += 2 + ncollections; - } else error->all(FLERR,"Illegal neigh_modify command"); + } else error->all(FLERR,"Illegal neigh_modify command: {} keyword doesn't exist", arg[iarg]); } } @@ -2818,7 +2812,6 @@ void Neighbor::exclusion_group_group_delete(int group1, int group2) nex_group--; } - /* ---------------------------------------------------------------------- return the value of exclude - used to check compatibility with GPU ------------------------------------------------------------------------- */ @@ -2881,7 +2874,6 @@ void Neighbor::build_collection(int istart) } } - /* ---------------------------------------------------------------------- for neighbor list statistics in Finish class ------------------------------------------------------------------------- */ @@ -2956,4 +2948,4 @@ double Neighbor::memory_usage() if (neigh_improper) bytes += neigh_improper->memory_usage(); return bytes; -} +} \ No newline at end of file From 98593b4ad581d74f39fa982705fa5845ac140d26 Mon Sep 17 00:00:00 2001 From: Jiancheng Chen <2742581175@qq.com> Date: Sat, 13 Aug 2022 08:35:20 +0800 Subject: [PATCH 5/9] Improved from last revision of neighbor.cpp --- src/neighbor.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 1a7516cbce..9e74ad3809 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -2580,47 +2580,47 @@ void Neighbor::modify_params(int narg, char **arg) int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"every") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid every keyword: expected 1 every argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify every", error); every = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (every <= 0) error->all(FLERR, "Invalid every argument: {}", every); + if (every <= 0) error->all(FLERR, "Invalid neigh_modify every argument: {}", every); iarg += 2; } else if (strcmp(arg[iarg],"delay") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid delay keyword: expected 1 delay argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify delay", error); delay = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (delay < 0) error->all(FLERR, "Invalid delay argument: {}", delay); + if (delay < 0) error->all(FLERR, "Invalid neigh_modify delay argument: {}", delay); iarg += 2; } else if (strcmp(arg[iarg],"check") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid check keyword: expected 1 check argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify check", error); dist_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"once") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid once keyword: expected 1 once argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify once", error); build_once = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"page") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid page keyword: expected 1 page argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify page", error); old_pgsize = pgsize; pgsize = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"one") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid one keyword: expected 1 one argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify one", error); old_oneatom = oneatom; oneatom = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"binsize") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid binsize keyword: expected 1 binsize argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify binsize", error); binsize_user = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (binsize_user <= 0.0) binsizeflag = 0; else binsizeflag = 1; iarg += 2; } else if (strcmp(arg[iarg],"cluster") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid cluster keyword: expected 1 cluster argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify cluster", error); cluster_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"include") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid include keyword: expected 1 include argument"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify include", error); includegroup = group->find(arg[iarg+1]); - if (includegroup == -1) + if (includegroup < 0) error->all(FLERR, "Invalid include keyword: group {} not found", arg[iarg+1]); if (atom->firstgroupname == nullptr) error->all(FLERR, "Invalid include keyword: atom_modify first command must be used"); @@ -2628,10 +2628,10 @@ void Neighbor::modify_params(int narg, char **arg) error->all(FLERR, "Neigh_modify include group != atom_modify first group: {}", atom->firstgroupname); iarg += 2; } else if (strcmp(arg[iarg],"exclude") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Invalid exclude keyword: loss exclude arguments"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude", error); if (strcmp(arg[iarg+1],"type") == 0) { - if (iarg+4 > narg) error->all(FLERR, "Invalid exclude type keyword: expected 2 type arguments"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude type", error); if (nex_type == maxex_type) { maxex_type += EXDELTA; memory->grow(ex1_type,maxex_type,"neigh:ex1_type"); @@ -2642,7 +2642,7 @@ void Neighbor::modify_params(int narg, char **arg) nex_type++; iarg += 4; } else if (strcmp(arg[iarg+1],"group") == 0) { - if (iarg+4 > narg) error->all(FLERR, "Invalid exclude group keyword: expected 2 group arguments"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude group", error); if (nex_group == maxex_group) { maxex_group += EXDELTA; memory->grow(ex1_group,maxex_group,"neigh:ex1_group"); @@ -2658,7 +2658,7 @@ void Neighbor::modify_params(int narg, char **arg) iarg += 4; } else if (strcmp(arg[iarg+1],"molecule/inter") == 0 || strcmp(arg[iarg+1],"molecule/intra") == 0) { - if (iarg+3 > narg) error->all(FLERR, "Invalid exclude molecule keyword: expected 1 molecule argument"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude molecule", error); if (atom->molecule_flag == 0) error->all(FLERR,"Neigh_modify exclude molecule " "requires atom attribute molecule"); @@ -2682,13 +2682,13 @@ void Neighbor::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg+1],"none") == 0) { nex_type = nex_group = nex_mol = 0; iarg += 2; - } else error->all(FLERR,"Invalid exclude keyword: {} argument doesn't exist", arg[iarg+1]); + } else error->all(FLERR,"Unknown neigh_modify exclude keyword: {}", arg[iarg+1]); } else if (strcmp(arg[iarg],"collection/interval") == 0) { if (style != Neighbor::MULTI) error->all(FLERR,"Cannot use collection/interval command without multi setting"); if (iarg+2 > narg) - error->all(FLERR, "Invalid collection/interval keyword: number of custom collections isn't set"); + utils::missing_cmd_args(FLERR, "neigh_modify collection/interval", error); ncollections = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (ncollections < 1) error->all(FLERR, "Invalid collection/interval keyword: illegal number of custom collections: {}", ncollections); @@ -2722,7 +2722,7 @@ void Neighbor::modify_params(int narg, char **arg) error->all(FLERR,"Cannot use collection/type command without multi setting"); if (iarg+2 > narg) - error->all(FLERR, "Invalid collection/type keyword: number of custom collections isn't set"); + utils::missing_cmd_args(FLERR, "neigh_modify collection/type", error); ncollections = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (ncollections < 1) error->all(FLERR, "Invalid collection/type keyword: illegal number of custom collections: {}", ncollections); @@ -2768,7 +2768,7 @@ void Neighbor::modify_params(int narg, char **arg) } iarg += 2 + ncollections; - } else error->all(FLERR,"Illegal neigh_modify command: {} keyword doesn't exist", arg[iarg]); + } else error->all(FLERR,"Unknown neigh_modify keyword: {}", arg[iarg]); } } @@ -2948,4 +2948,4 @@ double Neighbor::memory_usage() if (neigh_improper) bytes += neigh_improper->memory_usage(); return bytes; -} \ No newline at end of file +} From d599a541b56091aa79e8af317106c1a3210028ab Mon Sep 17 00:00:00 2001 From: Jiancheng Chen <2742581175@qq.com> Date: Sat, 13 Aug 2022 19:10:57 +0800 Subject: [PATCH 6/9] improved some error messages in velocity.cpp and dump.cpp --- src/dump.cpp | 62 ++++++++++++++++++++++++------------------------ src/velocity.cpp | 38 ++++++++++++++--------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/dump.cpp b/src/dump.cpp index 9a8bac052a..b0d1cc1408 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -1035,31 +1035,31 @@ void Dump::balance() void Dump::modify_params(int narg, char **arg) { - if (narg == 0) error->all(FLERR,"Illegal dump_modify command"); + if (narg == 0) utils::missing_cmd_args(FLERR, "dump_modify", error); int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"append") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify append", error); append_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"buffer") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify buffer", error); buffer_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); if (buffer_flag && buffer_allow == 0) error->all(FLERR,"Dump_modify buffer yes not allowed for this style"); iarg += 2; } else if (strcmp(arg[iarg],"delay") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify delay", error); delaystep = utils::bnumeric(FLERR,arg[iarg+1],false,lmp); if (delaystep >= 0) delay_flag = 1; else delay_flag = 0; iarg += 2; } else if (strcmp(arg[iarg],"every") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify every", error); int idump; for (idump = 0; idump < output->ndump; idump++) if (strcmp(id,output->dump[idump]->id) == 0) break; @@ -1070,14 +1070,14 @@ void Dump::modify_params(int narg, char **arg) n = 0; } else { n = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (n <= 0) error->all(FLERR,"Illegal dump_modify command"); + if (n <= 0) error->all(FLERR, "Invalid dump_modify every argument: {}", n); } output->mode_dump[idump] = 0; output->every_dump[idump] = n; iarg += 2; } else if (strcmp(arg[iarg],"every/time") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify every/time", error); int idump; for (idump = 0; idump < output->ndump; idump++) if (strcmp(id,output->dump[idump]->id) == 0) break; @@ -1088,7 +1088,7 @@ void Dump::modify_params(int narg, char **arg) delta = 0.0; } else { delta = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (delta <= 0.0) error->all(FLERR,"Illegal dump_modify command"); + if (delta <= 0.0) error->all(FLERR, "Invalid dump_modify every/time argument: {}", delta); } output->mode_dump[idump] = 1; output->every_time_dump[idump] = delta; @@ -1096,11 +1096,11 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"fileper") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify fileper", error); if (!multiproc) error->all(FLERR,"Cannot use dump_modify fileper without % in dump file name"); int nper = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nper <= 0) error->all(FLERR,"Illegal dump_modify command"); + if (nper <= 0) error->all(FLERR, "Invalid dump_modify fileper argument: {}", nper); multiproc = nprocs/nper; if (nprocs % nper) multiproc++; @@ -1122,22 +1122,22 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"first") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify first", error); first_flag = 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 dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify flush", error); flush_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"colname") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_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 dump_modify command"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "dump_modify colname", error); int icol = -1; if (utils::is_integer(arg[iarg + 1])) { icol = utils::inumeric(FLERR,arg[iarg + 1],false,lmp); @@ -1157,7 +1157,7 @@ void Dump::modify_params(int narg, char **arg) iarg += 3; } } else if (strcmp(arg[iarg],"format") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[iarg+1],"none") == 0) { delete[] format_line_user; @@ -1175,7 +1175,7 @@ void Dump::modify_params(int narg, char **arg) continue; } - if (iarg+3 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[iarg+1],"line") == 0) { delete[] format_line_user; @@ -1183,17 +1183,17 @@ void Dump::modify_params(int narg, char **arg) iarg += 3; } else { // pass other format options to child classes int n = modify_param(narg-iarg,&arg[iarg]); - if (n == 0) error->all(FLERR,"Illegal dump_modify command"); + if (n == 0) utils::missing_cmd_args(FLERR, "dump_modify", error); iarg += n; } } else if (strcmp(arg[iarg],"header") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify header", error); write_header_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"maxfiles") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify maxfiles", error); if (!multifile) error->all(FLERR,"Cannot use dump_modify maxfiles without * in dump file name"); // wipe out existing storage @@ -1203,7 +1203,7 @@ void Dump::modify_params(int narg, char **arg) delete[] nameslist; } maxfiles = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (maxfiles == 0) error->all(FLERR,"Illegal dump_modify command"); + if (maxfiles == 0) error->all(FLERR, "Invalid dump_modify maxfiles argument: {}", maxfiles); if (maxfiles > 0) { nameslist = new char*[maxfiles]; numfiles = 0; @@ -1213,11 +1213,11 @@ void Dump::modify_params(int narg, char **arg) } iarg += 2; } else if (strcmp(arg[iarg],"nfile") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify nfile", error); if (!multiproc) error->all(FLERR,"Cannot use dump_modify nfile without % in dump file name"); int nfile = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nfile <= 0) error->all(FLERR,"Illegal dump_modify command"); + if (nfile <= 0) error->all(FLERR, "Invalid dump_modify nfile argument: {}", nfile); nfile = MIN(nfile,nprocs); multiproc = nfile; @@ -1244,18 +1244,18 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"pad") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify pad", error); padflag = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (padflag < 0) error->all(FLERR,"Illegal dump_modify command"); + if (padflag < 0) error->all(FLERR, "Invalid dump_modify pad argument: {}", padflag); iarg += 2; } else if (strcmp(arg[iarg],"pbc") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify pbc", error); pbcflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"sort") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify sort", error); if (strcmp(arg[iarg+1],"off") == 0) sort_flag = 0; else if (strcmp(arg[iarg+1],"id") == 0) { sort_flag = 1; @@ -1265,7 +1265,7 @@ void Dump::modify_params(int narg, char **arg) sort_flag = 1; sortcol = utils::inumeric(FLERR,arg[iarg+1],false,lmp); sortorder = ASCEND; - if (sortcol == 0) error->all(FLERR,"Illegal dump_modify command"); + if (sortcol == 0) error->all(FLERR, "Invalid dump_modify sort argument: {}", sortcol); if (sortcol < 0) { sortorder = DESCEND; sortcol = -sortcol; @@ -1275,24 +1275,24 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"balance") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify blance", error); if (nprocs > 1) balance_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"time") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify time", error); time_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify units", error); unit_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else { int n = modify_param(narg-iarg,&arg[iarg]); - if (n == 0) error->all(FLERR,"Illegal dump_modify command"); + if (n == 0) utils::missing_cmd_args(FLERR, "dump_modify", error); iarg += n; } } diff --git a/src/velocity.cpp b/src/velocity.cpp index 34b8d5a700..e11317dd09 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -49,7 +49,7 @@ Velocity::Velocity(LAMMPS *lmp) : Command(lmp), rigid_fix(nullptr), temperature( void Velocity::command(int narg, char **arg) { - if (narg < 2) error->all(FLERR,"Illegal velocity command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "velocity", error); if (domain->box_exist == 0) error->all(FLERR,"Velocity command before simulation box is defined"); @@ -63,7 +63,7 @@ void Velocity::command(int narg, char **arg) // identify group igroup = group->find(arg[0]); - if (igroup == -1) error->all(FLERR,"Could not find velocity group ID"); + if (igroup == -1) error->all(FLERR, "Could not find velocity group ID {}", arg[0]); groupbit = group->bitmask[igroup]; // check if velocities of atoms in rigid bodies are updated @@ -79,7 +79,7 @@ void Velocity::command(int narg, char **arg) else if (strcmp(arg[1],"scale") == 0) style = SCALE; else if (strcmp(arg[1],"ramp") == 0) style = RAMP; else if (strcmp(arg[1],"zero") == 0) style = ZERO; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity keyword: {}", arg[1]); // set defaults @@ -163,7 +163,7 @@ void Velocity::create(double t_desired, int seed) int i; double **vhold; - if (seed <= 0) error->all(FLERR,"Illegal velocity create command"); + if (seed <= 0) error->all(FLERR, "Illegal velocity create seed argument: {}", seed); // if sum_flag set, store a copy of current velocities @@ -816,58 +816,58 @@ void Velocity::zero_rotation() void Velocity::options(int narg, char **arg) { - if (narg < 0) error->all(FLERR,"Illegal velocity command"); + if (narg < 0) utils::missing_cmd_args(FLERR, "velocity", error); int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"dist") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity dist", error); if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = UNIFORM; else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = GAUSSIAN; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity dist argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"sum") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity sum", error); sum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mom") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity mom", error); momentum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"rot") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity rot", error); rotation_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"temp") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity temp", error); temperature = modify->get_compute_by_id(arg[iarg+1]); - if (!temperature) error->all(FLERR,"Could not find velocity temperature compute ID"); + if (!temperature) error->all(FLERR,"Could not find velocity temperature compute ID: {}", arg[iarg+1]); if (temperature->tempflag == 0) error->all(FLERR,"Velocity temperature compute {} does not compute temperature", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity bias", error); bias_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"loop") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity loop", error); if (strcmp(arg[iarg+1],"all") == 0) loop_flag = ALL; else if (strcmp(arg[iarg+1],"local") == 0) loop_flag = LOCAL; else if (strcmp(arg[iarg+1],"geom") == 0) loop_flag = GEOM; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity loop argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"rigid") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity rigid", error); rigid_fix = modify->get_fix_by_id(arg[iarg+1]); if (!rigid_fix) error->all(FLERR,"Fix ID {} for velocity does not exist", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity units", error); if (strcmp(arg[iarg+1],"box") == 0) scale_flag = 0; else if (strcmp(arg[iarg+1],"lattice") == 0) scale_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity units argument: {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal velocity command"); + } else error->all(FLERR,"Unknown velocity keyword: {}", arg[iarg]); } // error check From 3292ee8299e11a61f9622f4a3ba4db76f38b4639 Mon Sep 17 00:00:00 2001 From: Jiancheng Chen <2742581175@qq.com> Date: Sun, 14 Aug 2022 10:21:49 +0800 Subject: [PATCH 7/9] Fixed the last change to modify_params function --- src/dump.cpp | 4 ++-- src/dump_custom.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dump.cpp b/src/dump.cpp index b0d1cc1408..c4b4cc02e9 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -1183,7 +1183,7 @@ void Dump::modify_params(int narg, char **arg) iarg += 3; } else { // pass other format options to child classes int n = modify_param(narg-iarg,&arg[iarg]); - if (n == 0) utils::missing_cmd_args(FLERR, "dump_modify", error); + if (n == 0) error->all(FLERR,"Unknown dump_modify format keyword: {}", arg[iarg+1]); iarg += n; } @@ -1292,7 +1292,7 @@ void Dump::modify_params(int narg, char **arg) } else { int n = modify_param(narg-iarg,&arg[iarg]); - if (n == 0) utils::missing_cmd_args(FLERR, "dump_modify", error); + if (n == 0) error->all(FLERR,"Unknown dump_modify keyword: {}", arg[iarg]); iarg += n; } } diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 9389839aca..c93e83e491 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -1673,7 +1673,7 @@ int DumpCustom::modify_param(int narg, char **arg) } if (strcmp(arg[0],"format") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[1],"none") == 0) { // just clear format_column_user allocated by this dump child class @@ -1684,7 +1684,7 @@ int DumpCustom::modify_param(int narg, char **arg) return 2; } - if (narg < 3) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[1],"int") == 0) { delete[] format_int_user; @@ -1710,7 +1710,7 @@ int DumpCustom::modify_param(int narg, char **arg) } else { int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1; if (i < 0 || i >= nfield) - error->all(FLERR,"Illegal dump_modify command"); + error->all(FLERR,"Unknown dump_modify format ID keyword: {}", arg[1]); delete[] format_column_user[i]; format_column_user[i] = utils::strdup(arg[2]); } @@ -1731,7 +1731,7 @@ int DumpCustom::modify_param(int narg, char **arg) } if (strcmp(arg[0],"refresh") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "dump_modify refresh", error); ArgInfo argi(arg[1],ArgInfo::COMPUTE); if ((argi.get_type() != ArgInfo::COMPUTE) || (argi.get_dim() != 0)) error->all(FLERR,"Illegal dump_modify command"); @@ -1743,7 +1743,7 @@ int DumpCustom::modify_param(int narg, char **arg) } if (strcmp(arg[0],"thresh") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "dump_modify thresh", error); if (strcmp(arg[1],"none") == 0) { if (nthresh) { memory->destroy(thresh_array); @@ -1765,7 +1765,7 @@ int DumpCustom::modify_param(int narg, char **arg) return 2; } - if (narg < 4) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "dump_modify thresh", error); // grow threshold arrays From 89f32e43dc0d6ef95acf61259210e910942473e3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 13 Aug 2022 23:02:04 -0400 Subject: [PATCH 8/9] update unit test for changed error message --- unittest/formats/test_dump_atom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/formats/test_dump_atom.cpp b/unittest/formats/test_dump_atom.cpp index 702325f2fb..762a01e648 100644 --- a/unittest/formats/test_dump_atom.cpp +++ b/unittest/formats/test_dump_atom.cpp @@ -624,7 +624,7 @@ TEST_F(DumpAtomTest, dump_modify_invalid) command("dump id all atom 1 dump.txt"); END_HIDE_OUTPUT(); - TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id true");); + TEST_FAILURE(".*Unknown dump_modify keyword: true.*", command("dump_modify id true");); } TEST_F(DumpAtomTest, write_dump) From d047053473ab6671367c8e8bb36e82e72dd0517c Mon Sep 17 00:00:00 2001 From: Jiancheng Chen <2742581175@qq.com> Date: Mon, 15 Aug 2022 10:51:29 +0800 Subject: [PATCH 9/9] improved some error messages in compute_msd,fix_indent and fix_nh.cpp --- src/compute_msd.cpp | 9 +++--- src/fix_indent.cpp | 26 ++++++++-------- src/fix_nh.cpp | 72 ++++++++++++++++++++++----------------------- 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index 7ecb89b4c0..90d8f47b7a 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) - : Compute(lmp, narg, arg), id_fix(nullptr) +ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), id_fix(nullptr) { if (narg < 3) error->all(FLERR, "Illegal compute msd command"); @@ -46,15 +45,15 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg], "com") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute msd com", error); comflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "average") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute msd average", error); avflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else - error->all(FLERR, "Illegal compute msd command"); + error->all(FLERR, "Unknown compute msd keyword: {}", arg[iarg]); } if (group->dynamic[igroup]) diff --git a/src/fix_indent.cpp b/src/fix_indent.cpp index 3f99d14a8c..766ec88d8e 100644 --- a/src/fix_indent.cpp +++ b/src/fix_indent.cpp @@ -43,7 +43,7 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), rstr(nullptr), pstr(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix indent command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "fix indent", error); scalar_flag = 1; vector_flag = 1; @@ -405,7 +405,7 @@ double FixIndent::compute_vector(int n) void FixIndent::options(int narg, char **arg) { - if (narg < 0) error->all(FLERR,"Illegal fix indent command"); + if (narg < 0) utils::missing_cmd_args(FLERR, "fix indent", error); istyle = NONE; xstr = ystr = zstr = rstr = pstr = nullptr; @@ -416,7 +416,7 @@ void FixIndent::options(int narg, char **arg) int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"sphere") == 0) { - if (iarg+5 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+5 > narg) utils::missing_cmd_args(FLERR, "fix indent sphere", error); if (utils::strmatch(arg[iarg+1],"^v_")) { xstr = utils::strdup(arg[iarg+1]+2); @@ -435,7 +435,7 @@ void FixIndent::options(int narg, char **arg) iarg += 5; } else if (strcmp(arg[iarg],"cylinder") == 0) { - if (iarg+5 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+5 > narg) utils::missing_cmd_args(FLERR, "fix indent cylinder", error); if (strcmp(arg[iarg+1],"x") == 0) { cdim = 0; @@ -461,7 +461,7 @@ void FixIndent::options(int narg, char **arg) if (utils::strmatch(arg[iarg+3],"^v_")) { ystr = utils::strdup(arg[iarg+3]+2); } else yvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); - } else error->all(FLERR,"Illegal fix indent command"); + } else error->all(FLERR,"Unknown fix indent cylinder argument: {}", arg[iarg+1]); if (utils::strmatch(arg[iarg+4],"^v_")) { rstr = utils::strdup(arg[iarg+4]+2); @@ -471,11 +471,11 @@ void FixIndent::options(int narg, char **arg) iarg += 5; } else if (strcmp(arg[iarg],"plane") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix indent plane", error); if (strcmp(arg[iarg+1],"x") == 0) cdim = 0; else if (strcmp(arg[iarg+1],"y") == 0) cdim = 1; else if (strcmp(arg[iarg+1],"z") == 0) cdim = 2; - else error->all(FLERR,"Illegal fix indent command"); + else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[iarg+1]); if (utils::strmatch(arg[iarg+2],"^v_")) { pstr = utils::strdup(arg[iarg+2]+2); @@ -483,23 +483,23 @@ void FixIndent::options(int narg, char **arg) if (strcmp(arg[iarg+3],"lo") == 0) planeside = -1; else if (strcmp(arg[iarg+3],"hi") == 0) planeside = 1; - else error->all(FLERR,"Illegal fix indent command"); + else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[iarg+3]); istyle = PLANE; iarg += 4; } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix indent 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 indent command"); + else error->all(FLERR,"Unknown fix indent units argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"side") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix indent side", error); if (strcmp(arg[iarg+1],"in") == 0) side = INSIDE; else if (strcmp(arg[iarg+1],"out") == 0) side = OUTSIDE; - else error->all(FLERR,"Illegal fix indent command"); + else error->all(FLERR,"Unknown fix indent side argument: {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal fix indent command"); + } else error->all(FLERR,"Unknown fix indent argument: {}", arg[iarg]); } } diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index cb0408a50c..89fbf2ef45 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -60,7 +60,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), etap_mass(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph", error); restart_global = 1; dynamic_group_allow = 1; @@ -130,7 +130,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"temp") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph temp", error); tstat_flag = 1; t_start = utils::numeric(FLERR,arg[iarg+1],false,lmp); t_target = t_start; @@ -142,7 +142,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 4; } else if (strcmp(arg[iarg],"iso") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph iso", error); pcouple = XYZ; p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); @@ -155,7 +155,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; } else if (strcmp(arg[iarg],"aniso") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph aniso", error); pcouple = NONE; p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); @@ -168,7 +168,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; } else if (strcmp(arg[iarg],"tri") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph tri", error); pcouple = NONE; scalexy = scalexz = scaleyz = 0; p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); @@ -191,7 +191,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; } else if (strcmp(arg[iarg],"x") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph x", error); p_start[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[0] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[0] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -199,7 +199,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : deviatoric_flag = 1; iarg += 4; } else if (strcmp(arg[iarg],"y") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph y", error); p_start[1] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[1] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -207,7 +207,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : deviatoric_flag = 1; iarg += 4; } else if (strcmp(arg[iarg],"z") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph z", error); p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -218,7 +218,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"yz") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph yz", error); p_start[3] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[3] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[3] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -229,7 +229,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : if (dimension == 2) error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"xz") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph xz", error); p_start[4] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[4] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[4] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -240,7 +240,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : if (dimension == 2) error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"xy") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph xy", error); p_start[5] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[5] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[5] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -250,7 +250,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 4; } else if (strcmp(arg[iarg],"couple") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph couple", error); if (strcmp(arg[iarg+1],"xyz") == 0) pcouple = XYZ; else if (strcmp(arg[iarg+1],"xy") == 0) pcouple = XY; else if (strcmp(arg[iarg+1],"yz") == 0) pcouple = YZ; @@ -260,18 +260,18 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"drag") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph drag", error); drag = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (drag < 0.0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (drag < 0.0) error->all(FLERR, "Invalid fix nvt/npt/nph drag argument: {}", drag); iarg += 2; } else if (strcmp(arg[iarg],"ptemp") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph ptemp", error); p_temp = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_temp_flag = 1; - if (p_temp <= 0.0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (p_temp <= 0.0) error->all(FLERR, "Invalid fix nvt/npt/nph ptemp argument: {}", p_temp); iarg += 2; } else if (strcmp(arg[iarg],"dilate") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph dilate", error); if (strcmp(arg[iarg+1],"all") == 0) allremap = 1; else { allremap = 0; @@ -284,62 +284,62 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"tchain") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph tchain", error); mtchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); // used by FixNVTSllod to preserve non-default value mtchain_default_flag = 0; - if (mtchain < 1) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (mtchain < 1) error->all(FLERR, "Invalid fix nvt/npt/nph tchain argument: {}", mtchain); iarg += 2; } else if (strcmp(arg[iarg],"pchain") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph pchain", error); mpchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (mpchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (mpchain < 0) error->all(FLERR, "Invalid fix nvt/npt/nph pchain argument: {}", mpchain); iarg += 2; } else if (strcmp(arg[iarg],"mtk") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph mtk", error); mtk_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"tloop") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph tloop", error); nc_tchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nc_tchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (nc_tchain < 0) error->all(FLERR, "Invalid fix nvt/npt/nph tloop argument: {}", nc_tchain); iarg += 2; } else if (strcmp(arg[iarg],"ploop") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph ploop", error); nc_pchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nc_pchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (nc_pchain < 0) error->all(FLERR, "Invalid fix nvt/npt/nph ploop argument: {}", nc_pchain); iarg += 2; } else if (strcmp(arg[iarg],"nreset") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph nreset", error); nreset_h0 = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nreset_h0 < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (nreset_h0 < 0) error->all(FLERR, "Invalid fix nvt/npt/nph nreset argument: {}", nreset_h0); iarg += 2; } else if (strcmp(arg[iarg],"scalexy") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph scalexy", error); scalexy = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scalexz") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph scalexz", error); scalexz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scaleyz") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph scaleyz", error); scaleyz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flip") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph flip", error); flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"update") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph update", error); if (strcmp(arg[iarg+1],"dipole") == 0) dipole_flag = 1; else if (strcmp(arg[iarg+1],"dipole/dlm") == 0) { dipole_flag = 1; dlm_flag = 1; - } else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + } else error->all(FLERR, "Invalid fix nvt/npt/nph update argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"fixedpoint") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph fixedpoint", error); fixedpoint[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); fixedpoint[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); fixedpoint[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -359,7 +359,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"ext") == 0) { iarg += 2; - } else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + } else error->all(FLERR,"Unknown fix nvt/npt/nph keyword: {}", arg[iarg]); } // error checks