Add utils::flush_buffers()
This commit is contained in:
@ -5449,11 +5449,7 @@ to simplify capturing output from LAMMPS library calls.
|
||||
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
||||
*/
|
||||
void lammps_flush_buffers(void *handle) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
if (lmp->screen) fflush(lmp->screen);
|
||||
if (lmp->logfile) fflush(lmp->logfile);
|
||||
if (lmp->universe->uscreen) fflush(lmp->universe->uscreen);
|
||||
if (lmp->universe->ulogfile) fflush(lmp->universe->ulogfile);
|
||||
utils::flush_buffers((LAMMPS *) handle);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include "text_file_reader.h"
|
||||
#include "tokenizer.h"
|
||||
#include "update.h"
|
||||
#include "universe.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
@ -138,6 +139,14 @@ void utils::fmtargs_logmesg(LAMMPS *lmp, fmt::string_view format, fmt::format_ar
|
||||
}
|
||||
}
|
||||
|
||||
void utils::flush_buffers(LAMMPS *lmp)
|
||||
{
|
||||
if (lmp->screen) fflush(lmp->screen);
|
||||
if (lmp->logfile) fflush(lmp->logfile);
|
||||
if (lmp->universe->uscreen) fflush(lmp->universe->uscreen);
|
||||
if (lmp->universe->ulogfile) fflush(lmp->universe->ulogfile);
|
||||
}
|
||||
|
||||
/* define this here, so we won't have to include the headers
|
||||
everywhere and utils.h will more likely be included anyway. */
|
||||
|
||||
|
||||
@ -74,6 +74,14 @@ namespace utils {
|
||||
|
||||
void logmesg(LAMMPS *lmp, const std::string &mesg);
|
||||
|
||||
/*! Flush output buffers
|
||||
*
|
||||
* This function calls fflush on screen and logfile FILE pointers
|
||||
* if available
|
||||
*/
|
||||
|
||||
void flush_buffers(LAMMPS *lmp);
|
||||
|
||||
/*! Return a string representing the current system error status
|
||||
*
|
||||
* This is a wrapper around calling strerror(errno).
|
||||
|
||||
Reference in New Issue
Block a user