Unverified Commit 88a574ff authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #2201 from akohlmey/more-fmtlib-use

Make more use of fmtlib and utils::logmesg()
parents 5263e457 5c08ce08
Loading
Loading
Loading
Loading
+10 −17
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -207,24 +208,16 @@ void DihedralClass2::compute(int eflag, int vflag)
    // error check

    if (c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) {
      int me;
      MPI_Comm_rank(world,&me);
      int me = comm->me;
      if (screen) {
        char str[128];
        sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " "
                TAGINT_FORMAT " " TAGINT_FORMAT " "
                TAGINT_FORMAT " " TAGINT_FORMAT,
        error->warning(FLERR,fmt::format("Dihedral problem: {} {} {} {} {} {}",
                                         me,update->ntimestep,
                atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]);
        error->warning(FLERR,str,0);
        fprintf(screen,"  1st atom: %d %g %g %g\n",
                me,x[i1][0],x[i1][1],x[i1][2]);
        fprintf(screen,"  2nd atom: %d %g %g %g\n",
                me,x[i2][0],x[i2][1],x[i2][2]);
        fprintf(screen,"  3rd atom: %d %g %g %g\n",
                me,x[i3][0],x[i3][1],x[i3][2]);
        fprintf(screen,"  4th atom: %d %g %g %g\n",
                me,x[i4][0],x[i4][1],x[i4][2]);
                                         atom->tag[i1],atom->tag[i2],
                                         atom->tag[i3],atom->tag[i4]));
        fmt::print(screen,"  1st atom: {} {} {} {}\n",me,x[i1][0],x[i1][1],x[i1][2]);
        fmt::print(screen,"  2nd atom: {} {} {} {}\n",me,x[i2][0],x[i2][1],x[i2][2]);
        fmt::print(screen,"  3rd atom: {} {} {} {}\n",me,x[i3][0],x[i3][1],x[i3][2]);
        fmt::print(screen,"  4th atom: {} {} {} {}\n",me,x[i4][0],x[i4][1],x[i4][2]);
      }
    }

+10 −17
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -153,24 +154,16 @@ void ImproperClass2::compute(int eflag, int vflag)

    for (i = 0; i < 3; i++) {
      if (costheta[i] == -1.0) {
        int me;
        MPI_Comm_rank(world,&me);
        int me = comm->me;
        if (screen) {
          char str[128];
          sprintf(str,"Improper problem: %d " BIGINT_FORMAT " "
                  TAGINT_FORMAT " " TAGINT_FORMAT " "
                  TAGINT_FORMAT " " TAGINT_FORMAT,
          error->warning(FLERR,fmt::format("Improper problem: {} {} {} {} {} {}",
                                           me,update->ntimestep,
                  atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]);
          error->warning(FLERR,str,0);
          fprintf(screen,"  1st atom: %d %g %g %g\n",
                  me,x[i1][0],x[i1][1],x[i1][2]);
          fprintf(screen,"  2nd atom: %d %g %g %g\n",
                  me,x[i2][0],x[i2][1],x[i2][2]);
          fprintf(screen,"  3rd atom: %d %g %g %g\n",
                  me,x[i3][0],x[i3][1],x[i3][2]);
          fprintf(screen,"  4th atom: %d %g %g %g\n",
                  me,x[i4][0],x[i4][1],x[i4][2]);
                                           atom->tag[i1],atom->tag[i2],
                                           atom->tag[i3],atom->tag[i4]));
          fmt::print(screen,"  1st atom: {} {} {} {}\n",me,x[i1][0],x[i1][1],x[i1][2]);
          fmt::print(screen,"  2nd atom: {} {} {} {}\n",me,x[i2][0],x[i2][1],x[i2][2]);
          fmt::print(screen,"  3rd atom: {} {} {} {}\n",me,x[i3][0],x[i3][1],x[i3][2]);
          fmt::print(screen,"  4th atom: {} {} {} {}\n",me,x[i4][0],x[i4][1],x[i4][2]);
        }
      }
    }
+14 −26
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "ewald.h"
#include <mpi.h>
#include <cmath>
#include <string>
#include "atom.h"
#include "comm.h"
#include "force.h"
@@ -29,6 +30,8 @@
#include "math_const.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -88,10 +91,7 @@ Ewald::~Ewald()

void Ewald::init()
{
  if (comm->me == 0) {
    if (screen) fprintf(screen,"Ewald initialization ...\n");
    if (logfile) fprintf(logfile,"Ewald initialization ...\n");
  }
  if (comm->me == 0) utils::logmesg(lmp,"Ewald initialization ...\n");

  // error check

@@ -185,28 +185,16 @@ void Ewald::init()
  // stats

  if (comm->me == 0) {
    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  estimated absolute RMS force accuracy = %g\n",
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
              kcount,kmax,kmax3d);
      fprintf(screen,"                  kxmax kymax kzmax  = %d %d %d\n",
              kxmax,kymax,kzmax);
    }
    if (logfile) {
      fprintf(logfile,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(logfile,"  estimated absolute RMS force accuracy = %g\n",
    std::string mesg = fmt::format("  G vector (1/distance) = {}\n",g_ewald);
    mesg += fmt::format("  estimated absolute RMS force accuracy = {}\n",
                       estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
    mesg += fmt::format("  estimated relative force accuracy = {}\n",
                       estimated_accuracy/two_charge_force);
      fprintf(logfile,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
    mesg += fmt::format("  KSpace vectors: actual max1d max3d = {} {} {}\n",
                        kcount,kmax,kmax3d);
      fprintf(logfile,"                  kxmax kymax kzmax  = %d %d %d\n",
    mesg += fmt::format("                  kxmax kymax kzmax  = {} {} {}\n",
                        kxmax,kymax,kzmax);
    }
    utils::logmesg(lmp,mesg);
  }
}

+14 −26
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "ewald_dipole.h"
#include <mpi.h>
#include <cstring>
#include <string>
#include <cmath>
#include "atom.h"
#include "comm.h"
@@ -29,6 +30,8 @@
#include "memory.h"
#include "error.h"
#include "update.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -63,10 +66,7 @@ EwaldDipole::~EwaldDipole()

void EwaldDipole::init()
{
  if (comm->me == 0) {
    if (screen) fprintf(screen,"EwaldDipole initialization ...\n");
    if (logfile) fprintf(logfile,"EwaldDipole initialization ...\n");
  }
  if (comm->me == 0) utils::logmesg(lmp,"EwaldDipole initialization ...\n");

  // error check

@@ -192,28 +192,16 @@ void EwaldDipole::init()
  // stats

  if (comm->me == 0) {
    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  estimated absolute RMS force accuracy = %g\n",
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
              kcount,kmax,kmax3d);
      fprintf(screen,"                  kxmax kymax kzmax  = %d %d %d\n",
              kxmax,kymax,kzmax);
    }
    if (logfile) {
      fprintf(logfile,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(logfile,"  estimated absolute RMS force accuracy = %g\n",
    std::string mesg = fmt::format("  G vector (1/distance) = {}\n",g_ewald);
    mesg += fmt::format("  estimated absolute RMS force accuracy = {}\n",
                       estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
    mesg += fmt::format("  estimated relative force accuracy = {}\n",
                       estimated_accuracy/two_charge_force);
      fprintf(logfile,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
    mesg += fmt::format("  KSpace vectors: actual max1d max3d = {} {} {}\n",
                        kcount,kmax,kmax3d);
      fprintf(logfile,"                  kxmax kymax kzmax  = %d %d %d\n",
    mesg += fmt::format("                  kxmax kymax kzmax  = {} {} {}\n",
                        kxmax,kymax,kzmax);
    }
    utils::logmesg(lmp,mesg);
  }
}

+14 −26
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "ewald_dipole_spin.h"
#include <mpi.h>
#include <cstring>
#include <string>
#include <cmath>
#include "atom.h"
#include "comm.h"
@@ -28,6 +29,8 @@
#include "memory.h"
#include "error.h"
#include "update.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -61,10 +64,7 @@ EwaldDipoleSpin::~EwaldDipoleSpin() {}

void EwaldDipoleSpin::init()
{
  if (comm->me == 0) {
    if (screen) fprintf(screen,"EwaldDipoleSpin initialization ...\n");
    if (logfile) fprintf(logfile,"EwaldDipoleSpin initialization ...\n");
  }
  if (comm->me == 0) utils::logmesg(lmp,"EwaldDipoleSpin initialization ...\n");

  // error check

@@ -182,28 +182,16 @@ void EwaldDipoleSpin::init()
  // stats

  if (comm->me == 0) {
    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  estimated absolute RMS force accuracy = %g\n",
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
              kcount,kmax,kmax3d);
      fprintf(screen,"                  kxmax kymax kzmax  = %d %d %d\n",
              kxmax,kymax,kzmax);
    }
    if (logfile) {
      fprintf(logfile,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(logfile,"  estimated absolute RMS force accuracy = %g\n",
    std::string mesg = fmt::format("  G vector (1/distance) = {}\n",g_ewald);
    mesg += fmt::format("  estimated absolute RMS force accuracy = {}\n",
                       estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
    mesg += fmt::format("  estimated relative force accuracy = {}\n",
                       estimated_accuracy/two_charge_force);
      fprintf(logfile,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
    mesg += fmt::format("  KSpace vectors: actual max1d max3d = {} {} {}\n",
                        kcount,kmax,kmax3d);
      fprintf(logfile,"                  kxmax kymax kzmax  = %d %d %d\n",
    mesg += fmt::format("                  kxmax kymax kzmax  = {} {} {}\n",
                        kxmax,kymax,kzmax);
    }
    utils::logmesg(lmp,mesg);
  }
}

Loading