diff --git a/src/domain.cpp b/src/domain.cpp index e1a9744fde..9cd375de71 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -39,6 +39,7 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "fmt/format.h" using namespace LAMMPS_NS; @@ -1935,33 +1936,20 @@ void Domain::set_box(int narg, char **arg) print box info, orthogonal or triclinic ------------------------------------------------------------------------- */ -void Domain::print_box(const char *str) +void Domain::print_box(const std::string &prefix) { if (comm->me == 0) { - if (screen) { - if (triclinic == 0) - fprintf(screen,"%sorthogonal box = (%g %g %g) to (%g %g %g)\n", - str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2]); - else { - char *format = (char *) - "%striclinic box = (%g %g %g) to (%g %g %g) with tilt (%g %g %g)\n"; - fprintf(screen,format, - str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2], - xy,xz,yz); - } - } - if (logfile) { - if (triclinic == 0) - fprintf(logfile,"%sorthogonal box = (%g %g %g) to (%g %g %g)\n", - str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2]); - else { - char *format = (char *) - "%striclinic box = (%g %g %g) to (%g %g %g) with tilt (%g %g %g)\n"; - fprintf(logfile,format, - str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2], - xy,xz,yz); - } + std::string mesg = prefix; + if (triclinic == 0) { + mesg += fmt::format("orthogonal box = ({} {} {}) to ({} {} {})\n", + boxlo[0],boxlo[1],boxlo[2], + boxhi[0],boxhi[1],boxhi[2]); + } else { + mesg += fmt::format("triclinic box = ({} {} {}) to ({} {} {}) " + "with tilt ({} {} {})\n",boxlo[0],boxlo[1], + boxlo[2],boxhi[0],boxhi[1],boxhi[2],xy,xz,yz); } + utils::logmesg(lmp,mesg); } } diff --git a/src/domain.h b/src/domain.h index 0ce31a8b4a..58b935ce01 100644 --- a/src/domain.h +++ b/src/domain.h @@ -131,7 +131,7 @@ class Domain : protected Pointers { int find_region(char *); void set_boundary(int, char **, int); void set_box(int, char **); - void print_box(const char *); + void print_box(const std::string &); void boundary_string(char *); virtual void lamda2x(int);