make more use of std::string and fmtlib where beneficial

This commit is contained in:
Axel Kohlmeyer
2020-06-25 21:13:14 -04:00
parent 8caa3e188c
commit 3c78ad0a70
7 changed files with 46 additions and 68 deletions

View File

@ -15,6 +15,7 @@
#include <mpi.h>
#include <cmath>
#include <cstring>
#include <string>
#include "update.h"
#include "force.h"
#include "input.h"
@ -25,6 +26,7 @@
#include "comm.h"
#include "timer.h"
#include "error.h"
#include "fmt/format.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -224,15 +226,13 @@ void FixHalt::end_of_step()
// soft/continue halt -> trigger timer to break from run loop
// print message with ID of fix halt in case multiple instances
char str[128];
sprintf(str,"Fix halt condition for fix-id %s met on step "
BIGINT_FORMAT " with value %g",
id, update->ntimestep, attvalue);
std::string message = fmt::format("Fix halt condition for fix-id {} met on "
"step {} with value {}",
id, update->ntimestep, attvalue);
if (eflag == HARD) {
error->all(FLERR,str);
error->all(FLERR,message);
} else if (eflag == SOFT || eflag == CONTINUE) {
if (comm->me == 0 && msgflag == YESMSG) error->message(FLERR,str);
if (comm->me == 0 && msgflag == YESMSG) error->message(FLERR,message);
timer->force_timeout();
}
}