(re-)add example uses of {fmt}
This commit is contained in:
@ -38,6 +38,10 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
|
|
||||||
@ -581,20 +585,11 @@ void CreateAtoms::command(int narg, char **arg)
|
|||||||
// print status
|
// print status
|
||||||
|
|
||||||
MPI_Barrier(world);
|
MPI_Barrier(world);
|
||||||
double time2 = MPI_Wtime();
|
if (me == 0)
|
||||||
|
utils::logmesg(lmp, fmt::format("Created {} atoms\n"
|
||||||
if (me == 0) {
|
" create_atoms CPU = {:<.3g} seconds\n",
|
||||||
if (screen) {
|
atom->natoms - natoms_previous,
|
||||||
fprintf(screen,"Created " BIGINT_FORMAT " atoms\n",
|
MPI_Wtime() - time1));
|
||||||
atom->natoms-natoms_previous);
|
|
||||||
fprintf(screen," create_atoms CPU = %g secs\n",time2-time1);
|
|
||||||
}
|
|
||||||
if (logfile) {
|
|
||||||
fprintf(logfile,"Created " BIGINT_FORMAT " atoms\n",
|
|
||||||
atom->natoms-natoms_previous);
|
|
||||||
fprintf(logfile," create_atoms CPU = %g secs\n",time2-time1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <string>
|
||||||
#include "style_bond.h"
|
#include "style_bond.h"
|
||||||
#include "style_angle.h"
|
#include "style_angle.h"
|
||||||
#include "style_dihedral.h"
|
#include "style_dihedral.h"
|
||||||
@ -34,6 +35,7 @@
|
|||||||
#include "kspace.h"
|
#include "kspace.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -945,10 +947,9 @@ double Force::numeric(const char *file, int line, char *str)
|
|||||||
if (isdigit(str[i])) continue;
|
if (isdigit(str[i])) continue;
|
||||||
if (str[i] == '-' || str[i] == '+' || str[i] == '.') continue;
|
if (str[i] == '-' || str[i] == '+' || str[i] == '.') continue;
|
||||||
if (str[i] == 'e' || str[i] == 'E') continue;
|
if (str[i] == 'e' || str[i] == 'E') continue;
|
||||||
char msg[256];
|
std::string msg = fmt::format("Expected floating point parameter "
|
||||||
snprintf(msg,256,"Expected floating point parameter instead of "
|
"instead of '{}' in input script or data file",str);
|
||||||
"'%s' in input script or data file",str);
|
error->all(file,line,msg.c_str());
|
||||||
error->all(file,line,msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return atof(str);
|
return atof(str);
|
||||||
@ -971,10 +972,9 @@ int Force::inumeric(const char *file, int line, char *str)
|
|||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
||||||
char msg[256];
|
std::string msg = fmt::format("Expected integer parameter instead "
|
||||||
snprintf(msg,256,"Expected integer parameter instead of "
|
"of '{}' in input script or data file",str);
|
||||||
"'%s' in input script or data file",str);
|
error->all(file,line,msg.c_str());
|
||||||
error->all(file,line,msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return atoi(str);
|
return atoi(str);
|
||||||
@ -997,10 +997,9 @@ bigint Force::bnumeric(const char *file, int line, char *str)
|
|||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
||||||
char msg[256];
|
std::string msg = fmt::format("Expected integer parameter instead "
|
||||||
snprintf(msg,256,"Expected integer parameter instead of "
|
"of '{}' in input script or data file",str);
|
||||||
"'%s' in input script or data file",str);
|
error->all(file,line,msg.c_str());
|
||||||
error->all(file,line,msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ATOBIGINT(str);
|
return ATOBIGINT(str);
|
||||||
@ -1023,10 +1022,9 @@ tagint Force::tnumeric(const char *file, int line, char *str)
|
|||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
||||||
char msg[256];
|
std::string msg = fmt::format("Expected integer parameter instead "
|
||||||
snprintf(msg,256,"Expected integer parameter instead of "
|
"of '{}' in input script or data file",str);
|
||||||
"'%s' in input script or data file",str);
|
error->all(file,line,msg.c_str());
|
||||||
error->all(file,line,msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ATOTAGINT(str);
|
return ATOTAGINT(str);
|
||||||
@ -1129,10 +1127,8 @@ void Force::potential_date(FILE *fp, const char *name)
|
|||||||
if (strcmp(word,"DATE:") == 0) {
|
if (strcmp(word,"DATE:") == 0) {
|
||||||
word = strtok(NULL," \t\n\r\f");
|
word = strtok(NULL," \t\n\r\f");
|
||||||
if (word == NULL) return;
|
if (word == NULL) return;
|
||||||
if (screen)
|
utils::logmesg(lmp,fmt::format("Reading potential "
|
||||||
fprintf(screen,"Reading potential file %s with DATE: %s\n",name,word);
|
"file {} with DATE: {}",name,word));
|
||||||
if (logfile)
|
|
||||||
fprintf(logfile,"Reading potential file %s with DATE: %s\n",name,word);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
word = strtok(NULL," \t\n\r\f");
|
word = strtok(NULL," \t\n\r\f");
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#include "lmprestart.h"
|
#include "lmprestart.h"
|
||||||
|
|
||||||
@ -498,36 +499,24 @@ void ReadRestart::command(int narg, char **arg)
|
|||||||
bigint nblocal = atom->nlocal;
|
bigint nblocal = atom->nlocal;
|
||||||
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " atoms\n",natoms);
|
utils::logmesg(lmp,fmt::format(" {} atoms\n",natoms));
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",natoms);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (natoms != atom->natoms)
|
if (natoms != atom->natoms)
|
||||||
error->all(FLERR,"Did not assign all restart atoms correctly");
|
error->all(FLERR,"Did not assign all restart atoms correctly");
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (atom->nbonds) {
|
if (atom->nbonds) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " bonds\n",atom->nbonds);
|
utils::logmesg(lmp,fmt::format(" {} bonds\n",atom->nbonds));
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " bonds\n",atom->nbonds);
|
|
||||||
}
|
}
|
||||||
if (atom->nangles) {
|
if (atom->nangles) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " angles\n",
|
utils::logmesg(lmp,fmt::format(" {} angles\n",atom->nangles));
|
||||||
atom->nangles);
|
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " angles\n",
|
|
||||||
atom->nangles);
|
|
||||||
}
|
}
|
||||||
if (atom->ndihedrals) {
|
if (atom->ndihedrals) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " dihedrals\n",
|
utils::logmesg(lmp,fmt::format(" {} dihedrals\n",atom->ndihedrals));
|
||||||
atom->ndihedrals);
|
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " dihedrals\n",
|
|
||||||
atom->ndihedrals);
|
|
||||||
}
|
}
|
||||||
if (atom->nimpropers) {
|
if (atom->nimpropers) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " impropers\n",
|
utils::logmesg(lmp,fmt::format(" {} impropers\n",atom->nimpropers));
|
||||||
atom->nimpropers);
|
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " impropers\n",
|
|
||||||
atom->nimpropers);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
#include "accelerator_kokkos.h"
|
#include "accelerator_kokkos.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -733,8 +735,7 @@ void Replicate::command(int narg, char **arg)
|
|||||||
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " atoms\n",natoms);
|
utils::logmesg(lmp,fmt::format(" {} atoms\n",natoms));
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",natoms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (natoms != atom->natoms)
|
if (natoms != atom->natoms)
|
||||||
@ -742,26 +743,16 @@ void Replicate::command(int narg, char **arg)
|
|||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (atom->nbonds) {
|
if (atom->nbonds) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " bonds\n",atom->nbonds);
|
utils::logmesg(lmp,fmt::format(" {} bonds\n",atom->nbonds));
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " bonds\n",atom->nbonds);
|
|
||||||
}
|
}
|
||||||
if (atom->nangles) {
|
if (atom->nangles) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " angles\n",
|
utils::logmesg(lmp,fmt::format(" {} angles\n",atom->nangles));
|
||||||
atom->nangles);
|
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " angles\n",
|
|
||||||
atom->nangles);
|
|
||||||
}
|
}
|
||||||
if (atom->ndihedrals) {
|
if (atom->ndihedrals) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " dihedrals\n",
|
utils::logmesg(lmp,fmt::format(" {} dihedrals\n",atom->ndihedrals));
|
||||||
atom->ndihedrals);
|
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " dihedrals\n",
|
|
||||||
atom->ndihedrals);
|
|
||||||
}
|
}
|
||||||
if (atom->nimpropers) {
|
if (atom->nimpropers) {
|
||||||
if (screen) fprintf(screen," " BIGINT_FORMAT " impropers\n",
|
utils::logmesg(lmp,fmt::format(" {} impropers\n",atom->nimpropers));
|
||||||
atom->nimpropers);
|
|
||||||
if (logfile) fprintf(logfile," " BIGINT_FORMAT " impropers\n",
|
|
||||||
atom->nimpropers);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include "special.h"
|
#include "special.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -40,10 +41,7 @@ void ResetIDs::command(int narg, char ** /* arg */)
|
|||||||
// NOTE: check if any fixes exist which store atom IDs?
|
// NOTE: check if any fixes exist which store atom IDs?
|
||||||
// if so, this operation will mess up the fix
|
// if so, this operation will mess up the fix
|
||||||
|
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) utils::logmesg(lmp,"Resetting atom IDs ...\n");
|
||||||
if (screen) fprintf(screen,"Resetting atom IDs ...\n");
|
|
||||||
if (logfile) fprintf(logfile,"Resetting atom IDs ...\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// create an atom map if one doesn't exist already
|
// create an atom map if one doesn't exist already
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "respa.h"
|
#include "respa.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "atom_vec.h"
|
#include "atom_vec.h"
|
||||||
@ -38,6 +39,7 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "pair_hybrid.h"
|
#include "pair_hybrid.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -192,44 +194,23 @@ Respa::Respa(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// print respa levels
|
// print respa levels
|
||||||
|
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
if (screen) {
|
std::string mesg = "Respa levels:\n";
|
||||||
fprintf(screen,"Respa levels:\n");
|
|
||||||
for (int i = 0; i < nlevels; i++) {
|
for (int i = 0; i < nlevels; i++) {
|
||||||
fprintf(screen," %d =",i+1);
|
mesg += fmt::format(" {} =",i+1);
|
||||||
if (level_bond == i) fprintf(screen," bond");
|
if (level_bond == i) mesg += " bond";
|
||||||
if (level_angle == i) fprintf(screen," angle");
|
if (level_angle == i) mesg += " angle";
|
||||||
if (level_dihedral == i) fprintf(screen," dihedral");
|
if (level_dihedral == i) mesg += " dihedral";
|
||||||
if (level_improper == i) fprintf(screen," improper");
|
if (level_improper == i) mesg += " improper";
|
||||||
if (level_pair == i) fprintf(screen," pair");
|
if (level_pair == i) mesg += " pair";
|
||||||
if (level_inner == i) fprintf(screen," pair-inner");
|
if (level_inner == i) mesg += " pair-inner";
|
||||||
if (level_middle == i) fprintf(screen," pair-middle");
|
if (level_middle == i) mesg += " pair-middle";
|
||||||
if (level_outer == i) fprintf(screen," pair-outer");
|
if (level_outer == i) mesg += " pair-outer";
|
||||||
for (int j=0;j<nhybrid_styles;j++) {
|
for (int j=0; j < nhybrid_styles; j++)
|
||||||
if (hybrid_level[j] == i) fprintf(screen, " hybrid-%d",j+1);
|
if (hybrid_level[j] == i) mesg += fmt::format(" hybrid-{}",j+1);
|
||||||
}
|
if (level_kspace == i) mesg += " kspace";
|
||||||
if (level_kspace == i) fprintf(screen," kspace");
|
mesg += "\n";
|
||||||
fprintf(screen,"\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (logfile) {
|
|
||||||
fprintf(logfile,"Respa levels:\n");
|
|
||||||
for (int i = 0; i < nlevels; i++) {
|
|
||||||
fprintf(logfile," %d =",i+1);
|
|
||||||
if (level_bond == i) fprintf(logfile," bond");
|
|
||||||
if (level_angle == i) fprintf(logfile," angle");
|
|
||||||
if (level_dihedral == i) fprintf(logfile," dihedral");
|
|
||||||
if (level_improper == i) fprintf(logfile," improper");
|
|
||||||
if (level_pair == i) fprintf(logfile," pair");
|
|
||||||
if (level_inner == i) fprintf(logfile," pair-inner");
|
|
||||||
if (level_middle == i) fprintf(logfile," pair-middle");
|
|
||||||
if (level_outer == i) fprintf(logfile," pair-outer");
|
|
||||||
for (int j=0;j<nhybrid_styles;j++) {
|
|
||||||
if (hybrid_level[j] == i) fprintf(logfile, " hybrid-%d",j+1);
|
|
||||||
}
|
|
||||||
if (level_kspace == i) fprintf(logfile," kspace");
|
|
||||||
fprintf(logfile,"\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
utils::logmesg(lmp,mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that levels are in correct order
|
// check that levels are in correct order
|
||||||
@ -400,22 +381,25 @@ void Respa::init()
|
|||||||
void Respa::setup(int flag)
|
void Respa::setup(int flag)
|
||||||
{
|
{
|
||||||
if (comm->me == 0 && screen) {
|
if (comm->me == 0 && screen) {
|
||||||
fprintf(screen,"Setting up r-RESPA run ...\n");
|
std::string mesg = "Setting up r-RESPA run ...\n";
|
||||||
if (flag) {
|
if (flag) {
|
||||||
fprintf(screen," Unit style : %s\n", update->unit_style);
|
mesg += fmt::format(" Unit style : {}\n",update->unit_style);
|
||||||
fprintf(screen," Current step : " BIGINT_FORMAT "\n",
|
mesg += fmt::format(" Current step : {}\n", update->ntimestep);
|
||||||
update->ntimestep);
|
|
||||||
fprintf(screen," Time steps :");
|
mesg += " Time steps :";
|
||||||
for (int ilevel=0; ilevel < nlevels; ++ilevel)
|
for (int ilevel=0; ilevel < nlevels; ++ilevel)
|
||||||
fprintf(screen," %d:%g",ilevel+1, step[ilevel]);
|
mesg += fmt::format(" {}:{}",ilevel+1, step[ilevel]);
|
||||||
fprintf(screen,"\n r-RESPA fixes :");
|
|
||||||
|
mesg += "\n r-RESPA fixes :";
|
||||||
for (int l=0; l < modify->n_post_force_respa; ++l) {
|
for (int l=0; l < modify->n_post_force_respa; ++l) {
|
||||||
Fix *f = modify->fix[modify->list_post_force_respa[l]];
|
Fix *f = modify->fix[modify->list_post_force_respa[l]];
|
||||||
if (f->respa_level >= 0)
|
if (f->respa_level >= 0)
|
||||||
fprintf(screen," %d:%s[%s]",
|
mesg += fmt::format(" {}:{}[{}]",
|
||||||
MIN(f->respa_level+1,nlevels),f->style,f->id);
|
MIN(f->respa_level+1,nlevels),
|
||||||
|
f->style,f->id);
|
||||||
}
|
}
|
||||||
fprintf(screen,"\n");
|
mesg += "\n";
|
||||||
|
fputs(mesg.c_str(),screen);
|
||||||
timer->print_timeout(screen);
|
timer->print_timeout(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/set.cpp
21
src/set.cpp
@ -36,6 +36,8 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
@ -601,23 +603,12 @@ void Set::command(int narg, char **arg)
|
|||||||
MPI_Allreduce(&count,&allcount,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&count,&allcount,1,MPI_INT,MPI_SUM,world);
|
||||||
|
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
|
|
||||||
if (screen) {
|
|
||||||
if (strcmp(arg[origarg],"cc") == 0)
|
if (strcmp(arg[origarg],"cc") == 0)
|
||||||
fprintf(screen," %d settings made for %s index %s\n",
|
utils::logmesg(lmp,fmt::format(" {} settings made for {} index {}",
|
||||||
allcount,arg[origarg],arg[origarg+1]);
|
allcount,arg[origarg],arg[origarg+1]));
|
||||||
else
|
else
|
||||||
fprintf(screen," %d settings made for %s\n",
|
utils::logmesg(lmp,fmt::format(" {} settings made for {}",
|
||||||
allcount,arg[origarg]);
|
allcount,arg[origarg]));
|
||||||
}
|
|
||||||
if (logfile) {
|
|
||||||
if (strcmp(arg[origarg],"cc") == 0)
|
|
||||||
fprintf(logfile," %d settings made for %s index %s\n",
|
|
||||||
allcount,arg[origarg],arg[origarg+1]);
|
|
||||||
else
|
|
||||||
fprintf(logfile," %d settings made for %s\n",
|
|
||||||
allcount,arg[origarg]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,8 @@
|
|||||||
#include "accelerator_kokkos.h" // IWYU pragma: export
|
#include "accelerator_kokkos.h" // IWYU pragma: export
|
||||||
#include "atom_masks.h"
|
#include "atom_masks.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -60,9 +62,9 @@ void Special::build()
|
|||||||
if (me == 0 && screen) {
|
if (me == 0 && screen) {
|
||||||
const double * const special_lj = force->special_lj;
|
const double * const special_lj = force->special_lj;
|
||||||
const double * const special_coul = force->special_coul;
|
const double * const special_coul = force->special_coul;
|
||||||
fprintf(screen,"Finding 1-2 1-3 1-4 neighbors ...\n"
|
fmt::print(screen,"Finding 1-2 1-3 1-4 neighbors ...\n"
|
||||||
" special bond factors lj: %-10g %-10g %-10g\n"
|
" special bond factors lj: {:<10g} {:<10g} {:<10g}\n"
|
||||||
" special bond factors coul: %-10g %-10g %-10g\n",
|
" special bond factors coul: {:<10g} {:<10g} {:<10g}\n",
|
||||||
special_lj[1],special_lj[2],special_lj[3],
|
special_lj[1],special_lj[2],special_lj[3],
|
||||||
special_coul[1],special_coul[2],special_coul[3]);
|
special_coul[1],special_coul[2],special_coul[3]);
|
||||||
}
|
}
|
||||||
@ -90,10 +92,8 @@ void Special::build()
|
|||||||
|
|
||||||
// print max # of 1-2 neighbors
|
// print max # of 1-2 neighbors
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen) fprintf(screen," %d = max # of 1-2 neighbors\n",maxall);
|
utils::logmesg(lmp,fmt::format(" {} = max # of 1-2 neighbors\n",maxall));
|
||||||
if (logfile) fprintf(logfile," %d = max # of 1-2 neighbors\n",maxall);
|
|
||||||
}
|
|
||||||
|
|
||||||
// done if special_bond weights for 1-3, 1-4 are set to 1.0
|
// done if special_bond weights for 1-3, 1-4 are set to 1.0
|
||||||
|
|
||||||
@ -115,10 +115,8 @@ void Special::build()
|
|||||||
|
|
||||||
// print max # of 1-3 neighbors
|
// print max # of 1-3 neighbors
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen) fprintf(screen," %d = max # of 1-3 neighbors\n",maxall);
|
utils::logmesg(lmp,fmt::format(" {} = max # of 1-3 neighbors\n",maxall));
|
||||||
if (logfile) fprintf(logfile," %d = max # of 1-3 neighbors\n",maxall);
|
|
||||||
}
|
|
||||||
|
|
||||||
// done if special_bond weights for 1-4 are set to 1.0
|
// done if special_bond weights for 1-4 are set to 1.0
|
||||||
|
|
||||||
@ -140,10 +138,8 @@ void Special::build()
|
|||||||
|
|
||||||
// print max # of 1-4 neighbors
|
// print max # of 1-4 neighbors
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen) fprintf(screen," %d = max # of 1-4 neighbors\n",maxall);
|
utils::logmesg(lmp,fmt::format(" {} = max # of 1-4 neighbors\n",maxall));
|
||||||
if (logfile) fprintf(logfile," %d = max # of 1-4 neighbors\n",maxall);
|
|
||||||
}
|
|
||||||
|
|
||||||
// finish processing the onetwo, onethree, onefour lists
|
// finish processing the onetwo, onethree, onefour lists
|
||||||
|
|
||||||
@ -694,12 +690,9 @@ void Special::combine()
|
|||||||
|
|
||||||
force->special_extra = 0;
|
force->special_extra = 0;
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen)
|
utils::logmesg(lmp,fmt::format(" {} = max # of special "
|
||||||
fprintf(screen," %d = max # of special neighbors\n",atom->maxspecial);
|
"neighbors\n",atom->maxspecial));
|
||||||
if (logfile)
|
|
||||||
fprintf(logfile," %d = max # of special neighbors\n",atom->maxspecial);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lmp->kokkos) {
|
if (lmp->kokkos) {
|
||||||
AtomKokkos* atomKK = (AtomKokkos*) atom;
|
AtomKokkos* atomKK = (AtomKokkos*) atom;
|
||||||
@ -800,14 +793,9 @@ void Special::angle_trim()
|
|||||||
double allcount;
|
double allcount;
|
||||||
MPI_Allreduce(&onethreecount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
MPI_Allreduce(&onethreecount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen)
|
utils::logmesg(lmp,fmt::format(" {} = # of 1-3 neighbors "
|
||||||
fprintf(screen,
|
"before angle trim\n",allcount));
|
||||||
" %g = # of 1-3 neighbors before angle trim\n",allcount);
|
|
||||||
if (logfile)
|
|
||||||
fprintf(logfile,
|
|
||||||
" %g = # of 1-3 neighbors before angle trim\n",allcount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if angles or dihedrals are defined
|
// if angles or dihedrals are defined
|
||||||
// rendezvous angle 1-3 and dihedral 1-3,2-4 pairs
|
// rendezvous angle 1-3 and dihedral 1-3,2-4 pairs
|
||||||
@ -1035,14 +1023,9 @@ void Special::angle_trim()
|
|||||||
for (i = 0; i < nlocal; i++) onethreecount += nspecial[i][1];
|
for (i = 0; i < nlocal; i++) onethreecount += nspecial[i][1];
|
||||||
MPI_Allreduce(&onethreecount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
MPI_Allreduce(&onethreecount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen)
|
utils::logmesg(lmp,fmt::format(" {} = # of 1-3 neighbors "
|
||||||
fprintf(screen,
|
"after angle trim\n",allcount));
|
||||||
" %g = # of 1-3 neighbors after angle trim\n",allcount);
|
|
||||||
if (logfile)
|
|
||||||
fprintf(logfile,
|
|
||||||
" %g = # of 1-3 neighbors after angle trim\n",allcount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -1070,14 +1053,9 @@ void Special::dihedral_trim()
|
|||||||
double allcount;
|
double allcount;
|
||||||
MPI_Allreduce(&onefourcount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
MPI_Allreduce(&onefourcount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen)
|
utils::logmesg(lmp,fmt::format(" {} = # of 1-4 neighbors "
|
||||||
fprintf(screen,
|
"before dihedral trim\n",allcount));
|
||||||
" %g = # of 1-4 neighbors before dihedral trim\n",allcount);
|
|
||||||
if (logfile)
|
|
||||||
fprintf(logfile,
|
|
||||||
" %g = # of 1-4 neighbors before dihedral trim\n",allcount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if dihedrals are defined, rendezvous the dihedral 1-4 pairs
|
// if dihedrals are defined, rendezvous the dihedral 1-4 pairs
|
||||||
|
|
||||||
@ -1219,14 +1197,9 @@ void Special::dihedral_trim()
|
|||||||
for (i = 0; i < nlocal; i++) onefourcount += nspecial[i][2];
|
for (i = 0; i < nlocal; i++) onefourcount += nspecial[i][2];
|
||||||
MPI_Allreduce(&onefourcount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
MPI_Allreduce(&onefourcount,&allcount,1,MPI_DOUBLE,MPI_SUM,world);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0)
|
||||||
if (screen)
|
utils::logmesg(lmp,fmt::format(" {} = # of 1-4 neighbors "
|
||||||
fprintf(screen,
|
"after dihedral trim\n",allcount));
|
||||||
" %g = # of 1-4 neighbors after dihedral trim\n",allcount);
|
|
||||||
if (logfile)
|
|
||||||
fprintf(logfile,
|
|
||||||
" %g = # of 1-4 neighbors after dihedral trim\n",allcount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -1340,9 +1313,7 @@ void Special::fix_alteration()
|
|||||||
|
|
||||||
void Special::timer_output(double time1)
|
void Special::timer_output(double time1)
|
||||||
{
|
{
|
||||||
double time2 = MPI_Wtime();
|
if (comm->me == 0)
|
||||||
if (comm->me == 0) {
|
utils::logmesg(lmp,fmt::format(" special bonds CPU = {:<.3g} secs\n",
|
||||||
if (screen) fprintf(screen," special bonds CPU = %g secs\n",time2-time1);
|
MPI_Wtime()-time1));
|
||||||
if (logfile) fprintf(logfile," special bonds CPU = %g secs\n",time2-time1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "lammps.h"
|
#include "lammps.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#include <unistd.h> // for readlink
|
#include <unistd.h> // for readlink
|
||||||
@ -84,6 +85,19 @@ bool utils::strmatch(std::string text, std::string pattern)
|
|||||||
return (pos >= 0);
|
return (pos >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This simplifies the repetitive task of outputting some
|
||||||
|
* message to both the screen and/or the log file. In combination
|
||||||
|
* with using fmt::format(), which returns the formatted text
|
||||||
|
* in a std::string() instance, this can be used to reduce
|
||||||
|
* operations previously requiring several lines of code to
|
||||||
|
* a single statement. */
|
||||||
|
|
||||||
|
void utils::logmesg(LAMMPS *lmp, const std::string &mesg)
|
||||||
|
{
|
||||||
|
if (lmp->screen) fputs(mesg.c_str(), lmp->screen);
|
||||||
|
if (lmp->logfile) fputs(mesg.c_str(), lmp->logfile);
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief try to detect pathname from FILE pointer. Currently only supported on Linux, otherwise will report "(unknown)".
|
/** \brief try to detect pathname from FILE pointer. Currently only supported on Linux, otherwise will report "(unknown)".
|
||||||
*
|
*
|
||||||
* \param buf storage buffer for pathname. output will be truncated if not large enough
|
* \param buf storage buffer for pathname. output will be truncated if not large enough
|
||||||
@ -167,14 +181,15 @@ void utils::sfread(const char *srcname, int srcline, void *s, size_t size,
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
std::string utils::check_packages_for_style(std::string style,
|
std::string utils::check_packages_for_style(const std::string &style,
|
||||||
std::string name, LAMMPS *lmp)
|
const std::string &name,
|
||||||
|
LAMMPS *lmp)
|
||||||
{
|
{
|
||||||
std::string errmsg = "Unrecognized " + style + " style '" + name + "'";
|
std::string errmsg = "Unrecognized " + style + " style '" + name + "'";
|
||||||
const char *pkg = lmp->match_style(style.c_str(),name.c_str());
|
const char *pkg = lmp->match_style(style.c_str(),name.c_str());
|
||||||
|
|
||||||
if (pkg) {
|
if (pkg) {
|
||||||
errmsg += " is part of the " + std::string(pkg) + " package";
|
errmsg += fmt::format(" is part of the {} package",pkg);
|
||||||
if (lmp->is_installed_pkg(pkg))
|
if (lmp->is_installed_pkg(pkg))
|
||||||
errmsg += ", but seems to be missing because of a dependency";
|
errmsg += ", but seems to be missing because of a dependency";
|
||||||
else
|
else
|
||||||
|
|||||||
11
src/utils.h
11
src/utils.h
@ -36,6 +36,13 @@ namespace LAMMPS_NS {
|
|||||||
*/
|
*/
|
||||||
bool strmatch(std::string text, std::string pattern);
|
bool strmatch(std::string text, std::string pattern);
|
||||||
|
|
||||||
|
/** \brief Send message to screen and logfile, if available
|
||||||
|
*
|
||||||
|
* \param lmp pointer to LAMMPS class instance
|
||||||
|
* \param mesg message to be printed
|
||||||
|
*/
|
||||||
|
void logmesg(LAMMPS *lmp, const std::string &mesg);
|
||||||
|
|
||||||
/** \brief safe wrapper around fgets() which aborts on errors
|
/** \brief safe wrapper around fgets() which aborts on errors
|
||||||
* or EOF and prints a suitable error message to help debugging
|
* or EOF and prints a suitable error message to help debugging
|
||||||
*
|
*
|
||||||
@ -72,8 +79,8 @@ namespace LAMMPS_NS {
|
|||||||
* \param lmp pointer to top-level LAMMPS class instance
|
* \param lmp pointer to top-level LAMMPS class instance
|
||||||
* \return string usable for error messages
|
* \return string usable for error messages
|
||||||
*/
|
*/
|
||||||
std::string check_packages_for_style(std::string style,
|
std::string check_packages_for_style(const std::string &style,
|
||||||
std::string name, LAMMPS *lmp);
|
const std::string &name, LAMMPS *lmp);
|
||||||
|
|
||||||
/** \brief Convert a string to a floating point number while checking
|
/** \brief Convert a string to a floating point number while checking
|
||||||
if it is a valid floating point or integer number
|
if it is a valid floating point or integer number
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "verlet.h"
|
#include "verlet.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
@ -30,6 +31,7 @@
|
|||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -87,9 +89,10 @@ void Verlet::setup(int flag)
|
|||||||
if (comm->me == 0 && screen) {
|
if (comm->me == 0 && screen) {
|
||||||
fprintf(screen,"Setting up Verlet run ...\n");
|
fprintf(screen,"Setting up Verlet run ...\n");
|
||||||
if (flag) {
|
if (flag) {
|
||||||
fprintf(screen," Unit style : %s\n",update->unit_style);
|
fmt::print(screen," Unit style : {}\n"
|
||||||
fprintf(screen," Current step : " BIGINT_FORMAT "\n",update->ntimestep);
|
" Current step : {}\n"
|
||||||
fprintf(screen," Time step : %g\n",update->dt);
|
" Time step : {}\n",
|
||||||
|
update->unit_style,update->ntimestep,update->dt);
|
||||||
timer->print_timeout(screen);
|
timer->print_timeout(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user