Unverified Commit 3c78ad0a authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

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

parent 8caa3e18
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "memory.h"
#include "error.h"
#include "tokenizer.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;

@@ -215,12 +216,9 @@ void AtomVecHybrid::process_args(int narg, char **arg)
  for (int idup = 0; idup < ndupfield; idup++) {
    char *dup = (char *) dupfield[idup];
    ptr = strstr(concat_grow,dup);
    if (ptr && strstr(ptr+1,dup)) {
      char str[128];
      sprintf(str,"Peratom %s is in multiple sub-styles - "
              "must be used consistently",dup);
      if (comm->me == 0) error->warning(FLERR,str);
    }
    if ((ptr && strstr(ptr+1,dup)) && (comm->me == 0))
      error->warning(FLERR,fmt::format("Peratom {} is in multiple sub-styles "
                                       "- must be used consistently",dup));
  }

  delete [] concat_grow;
+7 −10
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "comm.h"
#include "memory.h"
#include "error.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;

@@ -184,11 +185,9 @@ void ComputeCNAAtom::compute_peratom()

  int nerrorall;
  MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world);
  if (nerrorall && comm->me == 0) {
    char str[128];
    sprintf(str,"Too many neighbors in CNA for %d atoms",nerrorall);
    error->warning(FLERR,str,0);
  }
  if (nerrorall && comm->me == 0)
    error->warning(FLERR,fmt::format("Too many neighbors in CNA for {} "
                                     "atoms",nerrorall),0);

  // compute CNA for each atom in group
  // only performed if # of nearest neighbors = 12 or 14 (fcc,hcp)
@@ -345,11 +344,9 @@ void ComputeCNAAtom::compute_peratom()
  // warning message

  MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world);
  if (nerrorall && comm->me == 0) {
    char str[128];
    sprintf(str,"Too many common neighbors in CNA %d times",nerrorall);
    error->warning(FLERR,str);
  }
  if (nerrorall && comm->me == 0)
    error->warning(FLERR,fmt::format("Too many common neighbors in CNA {} "
                                     "times", nerrorall));
}

/* ----------------------------------------------------------------------
+3 −6
Original line number Diff line number Diff line
@@ -147,12 +147,9 @@ void ComputeGroupGroup::init()

  if (kspaceflag) {
    kspace_correction();
    if (fabs(e_correction) > SMALL && comm->me == 0) {
      char str[128];
      sprintf(str,"Both groups in compute group/group have a net charge; "
    if ((fabs(e_correction) > SMALL) && (comm->me == 0))
      error->warning(FLERR,"Both groups in compute group/group have a net charge; "
                     "the Kspace boundary correction to energy will be non-zero");
      error->warning(FLERR,str);
    }
  }

  // recheck that group 2 has not been deleted
+3 −5
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include "memory.h"
#include "error.h"
#include "math_const.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -715,11 +716,8 @@ void ComputeOrientOrderAtom::init_clebsch_gordan()

double ComputeOrientOrderAtom::factorial(int n)
{
  if (n < 0 || n > nmaxfactorial) {
    char str[128];
    sprintf(str, "Invalid argument to factorial %d", n);
    error->all(FLERR, str);
  }
  if (n < 0 || n > nmaxfactorial)
    error->all(FLERR,fmt::format("Invalid argument to factorial {}", n));

  return nfac_table[n];
}
+4 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "comm.h"
#include "force.h"
#include "error.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;

@@ -58,11 +59,9 @@ void DumpMovie::openfile()
    fp = popen(moviecmd,"w");
#endif

    if (fp == NULL) {
      char str[128];
      sprintf(str,"Failed to open FFmpeg pipeline to file %s",filename);
      error->one(FLERR,str);
    }
    if (fp == NULL)
      error->one(FLERR,fmt::format("Failed to open FFmpeg pipeline to "
                                   "file {}",filename));
  }
}
/* ---------------------------------------------------------------------- */
Loading