more use of fmtlib and std::string

This commit is contained in:
Axel Kohlmeyer
2020-06-25 21:32:30 -04:00
parent 4816c5c7cc
commit e4a3a518f7
12 changed files with 94 additions and 162 deletions

View File

@ -848,16 +848,12 @@ bool Info::is_active(const char *category, const char *name)
if (!match && lmp->suffix_enable) { if (!match && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
char *name_w_suffix = new char [len + 2 + strlen(lmp->suffix)]; std::string name_w_suffix = name + std::string("/") + lmp->suffix;
sprintf(name_w_suffix,"%s/%s",name,lmp->suffix); if (name_w_suffix == style) match = 1;
if (strcmp(style,name_w_suffix) == 0) match = 1;
delete[] name_w_suffix;
} }
if (!match && lmp->suffix2) { if (!match && lmp->suffix2) {
char *name_w_suffix = new char [len + 2 + strlen(lmp->suffix2)]; std::string name_w_suffix = name + std::string("/") + lmp->suffix2;
sprintf(name_w_suffix,"%s/%s",name,lmp->suffix2); if (name_w_suffix == style) match = 1;
if (strcmp(style,name_w_suffix) == 0) match = 1;
delete[] name_w_suffix;
} }
} }
return match ? true : false; return match ? true : false;

View File

@ -227,11 +227,8 @@ void Input::file()
// execute the command // execute the command
if (execute_command()) { if (execute_command())
char *str = new char[maxline+32]; error->all(FLERR,fmt::format("Unknown command: {}",line));
sprintf(str,"Unknown command: %s",line);
error->all(FLERR,str);
}
} }
} }
@ -1249,7 +1246,7 @@ char *shell_failed_message(const char* cmd, int errnum)
const char *errmsg = strerror(errnum); const char *errmsg = strerror(errnum);
int len = strlen(cmd)+strlen(errmsg)+64; int len = strlen(cmd)+strlen(errmsg)+64;
char *msg = new char[len]; char *msg = new char[len];
sprintf(msg,"Shell command '%s' failed with error '%s'", cmd, errmsg); snprintf(msg, len, "Shell command '%s' failed with error '%s'", cmd, errmsg);
return msg; return msg;
} }

View File

@ -16,6 +16,7 @@
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <string>
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "force.h" #include "force.h"
@ -25,6 +26,7 @@
#include "error.h" #include "error.h"
#include "suffix.h" #include "suffix.h"
#include "domain.h" #include "domain.h"
#include "fmt/format.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -307,10 +309,10 @@ void KSpace::qsum_qsq(int warning_flag)
// so issue warning or error // so issue warning or error
if (fabs(qsum) > SMALL) { if (fabs(qsum) > SMALL) {
char str[128]; std::string message = fmt::format("System is not charge neutral, net "
sprintf(str,"System is not charge neutral, net charge = %g",qsum); "charge = {}",qsum);
if (!warn_nonneutral) error->all(FLERR,str); if (!warn_nonneutral) error->all(FLERR,message);
if (warn_nonneutral == 1 && comm->me == 0) error->warning(FLERR,str); if (warn_nonneutral == 1 && comm->me == 0) error->warning(FLERR,message);
warn_nonneutral = 2; warn_nonneutral = 2;
} }
} }
@ -324,12 +326,10 @@ double KSpace::estimate_table_accuracy(double q2_over_sqrt, double spr)
double table_accuracy = 0.0; double table_accuracy = 0.0;
int nctb = force->pair->ncoultablebits; int nctb = force->pair->ncoultablebits;
if (comm->me == 0) { if (comm->me == 0) {
char str[128];
if (nctb) if (nctb)
sprintf(str," using %d-bit tables for long-range coulomb",nctb); error->message(FLERR,fmt::format(" using {}-bit tables for long-range coulomb",nctb));
else else
sprintf(str," using polynomial approximation for long-range coulomb"); error->message(FLERR," using polynomial approximation for long-range coulomb");
error->message(FLERR,str);
} }
if (nctb) { if (nctb) {

View File

@ -667,15 +667,12 @@ LAMMPS::~LAMMPS()
double totalclock = MPI_Wtime() - initclock; double totalclock = MPI_Wtime() - initclock;
if ((me == 0) && (screen || logfile)) { if ((me == 0) && (screen || logfile)) {
char outtime[128];
int seconds = fmod(totalclock,60.0); int seconds = fmod(totalclock,60.0);
totalclock = (totalclock - seconds) / 60.0; totalclock = (totalclock - seconds) / 60.0;
int minutes = fmod(totalclock,60.0); int minutes = fmod(totalclock,60.0);
int hours = (totalclock - minutes) / 60.0; int hours = (totalclock - minutes) / 60.0;
sprintf(outtime,"Total wall time: " utils::logmesg(this,fmt::format("Total wall time: {}:{:02d}:{:02d}\n",
"%d:%02d:%02d\n", hours, minutes, seconds); hours, minutes, seconds));
if (screen) fputs(outtime,screen);
if (logfile) fputs(outtime,logfile);
} }
if (universe->nworlds == 1) { if (universe->nworlds == 1) {

View File

@ -13,6 +13,7 @@
#include "modify.h" #include "modify.h"
#include <cstring> #include <cstring>
#include <string>
#include "style_compute.h" #include "style_compute.h"
#include "style_fix.h" #include "style_fix.h"
#include "atom.h" #include "atom.h"
@ -836,18 +837,17 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
int match = 0; int match = 0;
if (strcmp(arg[2],fix[ifix]->style) == 0) match = 1; if (strcmp(arg[2],fix[ifix]->style) == 0) match = 1;
if (!match && trysuffix && lmp->suffix_enable) { if (!match && trysuffix && lmp->suffix_enable) {
char estyle[256];
if (lmp->suffix) { if (lmp->suffix) {
sprintf(estyle,"%s/%s",arg[2],lmp->suffix); std::string estyle = arg[2] + std::string("/") + lmp->suffix;
if (strcmp(estyle,fix[ifix]->style) == 0) match = 1; if (estyle == fix[ifix]->style) match = 1;
} }
if (lmp->suffix2) { if (lmp->suffix2) {
sprintf(estyle,"%s/%s",arg[2],lmp->suffix2); std::string estyle = arg[2] + std::string("/") + lmp->suffix2;
if (strcmp(estyle,fix[ifix]->style) == 0) match = 1; if (estyle == fix[ifix]->style) match = 1;
} }
} }
if (!match) error->all(FLERR, if (!match)
"Replacing a fix, but new style != old style"); error->all(FLERR,"Replacing a fix, but new style != old style");
if (fix[ifix]->igroup != igroup && comm->me == 0) if (fix[ifix]->igroup != igroup && comm->me == 0)
error->warning(FLERR,"Replacing a fix, but new group != old group"); error->warning(FLERR,"Replacing a fix, but new group != old group");
@ -870,26 +870,24 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
int n = strlen(arg[2])+strlen(lmp->suffix)+2; std::string estyle = arg[2] + std::string("/") + lmp->suffix;
char *estyle = new char[n];
sprintf(estyle,"%s/%s",arg[2],lmp->suffix);
if (fix_map->find(estyle) != fix_map->end()) { if (fix_map->find(estyle) != fix_map->end()) {
FixCreator fix_creator = (*fix_map)[estyle]; FixCreator fix_creator = (*fix_map)[estyle];
fix[ifix] = fix_creator(lmp,narg,arg); fix[ifix] = fix_creator(lmp,narg,arg);
delete[] fix[ifix]->style; delete[] fix[ifix]->style;
fix[ifix]->style = estyle; fix[ifix]->style = new char[estyle.size()+1];
} else delete[] estyle; strcpy(fix[ifix]->style,estyle.c_str());
}
} }
if (fix[ifix] == NULL && lmp->suffix2) { if (fix[ifix] == NULL && lmp->suffix2) {
int n = strlen(arg[2])+strlen(lmp->suffix2)+2; std::string estyle = arg[2] + std::string("/") + lmp->suffix2;
char *estyle = new char[n];
sprintf(estyle,"%s/%s",arg[2],lmp->suffix2);
if (fix_map->find(estyle) != fix_map->end()) { if (fix_map->find(estyle) != fix_map->end()) {
FixCreator fix_creator = (*fix_map)[estyle]; FixCreator fix_creator = (*fix_map)[estyle];
fix[ifix] = fix_creator(lmp,narg,arg); fix[ifix] = fix_creator(lmp,narg,arg);
delete[] fix[ifix]->style; delete[] fix[ifix]->style;
fix[ifix]->style = estyle; fix[ifix]->style = new char[estyle.size()+1];
} else delete[] estyle; strcpy(fix[ifix]->style,estyle.c_str());
}
} }
} }
@ -1164,7 +1162,7 @@ int Modify::check_rigid_list_overlap(int *select)
int n = 0; int n = 0;
for (int ifix = 0; ifix < nfix; ifix++) { for (int ifix = 0; ifix < nfix; ifix++) {
if (strncmp("rigid",fix[ifix]->style,5) == 0) { if (utils::strmatch(fix[ifix]->style,"^rigid")) {
const int * const body = (const int *)fix[ifix]->extract("body",dim); const int * const body = (const int *)fix[ifix]->extract("body",dim);
if ((body == NULL) || (dim != 1)) break; if ((body == NULL) || (dim != 1)) break;
@ -1209,26 +1207,24 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
int n = strlen(arg[2])+strlen(lmp->suffix)+2; std::string estyle = arg[2] + std::string("/") + lmp->suffix;
char *estyle = new char[n];
sprintf(estyle,"%s/%s",arg[2],lmp->suffix);
if (compute_map->find(estyle) != compute_map->end()) { if (compute_map->find(estyle) != compute_map->end()) {
ComputeCreator compute_creator = (*compute_map)[estyle]; ComputeCreator compute_creator = (*compute_map)[estyle];
compute[ncompute] = compute_creator(lmp,narg,arg); compute[ncompute] = compute_creator(lmp,narg,arg);
delete[] compute[ncompute]->style; delete[] compute[ncompute]->style;
compute[ncompute]->style = estyle; compute[ncompute]->style = new char[estyle.size()+1];
} else delete[] estyle; strcpy(compute[ncompute]->style,estyle.c_str());
}
} }
if (compute[ncompute] == NULL && lmp->suffix2) { if (compute[ncompute] == NULL && lmp->suffix2) {
int n = strlen(arg[2])+strlen(lmp->suffix2)+2; std::string estyle = arg[2] + std::string("/") + lmp->suffix2;
char *estyle = new char[n];
sprintf(estyle,"%s/%s",arg[2],lmp->suffix2);
if (compute_map->find(estyle) != compute_map->end()) { if (compute_map->find(estyle) != compute_map->end()) {
ComputeCreator compute_creator = (*compute_map)[estyle]; ComputeCreator compute_creator = (*compute_map)[estyle];
compute[ncompute] = compute_creator(lmp,narg,arg); compute[ncompute] = compute_creator(lmp,narg,arg);
delete[] compute[ncompute]->style; delete[] compute[ncompute]->style;
compute[ncompute]->style = estyle; compute[ncompute]->style = new char[estyle.size()+1];
} else delete[] estyle; strcpy(compute[ncompute]->style,estyle.c_str());
}
} }
} }

View File

@ -97,10 +97,7 @@ void NTopoImproperPartial::build()
int all; int all;
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
if (all) { if (all && me == 0)
char str[128]; error->warning(FLERR,fmt::format("Improper atoms missing at step {}",
sprintf(str, update->ntimestep));
"Improper atoms missing at step " BIGINT_FORMAT,update->ntimestep);
if (me == 0) error->warning(FLERR,str);
}
} }

View File

@ -116,37 +116,28 @@ void PairTable::compute(int eflag, int vflag)
if (rsq < cutsq[itype][jtype]) { if (rsq < cutsq[itype][jtype]) {
tb = &tables[tabindex[itype][jtype]]; tb = &tables[tabindex[itype][jtype]];
if (rsq < tb->innersq) { if (rsq < tb->innersq)
sprintf(estr,"Pair distance < table inner cutoff: " error->one(FLERR,fmt::format("Pair distance < table inner cutoff: "
"ijtype %d %d dist %g",itype,jtype,sqrt(rsq)); "ijtype {} {} dist {}",itype,jtype,sqrt(rsq)));
error->one(FLERR,estr);
}
if (tabstyle == LOOKUP) { if (tabstyle == LOOKUP) {
itable = static_cast<int> ((rsq - tb->innersq) * tb->invdelta); itable = static_cast<int> ((rsq - tb->innersq) * tb->invdelta);
if (itable >= tlm1) { if (itable >= tlm1)
sprintf(estr,"Pair distance > table outer cutoff: " error->one(FLERR,fmt::format("Pair distance > table outer cutoff: "
"ijtype %d %d dist %g",itype,jtype,sqrt(rsq)); "ijtype {} {} dist {}",itype,jtype,sqrt(rsq)));
error->one(FLERR,estr);
}
fpair = factor_lj * tb->f[itable]; fpair = factor_lj * tb->f[itable];
} else if (tabstyle == LINEAR) { } else if (tabstyle == LINEAR) {
itable = static_cast<int> ((rsq - tb->innersq) * tb->invdelta); itable = static_cast<int> ((rsq - tb->innersq) * tb->invdelta);
if (itable >= tlm1) { if (itable >= tlm1)
sprintf(estr,"Pair distance > table outer cutoff: " error->one(FLERR,fmt::format("Pair distance > table outer cutoff: "
"ijtype %d %d dist %g",itype,jtype,sqrt(rsq)); "ijtype {} {} dist {}",itype,jtype,sqrt(rsq)));
error->one(FLERR,estr);
}
fraction = (rsq - tb->rsq[itable]) * tb->invdelta; fraction = (rsq - tb->rsq[itable]) * tb->invdelta;
value = tb->f[itable] + fraction*tb->df[itable]; value = tb->f[itable] + fraction*tb->df[itable];
fpair = factor_lj * value; fpair = factor_lj * value;
} else if (tabstyle == SPLINE) { } else if (tabstyle == SPLINE) {
itable = static_cast<int> ((rsq - tb->innersq) * tb->invdelta); itable = static_cast<int> ((rsq - tb->innersq) * tb->invdelta);
if (itable >= tlm1) { if (itable >= tlm1)
sprintf(estr,"Pair distance > table outer cutoff: " error->one(FLERR,fmt::format("Pair distance > table outer cutoff: "
"ijtype %d %d dist %g",itype,jtype,sqrt(rsq)); "ijtype {} {} dist {}",itype,jtype,sqrt(rsq)));
error->one(FLERR,estr);
}
b = (rsq - tb->rsq[itable]) * tb->invdelta; b = (rsq - tb->rsq[itable]) * tb->invdelta;
a = 1.0 - b; a = 1.0 - b;
value = a * tb->f[itable] + b * tb->f[itable+1] + value = a * tb->f[itable] + b * tb->f[itable+1] +

View File

@ -1157,11 +1157,8 @@ void ReadData::header(int firstpass)
parse_keyword(1); parse_keyword(1);
for (n = 0; n < NSECTIONS; n++) for (n = 0; n < NSECTIONS; n++)
if (strcmp(keyword,section_keywords[n]) == 0) break; if (strcmp(keyword,section_keywords[n]) == 0) break;
if (n == NSECTIONS) { if (n == NSECTIONS)
char str[128]; error->all(FLERR,fmt::format("Unknown identifier in data file: {}",keyword));
sprintf(str,"Unknown identifier in data file: %s",keyword);
error->all(FLERR,str);
}
// error checks on header values // error checks on header values
// must be consistent with atom style and other header values // must be consistent with atom style and other header values

View File

@ -289,13 +289,9 @@ bigint ReadDump::seek(bigint nrequest, int exact)
for (ifile = 0; ifile < nfile; ifile++) { for (ifile = 0; ifile < nfile; ifile++) {
ntimestep = -1; ntimestep = -1;
if (multiproc) { if (multiproc) {
char *ptr = strchr(files[ifile],'%'); std::string multiname = files[ifile];
char *multiname = new char[strlen(files[ifile]) + 16]; multiname.replace(multiname.find("%"),1,"0");
*ptr = '\0'; readers[0]->open_file(multiname.c_str());
sprintf(multiname,"%s%d%s",files[ifile],0,ptr+1);
*ptr = '%';
readers[0]->open_file(multiname);
delete [] multiname;
} else readers[0]->open_file(files[ifile]); } else readers[0]->open_file(files[ifile]);
while (1) { while (1) {
@ -337,13 +333,9 @@ bigint ReadDump::seek(bigint nrequest, int exact)
if (multiproc && filereader) { if (multiproc && filereader) {
for (int i = 0; i < nreader; i++) { for (int i = 0; i < nreader; i++) {
if (me == 0 && i == 0) continue; // proc 0, reader 0 already found it if (me == 0 && i == 0) continue; // proc 0, reader 0 already found it
char *ptr = strchr(files[currentfile],'%'); std::string multiname = files[currentfile];
char *multiname = new char[strlen(files[currentfile]) + 16]; multiname.replace(multiname.find("%"),1,fmt::format("{}",firstfile+i));
*ptr = '\0'; readers[i]->open_file(multiname.c_str());
sprintf(multiname,"%s%d%s",files[currentfile],firstfile+i,ptr+1);
*ptr = '%';
readers[i]->open_file(multiname);
delete [] multiname;
bigint step; bigint step;
while (1) { while (1) {
@ -389,13 +381,9 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip)
ntimestep = -1; ntimestep = -1;
if (ifile != currentfile) { if (ifile != currentfile) {
if (multiproc) { if (multiproc) {
char *ptr = strchr(files[ifile],'%'); std::string multiname = files[ifile];
char *multiname = new char[strlen(files[ifile]) + 16]; multiname.replace(multiname.find("%"),1,"0");
*ptr = '\0'; readers[0]->open_file(multiname.c_str());
sprintf(multiname,"%s%d%s",files[ifile],0,ptr+1);
*ptr = '%';
readers[0]->open_file(multiname);
delete [] multiname;
} else readers[0]->open_file(files[ifile]); } else readers[0]->open_file(files[ifile]);
} }
@ -447,13 +435,9 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip)
if (multiproc && filereader) { if (multiproc && filereader) {
for (int i = 0; i < nreader; i++) { for (int i = 0; i < nreader; i++) {
if (me == 0 && i == 0) continue; if (me == 0 && i == 0) continue;
char *ptr = strchr(files[currentfile],'%'); std::string multiname = files[currentfile];
char *multiname = new char[strlen(files[currentfile]) + 16]; multiname.replace(multiname.find("%"),1,fmt::format("{}",firstfile+i));
*ptr = '\0'; readers[i]->open_file(multiname.c_str());
sprintf(multiname,"%s%d%s",files[currentfile],firstfile+i,ptr+1);
*ptr = '%';
readers[i]->open_file(multiname);
delete [] multiname;
bigint step; bigint step;
while (1) { while (1) {

View File

@ -104,19 +104,14 @@ void ReadRestart::command(int narg, char **arg)
if (me == 0) { if (me == 0) {
if (screen) fprintf(screen,"Reading restart file ...\n"); if (screen) fprintf(screen,"Reading restart file ...\n");
char *hfile; std::string hfile = file;
if (multiproc) { if (multiproc) {
hfile = new char[strlen(file) + 16]; hfile.replace(hfile.find("%"),1,"base");
char *ptr = strchr(file,'%'); }
*ptr = '\0'; fp = fopen(hfile.c_str(),"rb");
sprintf(hfile,"%s%s%s",file,"base",ptr+1);
*ptr = '%';
} else hfile = file;
fp = fopen(hfile,"rb");
if (fp == NULL) if (fp == NULL)
error->one(FLERR,fmt::format("Cannot open restart file {}: {}", error->one(FLERR,fmt::format("Cannot open restart file {}: {}",
hfile, utils::getsyserror())); hfile, utils::getsyserror()));
if (multiproc) delete [] hfile;
} }
// read magic string, endian flag, format revision // read magic string, endian flag, format revision
@ -272,14 +267,10 @@ void ReadRestart::command(int narg, char **arg)
else if (nprocs <= multiproc_file) { else if (nprocs <= multiproc_file) {
char *procfile = new char[strlen(file) + 16];
char *ptr = strchr(file,'%');
for (int iproc = me; iproc < multiproc_file; iproc += nprocs) { for (int iproc = me; iproc < multiproc_file; iproc += nprocs) {
*ptr = '\0'; std::string procfile = file;
sprintf(procfile,"%s%d%s",file,iproc,ptr+1); procfile.replace(procfile.find("%"),1,fmt::format("{}",iproc));
*ptr = '%'; fp = fopen(procfile.c_str(),"rb");
fp = fopen(procfile,"rb");
if (fp == NULL) if (fp == NULL)
error->one(FLERR,fmt::format("Cannot open restart file {}: {}", error->one(FLERR,fmt::format("Cannot open restart file {}: {}",
procfile, utils::getsyserror())); procfile, utils::getsyserror()));
@ -309,8 +300,6 @@ void ReadRestart::command(int narg, char **arg)
fclose(fp); fclose(fp);
fp = NULL; fp = NULL;
} }
delete [] procfile;
} }
// input of multiple native files with procs > files // input of multiple native files with procs > files
@ -343,16 +332,12 @@ void ReadRestart::command(int narg, char **arg)
MPI_Comm_split(world,icluster,0,&clustercomm); MPI_Comm_split(world,icluster,0,&clustercomm);
if (filereader) { if (filereader) {
char *procfile = new char[strlen(file) + 16]; std::string procfile = file;
char *ptr = strchr(file,'%'); procfile.replace(procfile.find("%"),1,fmt::format("{}",icluster));
*ptr = '\0'; fp = fopen(procfile.c_str(),"rb");
sprintf(procfile,"%s%d%s",file,icluster,ptr+1);
*ptr = '%';
fp = fopen(procfile,"rb");
if (fp == NULL) if (fp == NULL)
error->one(FLERR,fmt::format("Cannot open restart file {}: {}", error->one(FLERR,fmt::format("Cannot open restart file {}: {}",
procfile, utils::getsyserror())); procfile, utils::getsyserror()));
delete [] procfile;
} }
int flag,procsperfile; int flag,procsperfile;
@ -618,10 +603,9 @@ void ReadRestart::file_search(char *inpfile, char *outfile)
// create outfile with maxint substituted for "*" // create outfile with maxint substituted for "*"
// use original inpfile, not pattern, since need to retain "%" in filename // use original inpfile, not pattern, since need to retain "%" in filename
ptr = strchr(inpfile,'*'); std::string newoutfile = inpfile;
*ptr = '\0'; newoutfile.replace(newoutfile.find("*"),1,fmt::format("{}",maxnum));
sprintf(outfile,"%s" BIGINT_FORMAT "%s",inpfile,maxnum,ptr+1); strcpy(outfile,newoutfile.c_str());
*ptr = '*';
// clean up // clean up

View File

@ -24,6 +24,7 @@
#include "memory.h" #include "memory.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;
@ -252,12 +253,9 @@ void ResetIDs::command(int narg, char **arg)
int all; int all;
MPI_Allreduce(&badcount,&all,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&badcount,&all,1,MPI_INT,MPI_SUM,world);
if (all) { if (all)
char str[128]; error->all(FLERR,fmt::format("Reset_ids missing {} bond topology atom IDs - "
sprintf(str,"Reset_ids missing %d bond topology atom IDs - " "use comm_modify cutoff",all));
"use comm_modify cutoff",all);
error->all(FLERR,str);
}
// reset IDs and atom map for owned atoms // reset IDs and atom map for owned atoms

View File

@ -45,6 +45,7 @@
#include "error.h" #include "error.h"
#include "math_const.h" #include "math_const.h"
#include "utils.h" #include "utils.h"
#include "fmt/format.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -423,21 +424,15 @@ bigint Thermo::lost_check()
// error message // error message
if (lostflag == Thermo::ERROR) { if (lostflag == Thermo::ERROR)
char str[64]; error->all(FLERR,fmt::format("Lost atoms: original {} current {}",
sprintf(str, atom->natoms,ntotal));
"Lost atoms: original " BIGINT_FORMAT " current " BIGINT_FORMAT,
atom->natoms,ntotal);
error->all(FLERR,str);
}
// warning message // warning message
char str[64]; if (me == 0)
sprintf(str, error->warning(FLERR,fmt::format("Lost atoms: original {} current {}",
"Lost atoms: original " BIGINT_FORMAT " current " BIGINT_FORMAT, atom->natoms,ntotal),0);
atom->natoms,ntotal);
if (me == 0) error->warning(FLERR,str,0);
// reset total atom count // reset total atom count