Skip to content

Commit

Permalink
redirect print_summary to LAMMPS log
Browse files Browse the repository at this point in the history
This commit redirects `print_summary` output to LAMMPS log function, so
it will be also shown in `log.lammps`.
  • Loading branch information
njzjz committed Dec 1, 2021
1 parent 6ce4225 commit 8931f04
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ void
PairDeepMD::print_summary(const string pre) const
{
if (comm->me == 0){
// capture cout to a string, then call LAMMPS's utils::logmesg
// https://stackoverflow.com/a/4043813/9567349
std::stringstream buffer;
std::streambuf *sbuf = std::cout.rdbuf();
std::cout.rdbuf(buffer.rdbuf());

cout << "Summary of lammps deepmd module ..." << endl;
cout << pre << ">>> Info of deepmd-kit:" << endl;
deep_pot.print_summary(pre);
Expand All @@ -279,6 +285,9 @@ PairDeepMD::print_summary(const string pre) const
cout << pre << "build float prec: " << STR_FLOAT_PREC << endl;
cout << pre << "build with tf inc: " << STR_TensorFlow_INCLUDE_DIRS << endl;
cout << pre << "build with tf lib: " << STR_TensorFlow_LIBRARY << endl;

std::cout.rdbuf(sbuf);
utils::logmesg(lmp, buffer.str());
}
}

Expand Down

0 comments on commit 8931f04

Please sign in to comment.