Update from master

This commit is contained in:
Stan Gerald Moore
2021-06-24 11:57:21 -06:00
6233 changed files with 415229 additions and 938546 deletions

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -36,7 +37,9 @@ static std::string truncpath(const std::string &path)
/* ---------------------------------------------------------------------- */
Error::Error(LAMMPS *lmp) : Pointers(lmp) {
Error::Error(LAMMPS *lmp)
: Pointers(lmp), numwarn(0), maxwarn(100), allwarn(0)
{
#ifdef LAMMPS_EXCEPTIONS
last_error_message.clear();
last_error_type = ERROR_NONE;
@ -52,8 +55,11 @@ Error::Error(LAMMPS *lmp) : Pointers(lmp) {
void Error::universe_all(const std::string &file, int line, const std::string &str)
{
MPI_Barrier(universe->uworld);
std::string mesg = fmt::format("ERROR: {} ({}:{})\n",
str,truncpath(file),line);
std::string mesg = "ERROR: " + str;
try {
mesg += fmt::format(" ({}:{})\n",truncpath(file),line);
} catch (fmt::format_error &e) {
}
if (universe->me == 0) {
if (universe->uscreen) fputs(mesg.c_str(),universe->uscreen);
if (universe->ulogfile) fputs(mesg.c_str(),universe->ulogfile);
@ -113,6 +119,8 @@ void Error::universe_one(const std::string &file, int line, const std::string &s
void Error::universe_warn(const std::string &file, int line, const std::string &str)
{
++numwarn;
if ((numwarn > maxwarn) || (allwarn > maxwarn) || (maxwarn < 0)) return;
if (universe->uscreen)
fmt::print(universe->uscreen,"WARNING on proc {}: {} ({}:{})\n",
universe->me,str,truncpath(file),line);
@ -135,9 +143,14 @@ void Error::all(const std::string &file, int line, const std::string &str)
MPI_Comm_rank(world,&me);
if (me == 0) {
std::string mesg = "ERROR: " + str;
if (input && input->line) lastcmd = input->line;
utils::logmesg(lmp,fmt::format("ERROR: {} ({}:{})\nLast command: {}\n",
str,truncpath(file),line,lastcmd));
try {
mesg += fmt::format(" ({}:{})\nLast command: {}\n",
truncpath(file),line,lastcmd);
} catch (fmt::format_error &e) {
}
utils::logmesg(lmp,mesg);
}
#ifdef LAMMPS_EXCEPTIONS
@ -206,17 +219,59 @@ void Error::one(const std::string &file, int line, const std::string &str)
#endif
}
/* ----------------------------------------------------------------------
forward vararg version to single string version
------------------------------------------------------------------------- */
void Error::_all(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
all(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
all(file,line,e.what());
}
exit(1); // to trick "smart" compilers into believing this does not return
}
void Error::_one(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
one(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
one(file,line,e.what());
}
exit(1); // to trick "smart" compilers into believing this does not return
}
/* ----------------------------------------------------------------------
called by one proc in world
only write to screen if non-nullptr on this proc since could be file
------------------------------------------------------------------------- */
void Error::warning(const std::string &file, int line, const std::string &str, int logflag)
void Error::warning(const std::string &file, int line, const std::string &str)
{
++numwarn;
if ((numwarn > maxwarn) || (allwarn > maxwarn) || (maxwarn < 0)) return;
std::string mesg = fmt::format("WARNING: {} ({}:{})\n",
str,truncpath(file),line);
if (screen) fputs(mesg.c_str(),screen);
if (logflag && logfile) fputs(mesg.c_str(),logfile);
if (logfile) fputs(mesg.c_str(),logfile);
}
/* ----------------------------------------------------------------------
forward vararg version to single string version
------------------------------------------------------------------------- */
void Error::_warning(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
warning(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
warning(file,line,e.what());
}
}
/* ----------------------------------------------------------------------
@ -224,12 +279,26 @@ void Error::warning(const std::string &file, int line, const std::string &str, i
write message to screen and logfile (if logflag is set)
------------------------------------------------------------------------- */
void Error::message(const std::string &file, int line, const std::string &str, int logflag)
void Error::message(const std::string &file, int line, const std::string &str)
{
std::string mesg = fmt::format("{} ({}:{})\n",str,truncpath(file),line);
if (screen) fputs(mesg.c_str(),screen);
if (logflag && logfile) fputs(mesg.c_str(),logfile);
if (logfile) fputs(mesg.c_str(),logfile);
}
/* ----------------------------------------------------------------------
forward vararg version to single string version
------------------------------------------------------------------------- */
void Error::_message(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
message(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
message(file,line,e.what());
}
}
/* ----------------------------------------------------------------------