From 5f811f852f12f7332ddc4db8e2177a2c5bd10a9a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 28 May 2022 04:19:47 -0400 Subject: [PATCH] stop with detailed parser error message with incorrect potential tables --- src/MOLECULE/angle_table.cpp | 14 ++++---------- src/MOLECULE/bond_table.cpp | 20 +++++--------------- src/MOLECULE/dihedral_table.cpp | 9 +++++---- src/pair_table.cpp | 18 ++++-------------- 4 files changed, 18 insertions(+), 43 deletions(-) diff --git a/src/MOLECULE/angle_table.cpp b/src/MOLECULE/angle_table.cpp index eeb30c4d64..c3959dc898 100644 --- a/src/MOLECULE/angle_table.cpp +++ b/src/MOLECULE/angle_table.cpp @@ -402,26 +402,20 @@ void AngleTable::read_table(Table *tb, char *file, char *keyword) // read a,e,f table values from file - int cerror = 0; reader.skip_line(); for (int i = 0; i < tb->ninput; i++) { - line = reader.next_line(4); + line = reader.next_line(); try { ValueTokenizer values(line); values.next_int(); tb->afile[i] = values.next_double(); tb->efile[i] = values.next_double(); tb->ffile[i] = values.next_double(); - } catch (TokenizerException &) { - ++cerror; + } catch (TokenizerException &e) { + error->one(FLERR, "Error parsing angle table '{}' line {} of {}. {}\nLine was: {}", keyword, + i + 1, tb->ninput, e.what(), line); } } - - // warn if data was read incompletely, e.g. columns were missing - - if (cerror) - error->warning(FLERR, "{} of {} lines in table incomplete or could not be parsed", cerror, - tb->ninput); } /* ---------------------------------------------------------------------- diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp index e1eac7c4c2..7af08a4a08 100644 --- a/src/MOLECULE/bond_table.cpp +++ b/src/MOLECULE/bond_table.cpp @@ -325,20 +325,20 @@ void BondTable::read_table(Table *tb, char *file, char *keyword) // read r,e,f table values from file - int cerror = 0; int r0idx = -1; reader.skip_line(); for (int i = 0; i < tb->ninput; i++) { - line = reader.next_line(4); + line = reader.next_line(); try { ValueTokenizer values(line); values.next_int(); tb->rfile[i] = values.next_double(); tb->efile[i] = values.next_double(); tb->ffile[i] = values.next_double(); - } catch (TokenizerException &) { - ++cerror; + } catch (TokenizerException &e) { + error->one(FLERR, "Error parsing bond table '{}' line {} of {}. {}\nLine was: {}", keyword, + i + 1, tb->ninput, e.what(), line); } if (tb->efile[i] < emin) { @@ -373,21 +373,11 @@ void BondTable::read_table(Table *tb, char *file, char *keyword) if (f > fleft && f > fright) ferror++; } - if (ferror) { + if (ferror) error->warning(FLERR, "{} of {} force values in table are inconsistent with -dE/dr.\n" "WARNING: Should only be flagged at inflection points", ferror, tb->ninput); - } - - // warn if data was read incompletely, e.g. columns were missing - - if (cerror) { - error->warning(FLERR, - "{} of {} lines in table were incomplete or could not be" - " parsed completely", - cerror, tb->ninput); - } } /* ---------------------------------------------------------------------- diff --git a/src/MOLECULE/dihedral_table.cpp b/src/MOLECULE/dihedral_table.cpp index ea0b30cbd5..1a9bc923a7 100644 --- a/src/MOLECULE/dihedral_table.cpp +++ b/src/MOLECULE/dihedral_table.cpp @@ -1020,23 +1020,24 @@ void DihedralTable::read_table(Table *tb, char *file, char *keyword) // read a,e,f table values from file for (int i = 0; i < tb->ninput; i++) { + line = reader.next_line(); try { + ValueTokenizer values(line); if (tb->f_unspecified) { - ValueTokenizer values = reader.next_values(3); values.next_int(); tb->phifile[i] = values.next_double(); tb->efile[i] = values.next_double(); } else { - ValueTokenizer values = reader.next_values(4); values.next_int(); tb->phifile[i] = values.next_double(); tb->efile[i] = values.next_double(); tb->ffile[i] = values.next_double(); } } catch (TokenizerException &e) { - error->one(FLERR, e.what()); + error->one(FLERR, "Error parsing dihedral table '{}' line {} of {}. {}\nLine was: {}", + keyword, i + 1, tb->ninput, e.what(), line); } - } //for (int i = 0; (i < tb->ninput) && fp; i++) { + } } /* ---------------------------------------------------------------------- diff --git a/src/pair_table.cpp b/src/pair_table.cpp index aefe9c4c4f..11bd986822 100644 --- a/src/pair_table.cpp +++ b/src/pair_table.cpp @@ -395,20 +395,18 @@ void PairTable::read_table(Table *tb, char *file, char *keyword) union_int_float_t rsq_lookup; int rerror = 0; - int cerror = 0; - reader.skip_line(); for (int i = 0; i < tb->ninput; i++) { - line = reader.next_line(4); - + line = reader.next_line(); try { ValueTokenizer values(line); values.next_int(); rfile = values.next_double(); tb->efile[i] = conversion_factor * values.next_double(); tb->ffile[i] = conversion_factor * values.next_double(); - } catch (TokenizerException &) { - ++cerror; + } catch (TokenizerException &e) { + error->one(FLERR, "Error parsing pair table '{}' line {} of {}. {}\nLine was: {}", keyword, + i + 1, tb->ninput, e.what(), line); } rnew = rfile; @@ -474,14 +472,6 @@ void PairTable::read_table(Table *tb, char *file, char *keyword) "{} of {} distance values in table {} with relative error\n" "WARNING: over {} to re-computed values", rerror, tb->ninput, EPSILONR, keyword); - - // warn if data was read incompletely, e.g. columns were missing - - if (cerror) - error->warning(FLERR, - "{} of {} lines in table {} were incomplete\n" - "WARNING: or could not be parsed completely", - cerror, tb->ninput, keyword); } /* ----------------------------------------------------------------------