From 48b7b7d722988276ed23a987dd4ddc7937388e03 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 4 Jun 2020 21:40:13 -0400 Subject: [PATCH] fix up change_box and displace_atoms lost atoms error message --- src/change_box.cpp | 12 ++++++------ src/displace_atoms.cpp | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/change_box.cpp b/src/change_box.cpp index 7ae49ca776..f50ba23db4 100644 --- a/src/change_box.cpp +++ b/src/change_box.cpp @@ -26,6 +26,8 @@ #include "group.h" #include "error.h" #include "force.h" +#include "utils.h" +#include "fmt/format.h" using namespace LAMMPS_NS; @@ -388,12 +390,10 @@ void ChangeBox::command(int narg, char **arg) bigint natoms; bigint nblocal = atom->nlocal; MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); - if (natoms != atom->natoms && comm->me == 0) { - char str[128]; - sprintf(str,"Lost atoms via change_box: original " BIGINT_FORMAT - " current " BIGINT_FORMAT,atom->natoms,natoms); - error->warning(FLERR,str); - } + if (natoms != atom->natoms && comm->me == 0) + error->warning(FLERR,fmt::format("Lost atoms via change_box: " + "original {} current {}", + atom->natoms,natoms)); } /* ---------------------------------------------------------------------- diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp index dc94c3ed35..2ac70f6b6e 100644 --- a/src/displace_atoms.cpp +++ b/src/displace_atoms.cpp @@ -34,6 +34,7 @@ #include "math_extra.h" #include "memory.h" #include "error.h" +#include "fmt/format.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -353,12 +354,10 @@ void DisplaceAtoms::command(int narg, char **arg) bigint natoms; bigint nblocal = atom->nlocal; MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); - if (natoms != atom->natoms && comm->me == 0) { - char str[128]; - sprintf(str,"Lost atoms via displace_atoms: original " BIGINT_FORMAT - " current " BIGINT_FORMAT,atom->natoms,natoms); - error->warning(FLERR,str); - } + if (natoms != atom->natoms && comm->me == 0) + error->warning(FLERR,fmt::format("Lost atoms via displace_atoms: " + "original {} current {}", + atom->natoms,natoms); } /* ----------------------------------------------------------------------