stop with detailed parser error message with incorrect potential tables

This commit is contained in:
Axel Kohlmeyer 2022-05-28 04:19:47 -04:00
parent 886ad8359e
commit 5f811f852f
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
4 changed files with 18 additions and 43 deletions

View File

@ -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);
}
/* ----------------------------------------------------------------------

View File

@ -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,23 +373,13 @@ 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);
}
}
/* ----------------------------------------------------------------------
build spline representation of e,f over entire range of read-in table
this function sets these values in e2file,f2file

View File

@ -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++) {
}
/* ----------------------------------------------------------------------

View File

@ -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);
}
/* ----------------------------------------------------------------------