diff --git a/doc/src/Errors_details.rst b/doc/src/Errors_details.rst index 72148c2626..9af9b984fb 100644 --- a/doc/src/Errors_details.rst +++ b/doc/src/Errors_details.rst @@ -387,7 +387,17 @@ the potential energy has stabilized. .. _err007: -.. currently unused +Fix used in ... not computed at compatible time +----------------------------------------------- + +Many fix styles are invoked only every *nevery* timesteps, which means +their data is only valid on those steps. When data from a fix is used +as input for a compute, a dump, another fix, or thermo output, it must +read that data at timesteps when the fix in question was invoked, i.e. +on timesteps that are multiples of its *nevery* setting. If this is +not the case, LAMMPS will stop with an error. To remedy this, it may +be required to change the output frequency or the *nevery* setting of +the fix. .. _err0008: diff --git a/src/OPENMP/reaxff_forces_omp.cpp b/src/OPENMP/reaxff_forces_omp.cpp index ce8ad0716f..e27460c425 100644 --- a/src/OPENMP/reaxff_forces_omp.cpp +++ b/src/OPENMP/reaxff_forces_omp.cpp @@ -37,6 +37,7 @@ #include using namespace LAMMPS_NS; +using utils::errorurl; namespace ReaxFF { /* ---------------------------------------------------------------------- */ @@ -182,8 +183,8 @@ namespace ReaxFF { if (End_Index(i, bonds) > comp) system->error_ptr->one(FLERR, fmt::format("step {}: bondchk failed: " - "i={} end(i)={} str(i+1)={}\n", - step,i,End_Index(i,bonds),comp)); + "i={} end(i)={} str(i+1)={}{}", + step,i,End_Index(i,bonds),comp,errorurl(18))); } } @@ -207,8 +208,9 @@ namespace ReaxFF { if (End_Index(Hindex, hbonds) > comp) system->error_ptr->one(FLERR, fmt::format("step {}: hbondchk failed: " - "H={} end(H)={} str(H+1)={}\n", - step, Hindex,End_Index(Hindex,hbonds),comp)); + "H={} end(H)={} str(H+1)={}{}", + step, Hindex,End_Index(Hindex,hbonds),comp, + errorurl(18))); } } } diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index a1d595a086..f8ea7d9efa 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -56,7 +56,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : fchunk(nullptr), varatom(nullptr), id_fix(nullptr), fixstore(nullptr), lockfix(nullptr), chunk(nullptr), exclude(nullptr), hash(nullptr) { - if (narg < 4) error->all(FLERR, "Illegal compute chunk/atom command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "compute chunk/atom", error); peratom_flag = 1; scalar_flag = 1; @@ -101,7 +101,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : which = ArgInfo::BINSPHERE; ncoord = 1; iarg = 4; - if (iarg + 6 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 6 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom bin/sphere", error); sorigin_user[0] = utils::numeric(FLERR, arg[iarg], false, lmp); sorigin_user[1] = utils::numeric(FLERR, arg[iarg + 1], false, lmp); sorigin_user[2] = utils::numeric(FLERR, arg[iarg + 2], false, lmp); @@ -126,7 +126,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : cdim1 = 0; cdim2 = 1; } - if (iarg + 5 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 5 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom bin/cylinder", error); corigin_user[dim[0]] = 0.0; corigin_user[cdim1] = utils::numeric(FLERR, arg[iarg], false, lmp); corigin_user[cdim2] = utils::numeric(FLERR, arg[iarg + 1], false, lmp); @@ -151,7 +151,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : cfvid = argi.copy_name(); if ((which == ArgInfo::UNKNOWN) || (which == ArgInfo::NONE) || (argi.get_dim() > 1)) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, 3, "Invalid compute chunk/atom argument {}", arg[3]); iarg = 4; } @@ -178,40 +178,42 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg], "region") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom region", error); if (!domain->get_region_by_id(arg[iarg + 1])) - error->all(FLERR, "Region {} for compute chunk/atom does not exist", arg[iarg + 1]); + error->all(FLERR, iarg + 1, "Region {} for compute chunk/atom does not exist", + arg[iarg + 1]); idregion = utils::strdup(arg[iarg + 1]); regionflag = 1; iarg += 2; } else if (strcmp(arg[iarg], "nchunk") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom nchunk", error); if (strcmp(arg[iarg + 1], "once") == 0) nchunkflag = ONCE; else if (strcmp(arg[iarg + 1], "every") == 0) nchunkflag = EVERY; else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg + 1, "Unknown compute chunk/atom nchunk argument {}", arg[iarg + 1]); nchunksetflag = 1; iarg += 2; } else if (strcmp(arg[iarg], "limit") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom limit", error); limit = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); - if (limit < 0) error->all(FLERR, "Illegal compute chunk/atom command"); + if (limit < 0) + error->all(FLERR, iarg + 1, "Illegal compute chunk/atom limit value {}", limit); if (limit && !compress) limitfirst = 1; iarg += 2; if (limit) { - if (iarg > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom limit", error); if (strcmp(arg[iarg], "max") == 0) limitstyle = LIMITMAX; else if (strcmp(arg[iarg], "exact") == 0) limitstyle = LIMITEXACT; else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg, "Unknown compute chunk/atom limit keyword {}", arg[iarg]); iarg++; } } else if (strcmp(arg[iarg], "ids") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom ids", error); if (strcmp(arg[iarg + 1], "once") == 0) idsflag = ONCE; else if (strcmp(arg[iarg + 1], "nfreq") == 0) @@ -219,14 +221,14 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg + 1], "every") == 0) idsflag = EVERY; else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg + 1, "Unknown compute chunk/atom ids argument {}", arg[iarg + 1]); iarg += 2; } else if (strcmp(arg[iarg], "compress") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom compress", error); compress = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "discard") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom discard", error); if (strcmp(arg[iarg + 1], "mixed") == 0) discard = MIXED; else if (strcmp(arg[iarg + 1], "no") == 0) @@ -234,11 +236,12 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg + 1], "yes") == 0) discard = YESDISCARD; else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg + 1, "Unknown compute chunk/atom discard argument {}", + arg[iarg + 1]); discardsetflag = 1; iarg += 2; } else if (strcmp(arg[iarg], "bound") == 0) { - if (iarg + 4 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom bound", error); int idim = 0; if (strcmp(arg[iarg + 1], "x") == 0) idim = 0; @@ -247,7 +250,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg + 1], "z") == 0) idim = 2; else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg + 1, "Unknown compute chunk/atom bound argument {}", arg[iarg + 1]); minflag[idim] = COORD; if (strcmp(arg[iarg + 2], "lower") == 0) minflag[idim] = LOWER; @@ -260,7 +263,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : maxvalue[idim] = utils::numeric(FLERR, arg[iarg + 3], false, lmp); iarg += 4; } else if (strcmp(arg[iarg], "units") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom units", error); if (strcmp(arg[iarg + 1], "box") == 0) scaleflag = BOX; else if (strcmp(arg[iarg + 1], "lattice") == 0) @@ -268,14 +271,14 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg + 1], "reduced") == 0) scaleflag = REDUCED; else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg + 1, "Unknown compute chunk/atom units argument {}", arg[iarg + 1]); iarg += 2; } else if (strcmp(arg[iarg], "pbc") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute chunk/atom pbc", error); pbcflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg, "Unknown compute chunk/atom keyword {}", arg[iarg]); } // set nchunkflag and discard to default values if not explicitly set @@ -309,74 +312,82 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : // error checks if (which == ArgInfo::MOLECULE && !atom->molecule_flag) - error->all(FLERR, "Compute chunk/atom molecule for non-molecular system"); + error->all(FLERR, Error::NOLASTLINE, "Compute chunk/atom molecule for non-molecular system"); if (!binflag && discard == MIXED) - error->all(FLERR, - "Compute chunk/atom without bins " - "cannot use discard mixed"); + error->all(FLERR, Error::NOLASTLINE, + "Compute chunk/atom without bins cannot use discard mixed"); if (which == ArgInfo::BIN1D && delta[0] <= 0.0) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/1d command"); if (which == ArgInfo::BIN2D && (delta[0] <= 0.0 || delta[1] <= 0.0)) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/2d command"); if (which == ArgInfo::BIN2D && (dim[0] == dim[1])) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/2d command"); if (which == ArgInfo::BIN3D && (delta[0] <= 0.0 || delta[1] <= 0.0 || delta[2] <= 0.0)) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/3d command"); if (which == ArgInfo::BIN3D && (dim[0] == dim[1] || dim[1] == dim[2] || dim[0] == dim[2])) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/3d command"); if (which == ArgInfo::BINSPHERE) { if (domain->dimension == 2 && sorigin_user[2] != 0.0) - error->all(FLERR, "Compute chunk/atom sphere z origin must be 0.0 for 2d"); + error->all(FLERR, Error::NOLASTLINE, "Compute chunk/atom sphere z origin must be 0.0 for 2d"); if (sradmin_user < 0.0 || sradmin_user >= sradmax_user || nsbin < 1) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/sphere command"); } if (which == ArgInfo::BINCYLINDER) { - if (delta[0] <= 0.0) error->all(FLERR, "Illegal compute chunk/atom command"); + if (delta[0] <= 0.0) + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/cylinder command"); if (domain->dimension == 2 && dim[0] != 2) - error->all(FLERR, "Compute chunk/atom cylinder axis must be z for 2d"); + error->all(FLERR, Error::NOLASTLINE, "Compute chunk/atom cylinder axis must be z for 2d"); if (cradmin_user < 0.0 || cradmin_user >= cradmax_user || ncbin < 1) - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, Error::NOLASTLINE, "Illegal compute chunk/atom bin/cylinder command"); } if (which == ArgInfo::COMPUTE) { cchunk = modify->get_compute_by_id(cfvid); - if (!cchunk) error->all(FLERR, "Compute ID {} for compute chunk /atom does not exist", cfvid); + if (!cchunk) + error->all(FLERR, 3, "Compute ID {} for compute chunk /atom does not exist", cfvid); if (cchunk->peratom_flag == 0) - error->all(FLERR, "Compute chunk/atom compute does not calculate per-atom values"); + error->all(FLERR, 3, "Compute chunk/atom compute {} does not calculate per-atom values", + cfvid); if ((argindex == 0) && (cchunk->size_peratom_cols != 0)) - error->all(FLERR, "Compute chunk/atom compute does not calculate a per-atom vector"); + error->all(FLERR, 3, "Compute chunk/atom compute {} does not calculate a per-atom vector", + cfvid); if (argindex && (cchunk->size_peratom_cols == 0)) - error->all(FLERR, "Compute chunk/atom compute does not calculate a per-atom array"); + error->all(FLERR, 3, "Compute chunk/atom compute {} does not calculate a per-atom array", + cfvid); if (argindex && argindex > cchunk->size_peratom_cols) - error->all(FLERR, "Compute chunk/atom compute array is accessed out-of-range"); + error->all(FLERR, 3, "Compute chunk/atom compute {} array is accessed out-of-range{}", cfvid, + utils::errorurl(20)); } if (which == ArgInfo::FIX) { fchunk = modify->get_fix_by_id(cfvid); - if (!fchunk) error->all(FLERR, "Fix ID {} for compute chunk/atom does not exist", cfvid); + if (!fchunk) error->all(FLERR, 3, "Fix ID {} for compute chunk/atom does not exist", cfvid); if (fchunk->peratom_flag == 0) - error->all(FLERR, "Compute chunk/atom fix does not calculate per-atom values"); + error->all(FLERR, 3, "Compute chunk/atom fix {} does not calculate per-atom values", cfvid); if (argindex == 0 && fchunk->size_peratom_cols != 0) - error->all(FLERR, "Compute chunk/atom fix does not calculate a per-atom vector"); + error->all(FLERR, 3, "Compute chunk/atom fix {} does not calculate a per-atom vector", cfvid); if (argindex && fchunk->size_peratom_cols == 0) - error->all(FLERR, "Compute chunk/atom fix does not calculate a per-atom array"); + error->all(FLERR, 3, "Compute chunk/atom fix {} does not calculate a per-atom array", cfvid); if (argindex && argindex > fchunk->size_peratom_cols) - error->all(FLERR, "Compute chunk/atom fix array is accessed out-of-range"); + error->all(FLERR, 3, "Compute chunk/atom fix {} array is accessed out-of-range{}", cfvid, + utils::errorurl(20)); } if (which == ArgInfo::VARIABLE) { int ivariable = input->variable->find(cfvid); - if (ivariable < 0) error->all(FLERR, "Variable name for compute chunk/atom does not exist"); + if (ivariable < 0) + error->all(FLERR, 3, "Variable name {} for compute chunk/atom does not exist", cfvid); if (input->variable->atomstyle(ivariable) == 0) - error->all(FLERR, "Compute chunk/atom variable is not atom-style variable"); + error->all(FLERR, 3, "Compute chunk/atom variable {} is not atom-style variable", cfvid); } // setup scaling if (binflag) { if (domain->triclinic == 1 && scaleflag != REDUCED) - error->all(FLERR, "Compute chunk/atom for triclinic boxes requires units reduced"); + error->all(FLERR, Error::NOLASTLINE, + "Compute chunk/atom for triclinic boxes requires units reduced"); } if (scaleflag == LATTICE) { @@ -512,20 +523,27 @@ void ComputeChunkAtom::init() if (regionflag) { region = domain->get_region_by_id(idregion); - if (!region) error->all(FLERR, "Region {} for compute chunk/atom does not exist", idregion); + if (!region) + error->all(FLERR, Error::NOLASTLINE, "Region {} for compute chunk/atom does not exist", + idregion); } // set compute,fix,variable if (which == ArgInfo::COMPUTE) { cchunk = modify->get_compute_by_id(cfvid); - if (!cchunk) error->all(FLERR, "Compute ID {} for compute chunk/atom does not exist", cfvid); + if (!cchunk) + error->all(FLERR, Error::NOLASTLINE, "Compute ID {} for compute chunk/atom does not exist", + cfvid); } else if (which == ArgInfo::FIX) { fchunk = modify->get_fix_by_id(cfvid); - if (!fchunk) error->all(FLERR, "Fix ID {} for compute chunk/atom does not exist", cfvid); + if (!fchunk) + error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for compute chunk/atom does not exist", + cfvid); } else if (which == ArgInfo::VARIABLE) { int ivariable = input->variable->find(cfvid); - if (ivariable < 0) error->all(FLERR, "Variable name for compute chunk/atom does not exist"); + if (ivariable < 0) + error->all(FLERR, Error::NOLASTLINE, "Variable name for compute chunk/atom does not exist"); vchunk = ivariable; } @@ -540,7 +558,8 @@ void ComputeChunkAtom::init() if (molecule[i] > maxone) maxone = molecule[i]; tagint maxall; MPI_Allreduce(&maxone, &maxall, 1, MPI_LMP_TAGINT, MPI_MAX, world); - if (maxall > MAXSMALLINT) error->all(FLERR, "Molecule IDs too large for compute chunk/atom"); + if (maxall > MAXSMALLINT) + error->all(FLERR, Error::NOLASTLINE, "Molecule IDs too large for compute chunk/atom"); } // for binning, if nchunkflag not already set, set it to ONCE or EVERY @@ -560,7 +579,7 @@ void ComputeChunkAtom::init() // can't check until now since nchunkflag may have been adjusted in init() if (idsflag == ONCE && nchunkflag != ONCE) - error->all(FLERR, "Compute chunk/atom ids once but nchunk is not once"); + error->all(FLERR, Error::NOLASTLINE, "Compute chunk/atom ids once but nchunk is not once"); // create/destroy fix STORE for persistent chunk IDs as needed // need to do this if idsflag = ONCE or locks will be used by other commands @@ -658,9 +677,8 @@ void ComputeChunkAtom::lock(Fix *fixptr, bigint startstep, bigint stopstep) } if (startstep != lockstart || stopstep != lockstop) - error->all(FLERR, - "Two fix commands using " - "same compute chunk/atom command in incompatible ways"); + error->all(FLERR, Error::NOLASTLINE, + "Two fix commands using same compute chunk/atom command in incompatible ways"); // set lock to last calling Fix, since it will be last to unlock() @@ -910,7 +928,9 @@ void ComputeChunkAtom::assign_chunk_ids() if (regionflag) { region = domain->get_region_by_id(idregion); - if (!region) error->all(FLERR, "Region {} for compute chunk/atom does not exist", idregion); + if (!region) + error->all(FLERR, Error::NOLASTLINE, "Region {} for compute chunk/atom does not exist", + idregion); region->prematch(); } @@ -989,9 +1009,9 @@ void ComputeChunkAtom::assign_chunk_ids() } else if (which == ArgInfo::FIX) { if (update->ntimestep % fchunk->peratom_freq) - error->all(FLERR, - "Fix used in compute chunk/atom not " - "computed at compatible time"); + error->all(FLERR, Error::NOLASTLINE, + "Fix used in compute chunk/atom not computed at compatible time" + + utils::errorurl(7)); if (argindex == 0) { double *vec = fchunk->vector_atom; @@ -1245,7 +1265,7 @@ int ComputeChunkAtom::setup_xyz_bins() hi = origin[m] - n * delta[m]; } - if (lo > hi) error->all(FLERR, "Invalid bin bounds in compute chunk/atom"); + if (lo > hi) error->all(FLERR, Error::NOLASTLINE, "Invalid bin bounds in compute chunk/atom"); offset[m] = lo; nlayers[m] = static_cast((hi - lo) * invdelta[m] + 0.5); @@ -1324,9 +1344,8 @@ int ComputeChunkAtom::setup_sphere_bins() if (periodicity[1] && sradmax > prd_half[1]) flag = 1; if (domain->dimension == 3 && periodicity[2] && sradmax > prd_half[2]) flag = 1; if (flag) - error->all(FLERR, - "Compute chunk/atom bin/sphere radius " - "is too large for periodic box"); + error->all(FLERR, Error::NOLASTLINE, + "Compute chunk/atom bin/sphere radius is too large for periodic box"); } sinvrad = nsbin / (sradmax - sradmin); @@ -1388,9 +1407,8 @@ int ComputeChunkAtom::setup_cylinder_bins() if (periodicity[cdim1] && sradmax > prd_half[cdim1]) flag = 1; if (periodicity[cdim2] && sradmax > prd_half[cdim2]) flag = 1; if (flag) - error->all(FLERR, - "Compute chunk/atom bin/cylinder radius " - "is too large for periodic box"); + error->all(FLERR, Error::NOLASTLINE, + "Compute chunk/atom bin/cylinder radius is too large for periodic box"); } cinvrad = ncbin / (cradmax - cradmin); @@ -2002,7 +2020,7 @@ void ComputeChunkAtom::atom2bincylinder() void ComputeChunkAtom::readdim(int narg, char **arg, int iarg, int idim) { - if (narg < iarg + 3) error->all(FLERR, "Illegal compute chunk/atom command"); + if (narg < iarg + 3) utils::missing_cmd_args(FLERR, "compute chunk/atom", error); if (strcmp(arg[iarg], "x") == 0) dim[idim] = 0; else if (strcmp(arg[iarg], "y") == 0) @@ -2010,10 +2028,10 @@ void ComputeChunkAtom::readdim(int narg, char **arg, int iarg, int idim) else if (strcmp(arg[iarg], "z") == 0) dim[idim] = 2; else - error->all(FLERR, "Illegal compute chunk/atom command"); + error->all(FLERR, iarg, "Illegal compute chunk/atom dimension {}", arg[iarg]); if (dim[idim] == 2 && domain->dimension == 2) - error->all(FLERR, "Cannot use compute chunk/atom bin z for 2d model"); + error->all(FLERR, iarg, "Cannot use compute chunk/atom bin z for 2d model"); if (strcmp(arg[iarg + 1], "lower") == 0) originflag[idim] = LOWER; diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 53b8517c22..5c47b7770e 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -34,7 +34,7 @@ ComputeChunkSpreadAtom:: ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), idchunk(nullptr) { - if (narg < 5) error->all(FLERR,"Illegal compute chunk/spread/atom command"); + if (narg < 5) utils::missing_cmd_args(FLERR,"compute chunk/spread/atom", error); // ID of compute chunk/atom @@ -43,10 +43,12 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : // expand args if any have wildcard character "*" - int iarg = 4; + const int ioffset = 4; + int iarg = ioffset; int expand = 0; char **earg; - int nargnew = utils::expand_args(FLERR,narg-iarg,&arg[iarg],1,earg,lmp); + int *amap = nullptr; + int nargnew = utils::expand_args(FLERR,narg-iarg,&arg[iarg],1,earg,lmp,&amap); if (earg != &arg[iarg]) expand = 1; arg = earg; @@ -60,11 +62,13 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : value_t val; val.which = argi.get_type(); val.argindex = argi.get_index1(); + if (expand) val.iarg = amap[iarg] + ioffset; + else val.iarg = iarg + ioffset; val.id = argi.get_name(); val.val.c = nullptr; if ((val.which == ArgInfo::UNKNOWN) || (val.which == ArgInfo::NONE) || (argi.get_dim() > 1)) - error->all(FLERR,"Illegal compute chunk/spread/atom argument: {}", arg[iarg]); + error->all(FLERR, val.iarg, "Illegal compute chunk/spread/atom argument: {}", arg[iarg]); values.push_back(val); } @@ -84,41 +88,48 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : if (val.which == ArgInfo::COMPUTE) { auto icompute = modify->get_compute_by_id(val.id); if (!icompute) - error->all(FLERR,"Compute ID {} for compute chunk/spread/atom does not exist", val.id); + error->all(FLERR, val.iarg, "Compute ID {} for compute chunk/spread/atom does not exist", + val.id); if (!utils::strmatch(icompute->style,"/chunk$")) - error->all(FLERR,"Compute chunk/spread/atom compute {} does not calculate per-chunk values", + error->all(FLERR, val.iarg, + "Compute chunk/spread/atom compute {} does not calculate per-chunk values", val.id); if (val.argindex == 0) { if (!icompute->vector_flag) - error->all(FLERR,"Compute chunk/spread/atom compute {} does not calculate global vector", + error->all(FLERR, val.iarg, + "Compute chunk/spread/atom compute {} does not calculate global vector", val.id); } else { if (!icompute->array_flag) - error->all(FLERR,"Compute chunk/spread/atom compute {} does not calculate global array", + error->all(FLERR, val.iarg, + "Compute chunk/spread/atom compute {} does not calculate global array", val.id); if (val.argindex > icompute->size_array_cols) - error->all(FLERR,"Compute chunk/spread/atom compute {} array is accessed out-of-range", - val.id); + error->all(FLERR, val.iarg, + "Compute chunk/spread/atom compute {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); } val.val.c = icompute; } else if (val.which == ArgInfo::FIX) { auto ifix = modify->get_fix_by_id(val.id); if (!ifix) - error->all(FLERR,"Fix ID {} for compute chunk/spread/atom does not exist", val.id); + error->all(FLERR, val.iarg, + "Fix ID {} for compute chunk/spread/atom does not exist", val.id); if (val.argindex == 0) { if (!ifix->vector_flag) - error->all(FLERR,"Compute chunk/spread/atom {} fix does not calculate global vector", - val.id); + error->all(FLERR, val.iarg, + "Compute chunk/spread/atom {} fix does not calculate global vector", val.id); } else { if (!ifix->array_flag) - error->all(FLERR,"Compute chunk/spread/atom {} fix does not calculate global array", - val.id); + error->all(FLERR, val.iarg, + "Compute chunk/spread/atom {} fix does not calculate global array", val.id); if (val.argindex > ifix->size_array_cols) - error->all(FLERR,"Compute chunk/spread/atom fix {} array is accessed out-of-range", - val.id); + error->all(FLERR, val.iarg, + "Compute chunk/spread/atom fix {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); } } } @@ -158,12 +169,14 @@ void ComputeChunkSpreadAtom::init() if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); if (!val.val.c) - error->all(FLERR,"Compute ID {} for compute chunk/spread/atom does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, + "Compute ID {} for compute chunk/spread/atom does not exist", val.id); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); if (!val.val.f) - error->all(FLERR,"Fix ID {} for compute chunk/spread/atom does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, + "Fix ID {} for compute chunk/spread/atom does not exist", val.id); } } } @@ -174,10 +187,12 @@ void ComputeChunkSpreadAtom::init_chunk() { 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 " + error->all(FLERR, Error::NOLASTLINE, + "Chunk/atom compute {} does not exist for compute chunk/spread/atom " "or is of invalid style", idchunk); if (strcmp(cchunk->style,"chunk/atom") != 0) - error->all(FLERR,"Compute chunk/spread/atom {} does not use chunk/atom compute", idchunk); + error->all(FLERR, Error::NOLASTLINE, + "Compute chunk/spread/atom {} does not use chunk/atom compute", idchunk); } /* ---------------------------------------------------------------------- */ @@ -273,8 +288,9 @@ void ComputeChunkSpreadAtom::compute_peratom() } else if (val.which == ArgInfo::FIX) { Fix *fix = val.val.f; if (update->ntimestep % fix->global_freq) - error->all(FLERR,"Fix {} used in compute chunk/spread/atom not computed at compatible time", - val.id); + error->all(FLERR, Error::NOLASTLINE, + "Fix {} used in compute chunk/spread/atom not computed at compatible time{}", + val.id, utils::errorurl(7)); if (val.argindex == 0) { int nfix = fix->size_vector; diff --git a/src/compute_chunk_spread_atom.h b/src/compute_chunk_spread_atom.h index 4ea88e89ec..7ec646d0e5 100644 --- a/src/compute_chunk_spread_atom.h +++ b/src/compute_chunk_spread_atom.h @@ -36,6 +36,7 @@ class ComputeChunkSpreadAtom : public Compute { struct value_t { int which; int argindex; + int iarg; std::string id; union { class Compute *c; diff --git a/src/compute_global_atom.cpp b/src/compute_global_atom.cpp index f968d0c014..a68260067e 100644 --- a/src/compute_global_atom.cpp +++ b/src/compute_global_atom.cpp @@ -37,16 +37,18 @@ ComputeGlobalAtom::ComputeGlobalAtom(LAMMPS *lmp, int narg, char **arg) : // process index arg - int iarg = 3; + const int ioffset = 3; + int iarg = ioffset; ArgInfo argi(arg[iarg]); reference.which = argi.get_type(); reference.argindex = argi.get_index1(); reference.id = argi.get_name(); + reference.iarg = iarg; if ((reference.which == ArgInfo::UNKNOWN) || (reference.which == ArgInfo::NONE) || (argi.get_dim() > 1)) - error->all(FLERR,"Illegal compute global/atom index property: {}", arg[iarg]); + error->all(FLERR, iarg, "Illegal compute global/atom index property: {}", arg[iarg]); iarg++; @@ -54,7 +56,8 @@ ComputeGlobalAtom::ComputeGlobalAtom(LAMMPS *lmp, int narg, char **arg) : int expand = 0; char **earg; - int nargnew = utils::expand_args(FLERR,narg-iarg,&arg[iarg],1,earg,lmp); + int *amap = nullptr; + int nargnew = utils::expand_args(FLERR,narg-iarg,&arg[iarg],1,earg,lmp,&amap); if (earg != &arg[iarg]) expand = 1; arg = earg; @@ -69,12 +72,14 @@ ComputeGlobalAtom::ComputeGlobalAtom(LAMMPS *lmp, int narg, char **arg) : value_t val; val.which = argi2.get_type(); val.argindex = argi2.get_index1(); + if (expand) val.iarg = amap[iarg] + ioffset; + else val.iarg = iarg + ioffset; val.id = argi2.get_name(); val.val.c = nullptr; if ((val.which == ArgInfo::UNKNOWN) || (val.which == ArgInfo::NONE) || (argi2.get_dim() > 1)) - error->all(FLERR,"Illegal compute global/atom global property: {}", arg[iarg]); + error->all(FLERR, val.iarg, "Illegal compute global/atom global property: {}", arg[iarg]); values.push_back(val); } @@ -91,85 +96,92 @@ ComputeGlobalAtom::ComputeGlobalAtom(LAMMPS *lmp, int narg, char **arg) : if (reference.which == ArgInfo::COMPUTE) { reference.val.c = modify->get_compute_by_id(reference.id); if (!reference.val.c) - error->all(FLERR,"Compute ID {} for compute global/atom index", reference.id); + error->all(FLERR,reference.iarg,"Compute ID {} for compute global/atom index",reference.id); if (!reference.val.c->peratom_flag) - error->all(FLERR,"Compute global/atom compute {} does not calculate a per-atom " - "vector or array", reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom compute {} does not calculate a " + "per-atom vector or array", reference.id); if ((reference.argindex == 0) && (reference.val.c->size_peratom_cols != 0)) - error->all(FLERR,"Compute global/atom compute {} does not calculate a per-atom " - "vector", reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom compute {} does not calculate a " + "per-atom vector", reference.id); if (reference.argindex && (reference.val.c->size_peratom_cols == 0)) - error->all(FLERR,"Compute global/atom compute does not calculate a per-atom " + error->all(FLERR, reference.iarg, "Compute global/atom compute does not calculate a per-atom " "array", reference.id); if (reference.argindex && (reference.argindex > reference.val.c->size_peratom_cols)) - error->all(FLERR, "Compute global/atom compute array {} is accessed out-of-range", - reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom compute array {} is accessed " + "out-of-range{}", reference.id, utils::errorurl(20)); } else if (reference.which == ArgInfo::FIX) { reference.val.f =modify->get_fix_by_id(reference.id); if (!reference.val.f) - error->all(FLERR,"Fix ID {} for compute global/atom does not exist", reference.id); + error->all(FLERR, reference.iarg, "Fix ID {} for compute global/atom does not exist", + reference.id); if (!reference.val.f->peratom_flag) - error->all(FLERR,"Compute global/atom fix {} does not calculate a per-atom vector " - "or array", reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom fix {} does not calculate a per-atom " + "vector or array", reference.id); if (reference.argindex == 0 && (reference.val.f->size_peratom_cols != 0)) - error->all(FLERR,"Compute global/atom fix {} does not calculate a per-atom vector", - reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom fix {} does not calculate a per-atom " + "vector", reference.id); if (reference.argindex && (reference.val.f->size_peratom_cols == 0)) - error->all(FLERR,"Compute global/atom fix {} does not calculate a per-atom array", - reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom fix {} does not calculate a per-atom " + "array", reference.id); if (reference.argindex && (reference.argindex > reference.val.f->size_peratom_cols)) - error->all(FLERR, "Compute global/atom fix {} array is accessed out-of-range", reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom fix {} array is accessed " + "out-of-range{}", reference.id, utils::errorurl(20)); } else if (reference.which == ArgInfo::VARIABLE) { reference.val.v = input->variable->find(reference.id.c_str()); if (reference.val.v < 0) - error->all(FLERR,"Variable name {} for compute global/atom index does not exist", - reference.id); + error->all(FLERR, reference.iarg, "Variable name {} for compute global/atom index does " + "not exist", reference.id); if (input->variable->atomstyle(reference.val.v) == 0) - error->all(FLERR,"Compute global/atom index variable {} is not atom-style variable", - reference.id); + error->all(FLERR, reference.iarg, "Compute global/atom index variable {} is not atom-style " + "variable", reference.id); } for (auto &val : values) { if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); if (!val.val.c) - error->all(FLERR,"Compute ID {} for compute global/atom does not exist", val.id); + error->all(FLERR, val.iarg, "Compute ID {} for compute global/atom does not exist", val.id); if (val.argindex == 0) { if (!val.val.c->vector_flag) - error->all(FLERR,"Compute ID {} for global/atom compute does not calculate " + error->all(FLERR, val.iarg, "Compute ID {} for global/atom compute does not calculate " "a global vector", val.id); } else { if (!val.val.c->array_flag) - error->all(FLERR,"Compute ID {} for global/atom compute does not calculate " + error->all(FLERR, val.iarg, "Compute ID {} for global/atom compute does not calculate " "a global array", val.id); if (val.argindex > val.val.c->size_array_cols) - error->all(FLERR,"Compute global/atom compute {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute global/atom compute {} array is accessed " + "out-of-range{}", val.id, utils::errorurl(20)); } } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); - if (!val.val.f) error->all(FLERR,"Fix ID {} for compute global/atom does not exist", val.id); + if (!val.val.f) + error->all(FLERR, val.iarg, "Fix ID {} for compute global/atom does not exist", val.id); if (val.argindex == 0) { if (!val.val.f->vector_flag) - error->all(FLERR,"Fix ID {} for compute global/atom compute does not calculate " - "a global vector", val.id); + error->all(FLERR, val.iarg, "Fix ID {} for compute global/atom compute does not " + "calculate a global vector", val.id); } else { if (!val.val.f->array_flag) - error->all(FLERR,"Fix ID {} for compute global/atom compute does not calculate " - "a global array", val.id); + error->all(FLERR, val.iarg, "Fix ID {} for compute global/atom compute does not " + "calculate a global array", val.id); if (val.argindex > val.val.f->size_array_cols) - error->all(FLERR,"Compute global/atom fix {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute global/atom fix {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); } } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR,"Variable name {} for compute global/atom does not exist", val.id); + error->all(FLERR, val.iarg, "Variable name {} for compute global/atom does not exist", + val.id); if (input->variable->vectorstyle(val.val.v) == 0) - error->all(FLERR,"Compute global/atom variable {} is not vector-style variable", val.id); + error->all(FLERR, val.iarg, "Compute global/atom variable {} is not vector-style variable", + val.id); } } @@ -203,33 +215,38 @@ void ComputeGlobalAtom::init() if (reference.which == ArgInfo::COMPUTE) { reference.val.c = modify->get_compute_by_id(reference.id); if (!reference.val.c) - error->all(FLERR,"Compute ID {} for compute global/atom index does not exist", reference.id); + error->all(FLERR, Error::NOLASTLINE, "Compute ID {} for compute global/atom index does not " + "exist", reference.id); } else if (reference.which == ArgInfo::FIX) { reference.val.f = modify->get_fix_by_id(reference.id); if (reference.val.f) - error->all(FLERR,"Fix ID {} for compute global/atom index does not exist", reference.id); + error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for compute global/atom index does not exist", + reference.id); } else if (reference.which == ArgInfo::VARIABLE) { reference.val.v = input->variable->find(reference.id.c_str()); if (reference.val.v < 0) - error->all(FLERR,"Variable name {} for compute global/atom index does not exist", - reference.id); + error->all(FLERR, Error::NOLASTLINE, "Variable name {} for compute global/atom index does " + "not exist", reference.id); } for (auto &val : values) { if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); if (!val.val.c) - error->all(FLERR,"Compute ID {} for compute global/atom does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, "Compute ID {} for compute global/atom does not exist", + val.id); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); if (!val.val.f) - error->all(FLERR,"Fix ID {} for compute global/atom does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for compute global/atom does not exist", + val.id); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR,"Variable name {} for compute global/atom does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, "Variable name {} for compute global/atom does not " + "exist", val.id); } } } @@ -288,8 +305,8 @@ void ComputeGlobalAtom::compute_peratom() } else if (reference.which == ArgInfo::FIX) { if (update->ntimestep % reference.val.f->peratom_freq) - error->all(FLERR,"Fix {} used in compute global/atom not computed at compatible time", - reference.id); + error->all(FLERR, Error::NOLASTLINE, "Fix {} used in compute global/atom not computed at " + "compatible time{}", reference.id, utils::errorurl(7)); if (reference.argindex == 0) { double *fix_vector = reference.val.f->vector_atom; @@ -334,8 +351,8 @@ void ComputeGlobalAtom::compute_peratom() } else if (val.which == ArgInfo::FIX) { if (update->ntimestep % val.val.f->peratom_freq) - error->all(FLERR,"Fix {} used in compute global/atom not computed at compatible time", - val.id); + error->all(FLERR, Error::NOLASTLINE, "Fix {} used in compute global/atom not computed " + "at compatible time{}", val.id, utils::errorurl(7)); vmax = reference.val.f->size_vector; if (vmax > maxvector) { @@ -401,8 +418,8 @@ void ComputeGlobalAtom::compute_peratom() } else if (val.which == ArgInfo::FIX) { if (update->ntimestep % val.val.f->peratom_freq) - error->all(FLERR,"Fix {} used in compute global/atom not computed at compatible time", - val.id); + error->all(FLERR, Error::NOLASTLINE, "Fix {} used in compute global/atom not computed " + "at compatible time{}", val.id, utils::errorurl(7)); vmax = val.val.f->size_array_rows; if (vmax > maxvector) { diff --git a/src/compute_global_atom.h b/src/compute_global_atom.h index b8d49bf7a5..909be7b20b 100644 --- a/src/compute_global_atom.h +++ b/src/compute_global_atom.h @@ -36,6 +36,7 @@ class ComputeGlobalAtom : public Compute { struct value_t { int which; int argindex; + int iarg; std::string id; union { class Compute *c; diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index 6c4bafab4f..622e568200 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -79,7 +79,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(style, "reduce/region") == 0) { if (narg < 6) utils::missing_cmd_args(FLERR, "compute reduce/region", error); if (!domain->get_region_by_id(arg[3])) - error->all(FLERR, "Region {} for compute reduce/region does not exist", arg[3]); + error->all(FLERR, 3, "Region {} for compute reduce/region does not exist", arg[3]); idregion = utils::strdup(arg[3]); iarg = 4; } @@ -105,7 +105,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg], "minabs") == 0) mode = MINABS; else - error->all(FLERR, "Unknown compute {} mode: {}", style, arg[iarg]); + error->all(FLERR, iarg, "Unknown compute {} mode: {}", style, arg[iarg]); iarg++; if (mode == SUM || mode == SUMSQ || mode == SUMABS) { @@ -124,9 +124,12 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : // expand args if any have wildcard character "*" + int ioffset = iarg; int expand = 0; char **earg; - int nargnew = utils::expand_args(FLERR, narg - iarg, &arg[iarg], 1, earg, lmp); + char **oarg = arg; + int *amap = nullptr; + int nargnew = utils::expand_args(FLERR, narg - iarg, &arg[iarg], 1, earg, lmp, &amap); if (earg != &arg[iarg]) expand = 1; arg = earg; @@ -140,6 +143,8 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : val.id = ""; val.val.c = nullptr; + if (expand) val.iarg = amap[iarg] + ioffset; + else val.iarg = iarg + ioffset; if (strcmp(arg[iarg], "x") == 0) { val.which = ArgInfo::X; @@ -180,7 +185,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : val.id = argi.get_name(); if ((val.which == ArgInfo::UNKNOWN) || (argi.get_dim() > 1)) - error->all(FLERR, "Illegal compute {} argument: {}", style, arg[iarg]); + error->all(FLERR, val.iarg, "Illegal compute {} argument: {}", style, arg[iarg]); if (val.which == ArgInfo::NONE) break; } @@ -196,31 +201,42 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : std::string mycmd = "compute "; mycmd += style; + for (int i = 0; i < narg; ++i) { + if (strcmp(oarg[i],arg[nvalues]) == 0) + ioffset = i - nvalues; + } for (int iarg = nvalues; iarg < nargnew; iarg++) { + int errptr = iarg + ioffset; if (strcmp(arg[iarg], "replace") == 0) { - if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, mycmd + " replace", error); + if (iarg + 3 > nargnew) utils::missing_cmd_args(FLERR, mycmd + " replace", error); if (mode != MINN && mode != MAXX) - error->all(FLERR, "Compute {} replace requires min or max mode", style); + error->all(FLERR, errptr, "Compute {} replace requires min or max mode", style); int col1 = utils::inumeric(FLERR, arg[iarg + 1], false, lmp) - 1; int col2 = utils::inumeric(FLERR, arg[iarg + 2], false, lmp) - 1; if ((col1 < 0) || (col1 >= nvalues)) - error->all(FLERR, "Invalid compute {} replace first column index {}", style, col1); + error->all(FLERR, errptr + 1, "Invalid compute {} replace first column index {}", + style, col1); if ((col2 < 0) || (col2 >= nvalues)) - error->all(FLERR, "Invalid compute {} replace second column index {}", style, col2); - if (col1 == col2) error->all(FLERR, "Compute {} replace columns must be different"); + error->all(FLERR, errptr + 2, "Invalid compute {} replace second column index {}", + style, col2); + if (col1 == col2) error->all(FLERR, errptr, "Compute {} replace columns must be different"); if ((replace[col1] >= 0) || (replace[col2] >= 0)) - error->all(FLERR, "Compute {} replace column already used for another replacement"); + error->all(FLERR, errptr, + "Compute {} replace column already used for another replacement"); replace[col1] = col2; iarg += 2; } else if (strcmp(arg[iarg], "inputs") == 0) { - if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, mycmd + " inputs", error); + if (iarg + 2 > nargnew) utils::missing_cmd_args(FLERR, mycmd + " inputs", error); if (strcmp(arg[iarg + 1], "peratom") == 0) input_mode = PERATOM; else if (strcmp(arg[iarg + 1], "local") == 0) input_mode = LOCAL; + else + error->all(FLERR, errptr + 1, "Unknown compute {} inputs argument: {}", style, + arg[iarg + 1]); iarg += 1; } else - error->all(FLERR, "Unknown compute {} keyword: {}", style, arg[iarg]); + error->all(FLERR, errptr, "Unknown compute {} keyword: {}", style, arg[iarg]); } // delete replace list if not set @@ -244,72 +260,87 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : for (auto &val : values) { if (val.which == ArgInfo::X || val.which == ArgInfo::V || val.which == ArgInfo::F) { - if (input_mode == LOCAL) error->all(FLERR, "Compute {} inputs must be all local"); + if (input_mode == LOCAL) + error->all(FLERR, Error::NOPOINTER, "Compute {} inputs must be all local"); } else if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); if (!val.val.c) - error->all(FLERR, "Compute ID {} for compute {} does not exist", val.id, style); + error->all(FLERR, val.iarg, "Compute ID {} for compute {} does not exist", val.id, style); if (input_mode == PERATOM) { if (!val.val.c->peratom_flag) - error->all(FLERR, "Compute {} compute {} does not calculate per-atom values", style, - val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} does not calculate per-atom values", + style, val.id); if (val.argindex == 0 && val.val.c->size_peratom_cols != 0) - error->all(FLERR, "Compute {} compute {} does not calculate a per-atom vector", style, - val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} does not calculate a per-atom vector", + style, val.id); if (val.argindex && val.val.c->size_peratom_cols == 0) - error->all(FLERR, "Compute {} compute {} does not calculate a per-atom array", style, - val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} does not calculate a per-atom array", + style, val.id); if (val.argindex && val.argindex > val.val.c->size_peratom_cols) - error->all(FLERR, "Compute {} compute {} array is accessed out-of-range", style, val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} array is accessed out-of-range{}", + style, val.id, utils::errorurl(20)); } else if (input_mode == LOCAL) { if (!val.val.c->local_flag) - error->all(FLERR, "Compute {} compute {} does not calculate local values", style, val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} does not calculate local values", + style, val.id); if (val.argindex == 0 && val.val.c->size_local_cols != 0) - error->all(FLERR, "Compute {} compute {} does not calculate a local vector", style, - val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} does not calculate a local vector", + style, val.id); if (val.argindex && val.val.c->size_local_cols == 0) - error->all(FLERR, "Compute {} compute {} does not calculate a local array", style, - val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} does not calculate a local array", + style, val.id); if (val.argindex && val.argindex > val.val.c->size_local_cols) - error->all(FLERR, "Compute {} compute {} array is accessed out-of-range", style, val.id); + error->all(FLERR, val.iarg, "Compute {} compute {} array is accessed out-of-range{}", + style, val.id, utils::errorurl(20)); } } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); - if (!val.val.f) error->all(FLERR, "Fix ID {} for compute {} does not exist", val.id, style); + if (!val.val.f) + error->all(FLERR, val.iarg, "Fix ID {} for compute {} does not exist", val.id, style); if (input_mode == PERATOM) { if (!val.val.f->peratom_flag) - error->all(FLERR, "Compute {} fix {} does not calculate per-atom values", style, val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} does not calculate per-atom values", + style, val.id); if (val.argindex == 0 && (val.val.f->size_peratom_cols != 0)) - error->all(FLERR, "Compute {} fix {} does not calculate a per-atom vector", style, - val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} does not calculate a per-atom vector", + style, val.id); if (val.argindex && (val.val.f->size_peratom_cols == 0)) - error->all(FLERR, "Compute {} fix {} does not calculate a per-atom array", style, val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} does not calculate a per-atom array", + style, val.id); if (val.argindex && (val.argindex > val.val.f->size_peratom_cols)) - error->all(FLERR, "Compute {} fix {} array is accessed out-of-range", style, val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} array is accessed out-of-range{}", + style, val.id, utils::errorurl(20)); } else if (input_mode == LOCAL) { if (!val.val.f->local_flag) - error->all(FLERR, "Compute {} fix {} does not calculate local values", style, val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} does not calculate local values", + style, val.id); if (val.argindex == 0 && (val.val.f->size_local_cols != 0)) - error->all(FLERR, "Compute {} fix {} does not calculate a local vector", style, val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} does not calculate a local vector", + style, val.id); if (val.argindex && (val.val.f->size_local_cols == 0)) - error->all(FLERR, "Compute {} fix {} does not calculate a local array", style, val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} does not calculate a local array", + style, val.id); if (val.argindex && (val.argindex > val.val.f->size_local_cols)) - error->all(FLERR, "Compute {} fix {} array is accessed out-of-range", style, val.id); + error->all(FLERR, val.iarg, "Compute {} fix {} array is accessed out-of-range{}", + style, val.id, utils::errorurl(20)); } } else if (val.which == ArgInfo::VARIABLE) { - if (input_mode == LOCAL) error->all(FLERR, "Compute {} inputs must be all local"); + if (input_mode == LOCAL) + error->all(FLERR, Error::NOPOINTER, "Compute {} inputs must be all local"); val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR, "Variable name {} for compute {} does not exist", val.id, style); + error->all(FLERR, val.iarg, "Variable name {} for compute {} does not exist", val.id, + style); if (input->variable->atomstyle(val.val.v) == 0) - error->all(FLERR, "Compute {} variable {} is not atom-style variable", style, val.id); + error->all(FLERR, val.iarg, "Compute {} variable {} is not atom-style variable", style, + val.id); } } @@ -365,16 +396,20 @@ void ComputeReduce::init() if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); if (!val.val.c) - error->all(FLERR, "Compute ID {} for compute {} does not exist", val.id, style); + error->all(FLERR, Error::NOLASTLINE, "Compute ID {} for compute {} does not exist", + val.id, style); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); - if (!val.val.f) error->all(FLERR, "Fix ID {} for compute {} does not exist", val.id, style); + if (!val.val.f) + error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for compute {} does not exist", + val.id, style); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR, "Variable name {} for compute {} does not exist", val.id, style); + error->all(FLERR, Error::NOLASTLINE, "Variable name {} for compute {} does not exist", + val.id, style); } } @@ -382,7 +417,9 @@ void ComputeReduce::init() if (idregion) { region = domain->get_region_by_id(idregion); - if (!region) error->all(FLERR, "Region {} for compute reduce/region does not exist", idregion); + if (!region) + error->all(FLERR, Error::NOLASTLINE, "Region {} for compute reduce/region does not exist", + idregion); } } @@ -586,7 +623,8 @@ double ComputeReduce::compute_one(int m, int flag) } else if (val.which == ArgInfo::FIX) { if (update->ntimestep % val.val.f->peratom_freq) - error->all(FLERR, "Fix {} used in compute {} not computed at compatible time", val.id, style); + error->all(FLERR, Error::NOLASTLINE, "Fix {} used in compute {} not computed at " + "compatible time{}", val.id, style, utils::errorurl(7)); if (input_mode == PERATOM) { if (aidx == 0) { diff --git a/src/compute_reduce.h b/src/compute_reduce.h index f8b652e00c..ce575a4368 100644 --- a/src/compute_reduce.h +++ b/src/compute_reduce.h @@ -41,6 +41,7 @@ class ComputeReduce : public Compute { struct value_t { int which; int argindex; + int iarg; std::string id; union { class Compute *c; diff --git a/src/compute_reduce_chunk.cpp b/src/compute_reduce_chunk.cpp index 9ba0e30a8d..133932bb63 100644 --- a/src/compute_reduce_chunk.cpp +++ b/src/compute_reduce_chunk.cpp @@ -52,15 +52,17 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[4], "max") == 0) mode = MAXX; else - error->all(FLERR, "Unknown compute reduce/chunk mode: {}", arg[4]); + error->all(FLERR, 4, "Unknown compute reduce/chunk mode: {}", arg[4]); - int iarg = 5; + const int ioffset = 5; + int iarg = ioffset; // expand args if any have wildcard character "*" int expand = 0; char **earg; - int nargnew = utils::expand_args(FLERR, narg - iarg, &arg[iarg], 1, earg, lmp); + int *amap = nullptr; + int nargnew = utils::expand_args(FLERR, narg - iarg, &arg[iarg], 1, earg, lmp, &amap); if (earg != &arg[iarg]) expand = 1; arg = earg; @@ -74,11 +76,13 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) : value_t val; val.which = argi.get_type(); val.argindex = argi.get_index1(); + if (expand) val.iarg = amap[iarg] + ioffset; + else val.iarg = iarg + ioffset; val.id = argi.get_name(); val.val.c = nullptr; if ((val.which == ArgInfo::UNKNOWN) || (val.which == ArgInfo::NONE) || (argi.get_dim() > 1)) - error->all(FLERR, "Illegal compute reduce/chunk argument: {}", arg[iarg]); + error->all(FLERR, val.iarg, "Illegal compute reduce/chunk argument: {}", arg[iarg]); values.push_back(val); } @@ -96,40 +100,46 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) : if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); if (!val.val.c) - error->all(FLERR, "Compute ID {} for compute reduce/chunk does not exist", val.id); + error->all(FLERR, val.iarg, "Compute ID {} for compute reduce/chunk does not exist", + val.id); if (!val.val.c->peratom_flag) - error->all(FLERR, "Compute reduce/chunk compute {} does not calculate per-atom values", - val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk compute {} does not calculate per-atom " + "values", val.id); if ((val.argindex == 0) && (val.val.c->size_peratom_cols != 0)) - error->all(FLERR, "Compute reduce/chunk compute {} does not calculate a per-atom vector", - val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk compute {} does not calculate a " + "per-atom vector", val.id); if (val.argindex && (val.val.c->size_peratom_cols == 0)) - error->all(FLERR, "Compute reduce/chunk compute {} does not calculate a per-atom array", - val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk compute {} does not calculate a " + "per-atom array", val.id); if (val.argindex && (val.argindex > val.val.c->size_peratom_cols)) - error->all(FLERR, "Compute reduce/chunk compute array {} is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk compute array {} is accessed " + "out-of-range{}", val.id, utils::errorurl(20)); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); if (!val.val.f) - error->all(FLERR, "Fix ID {} for compute reduce/chunk does not exist", val.id); + error->all(FLERR, val.iarg, "Fix ID {} for compute reduce/chunk does not exist", val.id); if (!val.val.f->peratom_flag) - error->all(FLERR, "Compute reduce/chunk fix {} does not calculate per-atom values", val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk fix {} does not calculate per-atom " + "values", val.id); if ((val.argindex == 0) && (val.val.f->size_peratom_cols != 0)) - error->all(FLERR, "Compute reduce/chunk fix {} does not calculate a per-atom vector", - val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk fix {} does not calculate a per-atom " + "vector", val.id); if (val.argindex && (val.val.f->size_peratom_cols == 0)) - error->all(FLERR, "Compute reduce/chunk fix {} does not calculate a per-atom array", - val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk fix {} does not calculate a per-atom " + "array", val.id); if (val.argindex && (val.argindex > val.val.f->size_peratom_cols)) - error->all(FLERR, "Compute reduce/chunk fix {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute reduce/chunk fix {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR, "Variable name {} for compute reduce/chunk does not exist", val.id); + error->all(FLERR, val.iarg, "Variable name {} for compute reduce/chunk does not exist", + val.id); if (input->variable->atomstyle(val.val.v) == 0) - error->all(FLERR, "Compute reduce/chunk variable is not atom-style variable"); + error->all(FLERR, val.iarg, "Compute reduce/chunk variable {} is not atom-style variable", + val.id); } } @@ -186,17 +196,20 @@ void ComputeReduceChunk::init() if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); if (!val.val.c) - error->all(FLERR, "Compute ID {} for compute reduce/chunk does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, + "Compute ID {} for compute reduce/chunk does not exist", val.id); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); if (!val.val.f) - error->all(FLERR, "Fix ID {} for compute reduce/chunk does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for compute reduce/chunk does not exist", + val.id); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR, "Variable name {} for compute reduce/chunk does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, "Variable name {} for compute reduce/chunk does not " + "exist", val.id); } } } @@ -317,7 +330,8 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride) } else if (val.which == ArgInfo::FIX) { if (update->ntimestep % val.val.f->peratom_freq) - error->all(FLERR, "Fix used in compute reduce/chunk not computed at compatible time"); + error->all(FLERR, Error::NOLASTLINE, "Fix used in compute reduce/chunk not computed at " + "compatible time{}", utils::errorurl(7)); if (val.argindex == 0) { double *vfix = val.val.f->vector_atom; diff --git a/src/compute_reduce_chunk.h b/src/compute_reduce_chunk.h index 4055956d2d..18cbe40526 100644 --- a/src/compute_reduce_chunk.h +++ b/src/compute_reduce_chunk.h @@ -38,6 +38,7 @@ class ComputeReduceChunk : public ComputeChunk { struct value_t { int which; int argindex; + int iarg; std::string id; union { class Compute *c; diff --git a/src/compute_slice.cpp b/src/compute_slice.cpp index 9851c430c4..8a44d2bc8e 100644 --- a/src/compute_slice.cpp +++ b/src/compute_slice.cpp @@ -34,9 +34,10 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, nar nstop = utils::inumeric(FLERR, arg[4], false, lmp); nskip = utils::inumeric(FLERR, arg[5], false, lmp); - if (nstart < 1) error->all(FLERR, "Invalid compute slice nstart value {} < 1", nstart); - if (nstop < nstart) error->all(FLERR, "Invalid compute slice nstop value {} < {}", nstop, nstart); - if (nskip < 1) error->all(FLERR, "Invalid compute slice nskip value < 1: {}", nskip); + if (nstart < 1) error->all(FLERR, 3, "Invalid compute slice nstart value {} < 1", nstart); + if (nstop < nstart) + error->all(FLERR, 4, "Invalid compute slice nstop value {} < {}", nstop, nstart); + if (nskip < 1) error->all(FLERR, 5, "Invalid compute slice nskip value < 1: {}", nskip); // parse values @@ -47,11 +48,12 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, nar value_t val; val.which = argi.get_type(); val.argindex = argi.get_index1(); + val.iarg = iarg; val.id = argi.get_name(); val.val.c = nullptr; if ((val.which == ArgInfo::UNKNOWN) || (val.which == ArgInfo::NONE) || (argi.get_dim() > 1)) - error->all(FLERR, "Illegal compute slice argument: {}", arg[iarg]); + error->all(FLERR, iarg, "Illegal compute slice argument: {}", arg[iarg]); values.push_back(val); } @@ -61,49 +63,63 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, nar for (auto &val : values) { if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); - if (!val.val.c) error->all(FLERR, "Compute ID {} for compute slice does not exist", val.id); + if (!val.val.c) + error->all(FLERR, val.iarg, "Compute ID {} for compute slice does not exist", val.id); if (val.val.c->vector_flag) { if (val.argindex) - error->all(FLERR, "Compute slice compute {} does not calculate a global array", val.id); + error->all(FLERR, val.iarg, "Compute slice compute {} does not calculate a global array", + val.id); if (nstop > val.val.c->size_vector) - error->all(FLERR, "Compute slice compute {} vector is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute slice compute {} vector is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else if (val.val.c->array_flag) { if (val.argindex == 0) - error->all(FLERR, "Compute slice compute {} does not calculate a global vector", val.id); + error->all(FLERR, val.iarg, "Compute slice compute {} does not calculate a global vector", + val.id); if (val.argindex > val.val.c->size_array_cols) - error->all(FLERR, "Compute slice compute {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute slice compute {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); if (nstop > val.val.c->size_array_rows) - error->all(FLERR, "Compute slice compute {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute slice compute {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else { - error->all(FLERR, "Compute slice compute {} does not calculate global vector or array", - val.id); + error->all(FLERR, val.iarg, "Compute slice compute {} does not calculate global vector or " + "array", val.id); } } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); - if (!val.val.f) error->all(FLERR, "Fix ID {} for compute slice does not exist", val.id); + if (!val.val.f) + error->all(FLERR, val.iarg, "Fix ID {} for compute slice does not exist", val.id); if (val.val.f->vector_flag) { if (val.argindex) - error->all(FLERR, "Compute slice fix {} does not calculate a global array", val.id); + error->all(FLERR, val.iarg, "Compute slice fix {} does not calculate a global array", + val.id); if (nstop > val.val.f->size_vector) - error->all(FLERR, "Compute slice fix {} vector is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute slice fix {} vector is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else if (val.val.f->array_flag) { if (val.argindex == 0) - error->all(FLERR, "Compute slice fix {} does not calculate a global vector", val.id); + error->all(FLERR, val.iarg, "Compute slice fix {} does not calculate a global vector", + val.id); if (val.argindex > val.val.f->size_array_cols) - error->all(FLERR, "Compute slice fix {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute slice fix {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); if (nstop > val.val.f->size_array_rows) - error->all(FLERR, "Compute slice fix {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Compute slice fix {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else { - error->all(FLERR, "Compute slice fix {} does not calculate global vector or array", val.id); + error->all(FLERR, val.iarg, "Compute slice fix {} does not calculate global vector or " + "array", val.id); } } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR, "Variable name {} for compute slice does not exist", val.id); + error->all(FLERR, val.iarg, "Variable name {} for compute slice does not exist", val.id); if (val.argindex == 0 && input->variable->vectorstyle(val.val.v) == 0) - error->all(FLERR, "Compute slice variable {} is not vector-style variable", val.id); + error->all(FLERR, val.iarg, "Compute slice variable {} is not vector-style variable", + val.id); if (val.argindex) - error->all(FLERR, "Compute slice vector variable {} cannot be indexed", val.id); + error->all(FLERR, val.iarg, "Compute slice vector variable {} cannot be indexed", val.id); } } @@ -195,14 +211,18 @@ void ComputeSlice::init() for (auto &val : values) { if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); - if (!val.val.c) error->all(FLERR, "Compute ID {} for compute slice does not exist", val.id); + if (!val.val.c) + error->all(FLERR, Error::NOLASTLINE, "Compute ID {} for compute slice does not exist", + val.id); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); - if (!val.val.f) error->all(FLERR, "Fix ID {} for compute slice does not exist", val.id); + if (!val.val.f) + error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for compute slice does not exist", val.id); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR, "Variable name {} for compute slice does not exist", val.id); + error->all(FLERR, Error::NOLASTLINE, "Variable name {} for compute slice does not exist", + val.id); } } } @@ -267,7 +287,8 @@ void ComputeSlice::extract_one(int m, double *vec, int stride) } else if (val.which == ArgInfo::FIX) { if (update->ntimestep % val.val.f->global_freq) - error->all(FLERR, "Fix {} used in compute slice not computed at compatible time", val.id); + error->all(FLERR, Error::NOLASTLINE, "Fix {} used in compute slice not computed at " + "compatible time{}", val.id, utils::errorurl(7)); if (val.argindex == 0) { int j = 0; @@ -289,7 +310,8 @@ void ComputeSlice::extract_one(int m, double *vec, int stride) } else if (val.which == ArgInfo::VARIABLE) { double *varvec; int nvec = input->variable->compute_vector(val.val.v, &varvec); - if (nvec < nstop) error->all(FLERR, "Compute slice variable {} is not long enough", val.id); + if (nvec < nstop) + error->all(FLERR, Error::NOLASTLINE, "Compute slice variable {} is not long enough", val.id); int j = 0; for (int i = nstart; i < nstop; i += nskip) { vec[j] = varvec[i - 1]; diff --git a/src/compute_slice.h b/src/compute_slice.h index c1575f4fc8..ddb8a7b45e 100644 --- a/src/compute_slice.h +++ b/src/compute_slice.h @@ -36,6 +36,7 @@ class ComputeSlice : public Compute { struct value_t { int which; int argindex; + int iarg; std::string id; union { class Compute *c; diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 5c86b390ac..56836b8446 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -68,13 +68,15 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) : clearstep = 1; nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery <= 0) error->all(FLERR,"Illegal dump {} command: output frequency must be > 0", style); + if (nevery <= 0) + error->all(FLERR, 3, "Illegal dump {} command: output frequency must be > 0", style); // expand args if any have wildcard character "*" // ok to include trailing optional args, // so long as they do not have "*" between square brackets // nfield may be shrunk below if extra optional args exist + int ioffset = 5; expand = 0; nfield = nargnew = utils::expand_args(FLERR,narg-5,&arg[5],1,earg,lmp); if (earg != &arg[5]) expand = 1; @@ -446,7 +448,8 @@ void DumpCustom::init_style() fix[i] = modify->get_fix_by_id(id_fix[i]); if (!fix[i]) error->all(FLERR,"Could not find dump {} fix ID {}", style, id_fix[i]); if (nevery % fix[i]->peratom_freq) - error->all(FLERR,"Dump {} and fix not computed at compatible times", style); + error->all(FLERR,"Dump {} and fix not computed at compatible times{}", style, + utils::errorurl(7)); } for (i = 0; i < nvariable; i++) { @@ -460,7 +463,7 @@ void DumpCustom::init_style() for (int i = 0; i < ncustom; i++) { icustom = atom->find_custom(id_custom[i],flag,cols); if (icustom < 0) - error->all(FLERR,"Could not find dump {} atom property name", style); + error->all(FLERR, "Could not find dump {} atom property name", style); custom[i] = icustom; if (!flag && !cols) custom_flag[i] = IVEC; else if (flag && !cols) custom_flag[i] = DVEC; @@ -482,7 +485,8 @@ void DumpCustom::init_style() void DumpCustom::write_header(bigint ndump) { - if (!header_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump"); + if (!header_choice) + error->all(FLERR, Error::NOLASTLINE, "Must not use 'run pre no' after creating a new dump"); if (multiproc) (this->*header_choice)(ndump); else if (me == 0) (this->*header_choice)(ndump); @@ -742,7 +746,8 @@ int DumpCustom::count() if (ncompute) { for (i = 0; i < ncompute; i++) { if (!compute[i]->is_initialized()) - error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run", + error->all(FLERR, Error::NOLASTLINE, + "Dump compute ID {} cannot be invoked before initialization by a run", compute[i]->id); if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) { compute[i]->compute_peratom(); @@ -800,7 +805,7 @@ int DumpCustom::count() nstride = 1; } else if (thresh_array[ithresh] == MOL) { if (!atom->molecule_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); tagint *molecule = atom->molecule; for (i = 0; i < nlocal; i++) dchoose[i] = molecule[i]; @@ -1074,39 +1079,44 @@ int DumpCustom::count() } else if (thresh_array[ithresh] == Q) { if (!atom->q_flag) - error->all(FLERR,"Threshold for an atom property that isn't allocated"); + error->all(FLERR, Error::NOLASTLINE, + "Threshold for an atom property that isn't allocated"); ptr = atom->q; nstride = 1; } else if (thresh_array[ithresh] == MUX) { if (!atom->mu_flag) - error->all(FLERR,"Threshold for an atom property that isn't allocated"); + error->all(FLERR, Error::NOLASTLINE, + "Threshold for an atom property that isn't allocated"); ptr = &atom->mu[0][0]; nstride = 4; } else if (thresh_array[ithresh] == MUY) { if (!atom->mu_flag) - error->all(FLERR,"Threshold for an atom property that isn't allocated"); + error->all(FLERR, Error::NOLASTLINE, + "Threshold for an atom property that isn't allocated"); ptr = &atom->mu[0][1]; nstride = 4; } else if (thresh_array[ithresh] == MUZ) { if (!atom->mu_flag) - error->all(FLERR,"Threshold for an atom property that isn't allocated"); + error->all(FLERR, Error::NOLASTLINE, + "Threshold for an atom property that isn't allocated"); ptr = &atom->mu[0][2]; nstride = 4; } else if (thresh_array[ithresh] == MU) { if (!atom->mu_flag) - error->all(FLERR,"Threshold for an atom property that isn't allocated"); + error->all(FLERR, Error::NOLASTLINE, + "Threshold for an atom property that isn't allocated"); ptr = &atom->mu[0][3]; nstride = 4; } else if (thresh_array[ithresh] == RADIUS) { if (!atom->radius_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = atom->radius; nstride = 1; } else if (thresh_array[ithresh] == DIAMETER) { if (!atom->radius_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); double *radius = atom->radius; for (i = 0; i < nlocal; i++) dchoose[i] = 2.0*radius[i]; @@ -1114,55 +1124,55 @@ int DumpCustom::count() nstride = 1; } else if (thresh_array[ithresh] == OMEGAX) { if (!atom->omega_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->omega[0][0]; nstride = 3; } else if (thresh_array[ithresh] == OMEGAY) { if (!atom->omega_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->omega[0][1]; nstride = 3; } else if (thresh_array[ithresh] == OMEGAZ) { if (!atom->omega_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->omega[0][2]; nstride = 3; } else if (thresh_array[ithresh] == ANGMOMX) { if (!atom->angmom_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->angmom[0][0]; nstride = 3; } else if (thresh_array[ithresh] == ANGMOMY) { if (!atom->angmom_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->angmom[0][1]; nstride = 3; } else if (thresh_array[ithresh] == ANGMOMZ) { if (!atom->angmom_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->angmom[0][2]; nstride = 3; } else if (thresh_array[ithresh] == TQX) { if (!atom->torque_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->torque[0][0]; nstride = 3; } else if (thresh_array[ithresh] == TQY) { if (!atom->torque_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->torque[0][1]; nstride = 3; } else if (thresh_array[ithresh] == TQZ) { if (!atom->torque_flag) - error->all(FLERR, + error->all(FLERR, Error::NOLASTLINE, "Threshold for an atom property that isn't allocated"); ptr = &atom->torque[0][2]; nstride = 3; diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 7394ec4481..ac09768422 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -19,6 +19,7 @@ #include "domain.h" #include "error.h" #include "fix.h" +#include "input.h" #include "memory.h" #include "modify.h" #include "update.h" @@ -43,10 +44,10 @@ DumpLocal::DumpLocal(LAMMPS *lmp, int narg, char **arg) : clearstep = 1; nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery <= 0) error->all(FLERR,"Illegal dump local command"); + if (nevery <= 0) error->all(FLERR, 3, "Dump local nevery value {} must be > 0", nevery); if (binary) - error->all(FLERR,"Binary files are not supported with dump local"); + error->all(FLERR, 2, "Binary files are not supported with dump local"); nfield = narg - 5; @@ -170,7 +171,7 @@ void DumpLocal::init_style() columns = utils::strdup(combined); if (sort_flag && sortcol == 0) - error->all(FLERR,"Dump local cannot sort by atom ID"); + error->all(FLERR, Error::NOLASTLINE, "Dump local cannot sort by atom ID"); // format = copy of default or user-specified line format @@ -185,7 +186,7 @@ void DumpLocal::init_style() auto words = utils::split_words(format); if ((int) words.size() < size_one) - error->all(FLERR,"Dump_modify format line is too short: {}", format); + error->all(FLERR, Error::NOLASTLINE, "Dump_modify format line is too short: {}", format); int i=0; for (const auto &word : words) { @@ -218,14 +219,17 @@ void DumpLocal::init_style() for (i = 0; i < ncompute; i++) { compute[i] = modify->get_compute_by_id(id_compute[i]); - if (!compute[i]) error->all(FLERR,"Could not find dump local compute ID {}",id_compute[i]); + if (!compute[i]) + error->all(FLERR, Error::NOLASTLINE, "Could not find dump local compute ID {}",id_compute[i]); } for (i = 0; i < nfix; i++) { fix[i] = modify->get_fix_by_id(id_fix[i]); - if (!fix[i]) error->all(FLERR,"Could not find dump local fix ID {}", id_fix[i]); + if (!fix[i]) + error->all(FLERR, Error::NOLASTLINE, "Could not find dump local fix ID {}", id_fix[i]); if (nevery % fix[i]->local_freq) - error->all(FLERR,"Dump local and fix {} not computed at compatible times", id_fix[i]); + error->all(FLERR, Error::NOLASTLINE, "Dump local and fix {} not computed at " + "compatible times{}", id_fix[i], utils::errorurl(7)); } // open single file, one time only @@ -237,13 +241,17 @@ void DumpLocal::init_style() int DumpLocal::modify_param(int narg, char **arg) { + // determine offset in list of arguments for error pointer. also handle the no match case. + int argoff = 0; + while (input && input->arg[argoff] && (strcmp(input->arg[argoff], arg[0]) != 0)) argoff++; + if (strcmp(arg[0],"label") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR,"dump_modify label", error); delete[] label; label = utils::strdup(arg[1]); return 2; } else 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 @@ -262,7 +270,7 @@ int DumpLocal::modify_param(int narg, char **arg) // use of &str[1] removes leading '%' from BIGINT_FORMAT string char *ptr = strchr(format_int_user,'d'); if (ptr == nullptr) - error->all(FLERR, "Dump_modify int format does not contain d character"); + error->all(FLERR, argoff + 2, "Dump_modify int format does not contain d character"); char str[8]; snprintf(str,8,"%s",BIGINT_FORMAT); *ptr = '\0'; @@ -276,7 +284,7 @@ int DumpLocal::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, 1, "Illegal dump_modify format column number {}", i); delete[] format_column_user[i]; format_column_user[i] = utils::strdup(arg[2]); } @@ -330,8 +338,9 @@ int DumpLocal::count() if (ncompute) { for (i = 0; i < ncompute; i++) { if (!compute[i]->is_initialized()) - error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run", - compute[i]->id); + error->all(FLERR, Error::NOLASTLINE, + "Dump compute ID {} cannot be invoked before initialization by a run", + compute[i]->id); if (!(compute[i]->invoked_flag & Compute::INVOKED_LOCAL)) { compute[i]->compute_local(); compute[i]->invoked_flag |= Compute::INVOKED_LOCAL; @@ -347,14 +356,14 @@ int DumpLocal::count() for (i = 0; i < ncompute; i++) { if (nmine < 0) nmine = compute[i]->size_local_rows; else if (nmine != compute[i]->size_local_rows) - error->one(FLERR, + error->one(FLERR, Error::NOLASTLINE, "Dump local count is not consistent across input fields"); } for (i = 0; i < nfix; i++) { if (nmine < 0) nmine = fix[i]->size_local_rows; else if (nmine != fix[i]->size_local_rows) - error->one(FLERR, + error->one(FLERR, Error::NOLASTLINE, "Dump local count is not consistent across input fields"); } @@ -442,11 +451,16 @@ void DumpLocal::write_lines(int n, double *mybuf) void DumpLocal::parse_fields(int narg, char **arg) { + // determine offset in list of arguments for error pointer. + int argoff = 0; + while (input && input->arg[argoff] && (strcmp(input->arg[argoff], arg[0]) != 0)) argoff++; + int computefixflag = 0; // customize by adding to if statement for (int iarg = 0; iarg < narg; iarg++) { + int errptr = iarg + argoff; if (strcmp(arg[iarg],"index") == 0) { pack_choice[iarg] = &DumpLocal::pack_index; @@ -470,15 +484,16 @@ void DumpLocal::parse_fields(int narg, char **arg) pack_choice[iarg] = &DumpLocal::pack_compute; icompute = modify->get_compute_by_id(name); - if (!icompute) error->all(FLERR,"Could not find dump local compute ID {}",name); + if (!icompute) error->all(FLERR, errptr, "Could not find dump local compute ID {}", name); if (icompute->local_flag == 0) - error->all(FLERR,"Dump local compute {} does not compute local info", name); + error->all(FLERR, errptr, "Dump local compute {} does not compute local info", name); if (argi.get_dim() == 0 && icompute->size_local_cols > 0) - error->all(FLERR,"Dump local compute {} does not calculate local vector", name); + error->all(FLERR, errptr, "Dump local compute {} does not calculate local vector", name); if (argi.get_index1() > 0 && icompute->size_local_cols == 0) - error->all(FLERR,"Dump local compute {} does not calculate local array", name); + error->all(FLERR, errptr, "Dump local compute {} does not calculate local array", name); if (argi.get_index1() > 0 && argi.get_index1() > icompute->size_local_cols) - error->all(FLERR,"Dump local compute {} vector is accessed out-of-range", name); + error->all(FLERR, errptr, "Dump local compute {} vector is accessed out-of-range{}", + name, utils::errorurl(20)); field2index[iarg] = add_compute(name); break; @@ -490,15 +505,16 @@ void DumpLocal::parse_fields(int narg, char **arg) pack_choice[iarg] = &DumpLocal::pack_fix; ifix = modify->get_fix_by_id(name); - if (!ifix) error->all(FLERR,"Could not find dump local fix ID {}", name); + if (!ifix) error->all(FLERR, errptr, "Could not find dump local fix ID {}", name); if (ifix->local_flag == 0) - error->all(FLERR,"Dump local fix {} does not compute local info", name); + error->all(FLERR, errptr, "Dump local fix {} does not compute local info", name); if (argi.get_dim() == 0 && ifix->size_local_cols > 0) - error->all(FLERR,"Dump local fix {} does not compute local vector", name); + error->all(FLERR, errptr, "Dump local fix {} does not compute local vector", name); if (argi.get_index1() > 0 && ifix->size_local_cols == 0) - error->all(FLERR,"Dump local fix {} does not compute local array", name); + error->all(FLERR, errptr, "Dump local fix {} does not compute local array", name); if (argi.get_index1() > 0 && argi.get_index1() > ifix->size_local_cols) - error->all(FLERR,"Dump local fix {} vector is accessed out-of-range", name); + error->all(FLERR, errptr, "Dump local fix {} vector is accessed out-of-range{}", name, + utils::errorurl(20)); field2index[iarg] = add_fix(name); break; @@ -506,14 +522,14 @@ void DumpLocal::parse_fields(int narg, char **arg) case ArgInfo::NONE: // fallthrough case ArgInfo::UNKNOWN: // fallthrough default: - error->all(FLERR,"Invalid attribute {} in dump local command",arg[iarg]); + error->all(FLERR, errptr, "Invalid attribute {} in dump local command",arg[iarg]); break; } } } if (computefixflag == 0) - error->all(FLERR,"Dump local attributes contain no compute or fix"); + error->all(FLERR, Error::NOPOINTER, "Dump local attributes contain no compute or fix"); } /* ---------------------------------------------------------------------- diff --git a/src/fix_ave_atom.cpp b/src/fix_ave_atom.cpp index 1a578f527e..bd30509e0f 100644 --- a/src/fix_ave_atom.cpp +++ b/src/fix_ave_atom.cpp @@ -127,29 +127,40 @@ FixAveAtom::FixAveAtom(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), if (val.which == ArgInfo::COMPUTE) { val.val.c = modify->get_compute_by_id(val.id); - if (!val.val.c) error->all(FLERR, val.iarg, "Compute ID {} for fix ave/atom does not exist", val.id); + if (!val.val.c) + error->all(FLERR, val.iarg, "Compute ID {} for fix ave/atom does not exist", val.id); if (val.val.c->peratom_flag == 0) - error->all(FLERR, val.iarg, "Fix ave/atom compute {} does not calculate per-atom values", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom compute {} does not calculate per-atom values", + val.id); if (val.argindex == 0 && val.val.c->size_peratom_cols != 0) - error->all(FLERR, val.iarg, "Fix ave/atom compute {} does not calculate a per-atom vector", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom compute {} does not calculate a per-atom vector", + val.id); if (val.argindex && val.val.c->size_peratom_cols == 0) - error->all(FLERR, val.iarg, "Fix ave/atom compute {} does not calculate a per-atom array", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom compute {} does not calculate a per-atom array", + val.id); if (val.argindex && val.argindex > val.val.c->size_peratom_cols) - error->all(FLERR, val.iarg, "Fix ave/atom compute {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom compute {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); - if (!val.val.f) error->all(FLERR, val.iarg, "Fix ID {} for fix ave/atom does not exist", val.id); + if (!val.val.f) + error->all(FLERR, val.iarg, "Fix ID {} for fix ave/atom does not exist", val.id); if (val.val.f->peratom_flag == 0) - error->all(FLERR, val.iarg, "Fix ave/atom fix {} does not calculate per-atom values", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom fix {} does not calculate per-atom values", + val.id); if (val.argindex == 0 && val.val.f->size_peratom_cols != 0) - error->all(FLERR, val.iarg, "Fix ave/atom fix {} does not calculate a per-atom vector", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom fix {} does not calculate a per-atom vector", + val.id); if (val.argindex && val.val.f->size_peratom_cols == 0) - error->all(FLERR, val.iarg, "Fix ave/atom fix {} does not calculate a per-atom array", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom fix {} does not calculate a per-atom array", + val.id); if (val.argindex && val.argindex > val.val.f->size_peratom_cols) - error->all(FLERR, val.iarg, "Fix ave/atom fix {} array is accessed out-of-range", val.id); + error->all(FLERR, val.iarg, "Fix ave/atom fix {} array is accessed out-of-range{}", + val.id, utils::errorurl(20)); if (nevery % val.val.f->peratom_freq) - error->all(FLERR, val.iarg, "Fix {} for fix ave/atom not computed at compatible time", val.id); + error->all(FLERR, val.iarg, "Fix {} for fix ave/atom not computed at compatible time{}", + val.id, utils::errorurl(7)); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index e713842872..f2d324a073 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -262,32 +262,40 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : if (!val.val.c) error->all(FLERR, val.iarg, "Compute ID {} for fix ave/chunk does not exist",val.id); if (val.val.c->peratom_flag == 0) - error->all(FLERR, val.iarg, "Fix ave/chunk compute {} does not calculate per-atom values",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk compute {} does not calculate per-atom values", + val.id); if (val.argindex == 0 && (val.val.c->size_peratom_cols != 0)) - error->all(FLERR, val.iarg, "Fix ave/chunk compute {} does not calculate a per-atom vector",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk compute {} does not calculate a per-atom vector", + val.id); if (val.argindex && (val.val.c->size_peratom_cols == 0)) - error->all(FLERR, val.iarg, "Fix ave/chunk compute {} does not calculate a per-atom array",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk compute {} does not calculate a per-atom array", + val.id); if (val.argindex && (val.argindex > val.val.c->size_peratom_cols)) - error->all(FLERR, val.iarg, "Fix ave/chunk compute {} vector is accessed out-of-range",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk compute {} vector is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else if (val.which == ArgInfo::FIX) { val.val.f = modify->get_fix_by_id(val.id); if (!val.val.f) error->all(FLERR, val.iarg, "Fix ID {} for fix ave/chunk does not exist",val.id); if (val.val.f->peratom_flag == 0) - error->all(FLERR, val.iarg, "Fix ave/chunk fix {} does not calculate per-atom values",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk fix {} does not calculate per-atom values", + val.id); if (val.argindex == 0 && (val.val.f->size_peratom_cols != 0)) - error->all(FLERR, val.iarg, "Fix ave/chunk fix {} does not calculate a per-atom vector",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk fix {} does not calculate a per-atom vector", + val.id); if (val.argindex && (val.val.f->size_peratom_cols == 0)) - error->all(FLERR, val.iarg, "Fix ave/chunk fix {} does not calculate a per-atom array",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk fix {} does not calculate a per-atom array", + val.id); if (val.argindex && val.argindex > val.val.f->size_peratom_cols) - error->all(FLERR, val.iarg, "Fix ave/chunk fix {} vector is accessed out-of-range",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk fix {} vector is accessed out-of-range{}", + val.id, utils::errorurl(20)); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); if (val.val.v < 0) - error->all(FLERR, val.iarg, "Variable name {} for fix ave/chunk does not exist",val.id); + error->all(FLERR, val.iarg, "Variable name {} for fix ave/chunk does not exist", val.id); if (input->variable->atomstyle(val.val.v) == 0) - error->all(FLERR, val.iarg, "Fix ave/chunk variable {} is not atom-style variable",val.id); + error->all(FLERR, val.iarg, "Fix ave/chunk variable {} is not atom-style variable", val.id); } } @@ -297,8 +305,8 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : cchunk = dynamic_cast(modify->get_compute_by_id(idchunk)); if (!cchunk) - error->all(FLERR, 6, "Chunk/atom compute {} does not exist or is incorrect style for fix ave/chunk", - idchunk); + error->all(FLERR, 6, "Chunk/atom compute {} does not exist or is incorrect style for " + "fix ave/chunk", idchunk); if ((nrepeat > 1) || (ave == RUNNING) || (ave == WINDOW)) cchunk->lockcount++; lockforever = 0; @@ -445,7 +453,8 @@ void FixAveChunk::init() if (biasflag) { tbias = modify->get_compute_by_id(id_bias); if (!tbias) - error->all(FLERR,"Could not find compute ID {} for temperature bias", id_bias); + error->all(FLERR, Error::NOLASTLINE, "Could not find compute ID {} for temperature bias", + id_bias); } for (auto &val : values) { @@ -460,8 +469,8 @@ void FixAveChunk::init() error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for fix ave/chunk does not exist", val.id); if (nevery % val.val.f->peratom_freq) - error->all(FLERR, Error::NOLASTLINE, "Fix {} for fix ave/chunk not computed at compatible time", - val.id); + error->all(FLERR, Error::NOLASTLINE, "Fix {} for fix ave/chunk not computed at " + "compatible time{}", val.id, utils::errorurl(7)); } else if (val.which == ArgInfo::VARIABLE) { val.val.v = input->variable->find(val.id.c_str()); diff --git a/src/fix_ave_correlate.cpp b/src/fix_ave_correlate.cpp index a48788b777..9b2291b3d9 100644 --- a/src/fix_ave_correlate.cpp +++ b/src/fix_ave_correlate.cpp @@ -55,9 +55,10 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) : // expand args if any have wildcard character "*" - const int ioffset = 6; + int ioffset = 6; int expand = 0; char **earg; + char **oarg = arg; int *amap = nullptr; int nargnew = utils::expand_args(FLERR, narg - ioffset, &arg[ioffset], 0, earg, lmp, &amap); @@ -99,7 +100,12 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) : char *title2 = nullptr; char *title3 = nullptr; + for (int i = 0; i < narg; ++i) { + if (strcmp(oarg[i],arg[iarg]) == 0) + ioffset = i - iarg; + } while (iarg < nargnew) { + int errptr = iarg + ioffset; if (strcmp(arg[iarg],"type") == 0) { if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate type", error); if (strcmp(arg[iarg+1],"auto") == 0) type = AUTO; @@ -109,13 +115,13 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg+1],"auto/lower") == 0) type = AUTOLOWER; else if (strcmp(arg[iarg+1],"full") == 0) type = FULL; else if (strcmp(arg[iarg+1], "first") == 0) type = FIRST; - else error->all(FLERR, iarg+1, "Unknown fix ave/correlate type: {}"); + else error->all(FLERR, errptr + 1, "Unknown fix ave/correlate type: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"ave") == 0) { if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate ave", error); if (strcmp(arg[iarg+1],"one") == 0) ave = ONE; else if (strcmp(arg[iarg+1],"running") == 0) ave = RUNNING; - else error->all(FLERR, iarg+1, "Unknown fix ave/correlate ave mode: {}", arg[iarg+1]); + else error->all(FLERR, errptr+1, "Unknown fix ave/correlate ave mode: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"start") == 0) { if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate start", error); @@ -130,7 +136,7 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) : if (comm->me == 0) { fp = fopen(arg[iarg+1],"w"); if (fp == nullptr) - error->one(FLERR, iarg+1, "Cannot open fix ave/correlate file {}:"" {}", arg[iarg+1], + error->one(FLERR, errptr+1, "Cannot open fix ave/correlate file {}:"" {}", arg[iarg+1], utils::getsyserror()); } iarg += 2; @@ -152,7 +158,7 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) : delete[] title3; title3 = utils::strdup(arg[iarg+1]); iarg += 2; - } else error->all(FLERR, iarg, "Unkown fix ave/correlate keyword: {}", arg[iarg]); + } else error->all(FLERR, errptr, "Unkown fix ave/correlate keyword: {}", arg[iarg]); } // setup and error check