simplify code by appling varargs messages and warnings

This commit is contained in:
Axel Kohlmeyer
2021-05-05 18:19:12 -04:00
parent 8fd0595f1b
commit 22e93468d6
48 changed files with 162 additions and 181 deletions

View File

@ -72,7 +72,7 @@ void DumpAtomGZ::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -80,7 +80,7 @@ void DumpAtomZstd::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -74,7 +74,7 @@ void DumpCFGGZ::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -82,7 +82,7 @@ void DumpCFGZstd::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -72,7 +72,7 @@ void DumpCustomGZ::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -79,7 +79,7 @@ void DumpCustomZstd::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -72,7 +72,7 @@ void DumpLocalGZ::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -79,7 +79,7 @@ void DumpLocalZstd::openfile()
++numfiles; ++numfiles;
} else { } else {
if (remove(nameslist[fileidx]) != 0) { if (remove(nameslist[fileidx]) != 0) {
error->warning(FLERR, fmt::format("Could not delete {}", nameslist[fileidx])); error->warning(FLERR, "Could not delete {}", nameslist[fileidx]);
} }
delete[] nameslist[fileidx]; delete[] nameslist[fileidx];
nameslist[fileidx] = utils::strdup(filecurrent); nameslist[fileidx] = utils::strdup(filecurrent);

View File

@ -213,11 +213,10 @@ void EwaldDisp::init()
error->all(FLERR,"Cannot (yet) use 'electron' units with dipoles"); error->all(FLERR,"Cannot (yet) use 'electron' units with dipoles");
if (qsqsum == 0.0 && bsbsum == 0.0 && M2 == 0.0) if (qsqsum == 0.0 && bsbsum == 0.0 && M2 == 0.0)
error->all(FLERR,"Cannot use Ewald/disp solver " error->all(FLERR,"Cannot use Ewald/disp solver on system without "
"on system with no charge, dipole, or LJ particles"); "charged, dipole, or LJ particles");
if (fabs(qsum) > SMALL && comm->me == 0) if (fabs(qsum) > SMALL && comm->me == 0)
error->warning(FLERR,fmt::format("System is not charge neutral, " error->warning(FLERR,"System is not charge neutral, net charge = {:.8g}",qsum);
"net charge = {:.8g}",qsum));
if (!function[1] && !function[2]) dispersionflag = 0; if (!function[1] && !function[2]) dispersionflag = 0;
if (!function[3]) dipoleflag = 0; if (!function[3]) dipoleflag = 0;

View File

@ -1085,8 +1085,8 @@ void MSM::set_grid_global()
*p_cutoff = cutoff; *p_cutoff = cutoff;
if (me == 0) if (me == 0)
error->warning(FLERR,fmt::format("Adjusting Coulombic cutoff for " error->warning(FLERR,"Adjusting Coulombic cutoff for "
"MSM, new cutoff = {:.8}", cutoff)); "MSM, new cutoff = {:.8}", cutoff);
} }
if (triclinic == 0) { if (triclinic == 0) {

View File

@ -1362,8 +1362,8 @@ void PPPMDisp::init_coeffs()
err = bmax/amax; err = bmax/amax;
if (err > 1.0e-4 && comm->me == 0) if (err > 1.0e-4 && comm->me == 0)
error->warning(FLERR,fmt::format("Estimated error in splitting of " error->warning(FLERR,"Estimated error in splitting of "
"dispersion coeffs is {}",err)); "dispersion coeffs is {}",err);
// set B // set B
B = new double[nsplit*n+nsplit]; B = new double[nsplit*n+nsplit];

View File

@ -287,8 +287,8 @@ void FixDeposit::init()
double separation = MAX(2.0*maxradinsert,maxradall+maxradinsert); double separation = MAX(2.0*maxradinsert,maxradall+maxradinsert);
if (sqrt(nearsq) < separation && comm->me == 0) if (sqrt(nearsq) < separation && comm->me == 0)
error->warning(FLERR,fmt::format("Fix deposit near setting < possible " error->warning(FLERR,"Fix deposit near setting < possible "
"overlap separation {}",separation)); "overlap separation {}",separation);
} }
} }

View File

@ -85,8 +85,8 @@ void BondFENE::compute(int eflag, int vflag)
// if r > 2*r0 something serious is wrong, abort // if r > 2*r0 something serious is wrong, abort
if (rlogarg < 0.1) { if (rlogarg < 0.1) {
error->warning(FLERR,fmt::format("FENE bond too long: {} {} {} {}", error->warning(FLERR,"FENE bond too long: {} {} {} {}",
update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq))); update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq));
if (rlogarg <= -3.0) error->one(FLERR,"Bad FENE bond"); if (rlogarg <= -3.0) error->one(FLERR,"Bad FENE bond");
rlogarg = 0.1; rlogarg = 0.1;
} }

View File

@ -378,15 +378,15 @@ void BondTable::read_table(Table *tb, char *file, char *keyword)
} }
if (ferror) { if (ferror) {
error->warning(FLERR, fmt::format("{} of {} force values in table are inconsistent with -dE/dr.\n" error->warning(FLERR, "{} of {} force values in table are inconsistent with -dE/dr.\n"
" Should only be flagged at inflection points",ferror,tb->ninput)); "WARNING: Should only be flagged at inflection points",ferror,tb->ninput);
} }
// warn if data was read incompletely, e.g. columns were missing // warn if data was read incompletely, e.g. columns were missing
if (cerror) { if (cerror) {
error->warning(FLERR, fmt::format("{} of {} lines in table were incomplete or could not be" error->warning(FLERR, "{} of {} lines in table were incomplete or could not be"
" parsed completely",cerror,tb->ninput)); " parsed completely",cerror,tb->ninput);
} }
} }

View File

@ -171,9 +171,8 @@ namespace LAMMPS_NS
auto pair_map = lmp->force->pair_map; auto pair_map = lmp->force->pair_map;
if (pair_map->find(plugin->name) != pair_map->end()) { if (pair_map->find(plugin->name) != pair_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in pair " lmp->error->warning(FLERR,"Overriding built-in pair "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*pair_map)[plugin->name] = (Force::PairCreator)plugin->creator.v1; (*pair_map)[plugin->name] = (Force::PairCreator)plugin->creator.v1;
@ -181,9 +180,8 @@ namespace LAMMPS_NS
auto bond_map = lmp->force->bond_map; auto bond_map = lmp->force->bond_map;
if (bond_map->find(plugin->name) != bond_map->end()) { if (bond_map->find(plugin->name) != bond_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in bond " lmp->error->warning(FLERR,"Overriding built-in bond "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*bond_map)[plugin->name] = (Force::BondCreator)plugin->creator.v1; (*bond_map)[plugin->name] = (Force::BondCreator)plugin->creator.v1;
@ -191,9 +189,8 @@ namespace LAMMPS_NS
auto angle_map = lmp->force->angle_map; auto angle_map = lmp->force->angle_map;
if (angle_map->find(plugin->name) != angle_map->end()) { if (angle_map->find(plugin->name) != angle_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in angle " lmp->error->warning(FLERR,"Overriding built-in angle "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*angle_map)[plugin->name] = (Force::AngleCreator)plugin->creator.v1; (*angle_map)[plugin->name] = (Force::AngleCreator)plugin->creator.v1;
@ -201,9 +198,8 @@ namespace LAMMPS_NS
auto dihedral_map = lmp->force->dihedral_map; auto dihedral_map = lmp->force->dihedral_map;
if (dihedral_map->find(plugin->name) != dihedral_map->end()) { if (dihedral_map->find(plugin->name) != dihedral_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in dihedral " lmp->error->warning(FLERR,"Overriding built-in dihedral "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*dihedral_map)[plugin->name] = (Force::DihedralCreator)plugin->creator.v1; (*dihedral_map)[plugin->name] = (Force::DihedralCreator)plugin->creator.v1;
@ -211,9 +207,8 @@ namespace LAMMPS_NS
auto improper_map = lmp->force->improper_map; auto improper_map = lmp->force->improper_map;
if (improper_map->find(plugin->name) != improper_map->end()) { if (improper_map->find(plugin->name) != improper_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in improper " lmp->error->warning(FLERR,"Overriding built-in improper "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*improper_map)[plugin->name] = (Force::ImproperCreator)plugin->creator.v1; (*improper_map)[plugin->name] = (Force::ImproperCreator)plugin->creator.v1;
@ -221,9 +216,8 @@ namespace LAMMPS_NS
auto compute_map = lmp->modify->compute_map; auto compute_map = lmp->modify->compute_map;
if (compute_map->find(plugin->name) != compute_map->end()) { if (compute_map->find(plugin->name) != compute_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in compute " lmp->error->warning(FLERR,"Overriding built-in compute "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*compute_map)[plugin->name] = (Modify::ComputeCreator)plugin->creator.v2; (*compute_map)[plugin->name] = (Modify::ComputeCreator)plugin->creator.v2;
@ -231,9 +225,8 @@ namespace LAMMPS_NS
auto fix_map = lmp->modify->fix_map; auto fix_map = lmp->modify->fix_map;
if (fix_map->find(plugin->name) != fix_map->end()) { if (fix_map->find(plugin->name) != fix_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in fix " lmp->error->warning(FLERR,"Overriding built-in fix "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*fix_map)[plugin->name] = (Modify::FixCreator)plugin->creator.v2; (*fix_map)[plugin->name] = (Modify::FixCreator)plugin->creator.v2;
@ -241,9 +234,8 @@ namespace LAMMPS_NS
auto region_map = lmp->domain->region_map; auto region_map = lmp->domain->region_map;
if (region_map->find(plugin->name) != region_map->end()) { if (region_map->find(plugin->name) != region_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in region " lmp->error->warning(FLERR,"Overriding built-in region "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*region_map)[plugin->name] = (Domain::RegionCreator)plugin->creator.v2; (*region_map)[plugin->name] = (Domain::RegionCreator)plugin->creator.v2;
@ -251,9 +243,8 @@ namespace LAMMPS_NS
auto command_map = lmp->input->command_map; auto command_map = lmp->input->command_map;
if (command_map->find(plugin->name) != command_map->end()) { if (command_map->find(plugin->name) != command_map->end()) {
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
lmp->error->warning(FLERR,fmt::format("Overriding built-in command " lmp->error->warning(FLERR,"Overriding built-in command "
"style {} from plugin", "style {} from plugin",plugin->name);
plugin->name));
} }
(*command_map)[plugin->name] = (Input::CommandCreator)plugin->creator.v1; (*command_map)[plugin->name] = (Input::CommandCreator)plugin->creator.v1;

View File

@ -387,10 +387,9 @@ int FixQEq::CG( double *b, double *x )
} }
if ((comm->me == 0) && (loop >= maxiter)) if ((comm->me == 0) && (loop >= maxiter))
error->warning(FLERR,fmt::format("Fix qeq CG convergence failed ({}) " error->warning(FLERR,"Fix qeq CG convergence failed ({}) after {} "
"after {} iterations at step {}", "iterations at step {}",sqrt(sig_new)/b_norm,loop,
sqrt(sig_new)/b_norm,loop, update->ntimestep);
update->ntimestep));
return loop; return loop;
} }

View File

@ -155,8 +155,8 @@ void FixQEqDynamic::pre_force(int /*vflag*/)
} }
if ((comm->me == 0) && (iloop >= maxiter)) if ((comm->me == 0) && (iloop >= maxiter))
error->warning(FLERR,fmt::format("Charges did not converge at step " error->warning(FLERR,"Charges did not converge at step {}: {}",
"{}: {}",update->ntimestep,enegchk)); update->ntimestep,enegchk);
if (force->kspace) force->kspace->qsum_qsq(); if (force->kspace) force->kspace->qsum_qsq();
} }

View File

@ -215,8 +215,8 @@ void FixQEqFire::pre_force(int /*vflag*/)
} }
if ((comm->me == 0) && (iloop >= maxiter)) if ((comm->me == 0) && (iloop >= maxiter))
error->warning(FLERR,fmt::format("Charges did not converge at step " error->warning(FLERR,"Charges did not converge at step {}: {}",
"{}: {}",update->ntimestep,enegchk)); update->ntimestep,enegchk);
if (force->kspace) force->kspace->qsum_qsq(); if (force->kspace) force->kspace->qsum_qsq();
} }

View File

@ -697,8 +697,8 @@ void FixRigid::init()
if (modify->fix[i]->rigid_flag) rflag = 1; if (modify->fix[i]->rigid_flag) rflag = 1;
if (rflag && (modify->fmask[i] & POST_FORCE) && if (rflag && (modify->fmask[i] & POST_FORCE) &&
!modify->fix[i]->rigid_flag) !modify->fix[i]->rigid_flag)
error->warning(FLERR,fmt::format("Fix {} alters forces after fix " error->warning(FLERR,"Fix {} alters forces after fix rigid",
"rigid",modify->fix[i]->id)); modify->fix[i]->id);
} }
} }

View File

@ -548,8 +548,8 @@ void FixRigidSmall::init()
if (modify->fix[i]->rigid_flag) rflag = 1; if (modify->fix[i]->rigid_flag) rflag = 1;
if (rflag && (modify->fmask[i] & POST_FORCE) && if (rflag && (modify->fmask[i] & POST_FORCE) &&
!modify->fix[i]->rigid_flag) !modify->fix[i]->rigid_flag)
error->warning(FLERR,fmt::format("Fix {} alters forces after fix " error->warning(FLERR,"Fix {} alters forces after fix rigid",
"rigid",modify->fix[i]->id)); modify->fix[i]->id);
} }
} }

View File

@ -629,7 +629,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
// NB: LAMMPS coding guidelines prefer cstdio so we are intentionally // NB: LAMMPS coding guidelines prefer cstdio so we are intentionally
// foregoing reading with getline // foregoing reading with getline
if (comm->me == 0) { if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: About to read data file: {}", filename)); error->message(FLERR, "INFO: About to read data file: {}", filename);
} }
// Data file lines hold two floating point numbers. // Data file lines hold two floating point numbers.
@ -645,7 +645,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
numEntries = inputLines.size(); numEntries = inputLines.size();
if (comm->me == 0) { if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: Read {} lines from file", numEntries)); error->message(FLERR, "INFO: Read {} lines from file", numEntries);
} }
@ -670,34 +670,23 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2); test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2);
if (test_sscanf == 2) if (test_sscanf == 2)
{ {
//if (comm->me == 0) {
// error->message(FLERR, fmt::format("INFO: f1 = {}, f2 = {}", f1, f2));
//}
data[VOLUME][i] = (double)f1; data[VOLUME][i] = (double)f1;
data[PRESSURE_CORRECTION][i] = (double)f2; data[PRESSURE_CORRECTION][i] = (double)f2;
if (i == 1) if (i == 1)
{ {
// second entry is used to compute the validation interval used below // second entry is used to compute the validation interval used below
stdVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1]; stdVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1];
//if (comm->me == 0) {
// error->message(FLERR, fmt::format("INFO: standard volume interval computed: {}", stdVolumeInterval));
//}
} }
else if (i > 1) else if (i > 1)
{ {
// after second entry, all intervals are validated // after second entry, all intervals are validated
currVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1]; currVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1];
//if (comm->me == 0) {
// error->message(FLERR, fmt::format("INFO: current volume interval: {}", currVolumeInterval));
//}
if (fabs(currVolumeInterval - stdVolumeInterval) > volumeIntervalTolerance) { if (fabs(currVolumeInterval - stdVolumeInterval) > volumeIntervalTolerance) {
if (comm->me == 0) { if (comm->me == 0)
message = fmt::format("Bad volume interval. Spline analysis requires uniform" error->warning(FLERR,"Bad volume interval. Spline analysis requires uniform"
" volume distribution, found inconsistent volume" " volume distribution, found inconsistent volume"
" differential, line {} of file {}\n\tline: {}", " differential, line {} of file {}\nWARNING:\tline: {}",
lineNum, filename, inputLines.at(i)); lineNum, filename, inputLines.at(i));
error->warning(FLERR, message);
}
badInput = true; badInput = true;
numBadVolumeIntervals++; numBadVolumeIntervals++;
} }
@ -706,12 +695,10 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
} }
else else
{ {
if (comm->me == 0) { if (comm->me == 0)
message = fmt::format("Bad input format: did not find 2 comma separated numeric" error->warning(FLERR,"Bad input format: did not find 2 comma separated numeric"
" values in line {} of file {}\n\tline: {}", " values in line {} of file {}\nWARNING:\tline: {}",
lineNum, filename, inputLines.at(i)); lineNum, filename, inputLines.at(i));
error->warning(FLERR, message);
}
badInput = true; badInput = true;
} }
if (badInput) if (badInput)
@ -721,7 +708,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
} }
if (numBadVolumeIntervals > 0 && comm->me == 0) { if (numBadVolumeIntervals > 0 && comm->me == 0) {
error->message(FLERR, fmt::format("INFO: total number bad volume intervals = {}", numBadVolumeIntervals)); error->message(FLERR, "INFO: total number bad volume intervals = {}", numBadVolumeIntervals);
} }
} }
else { else {
@ -729,7 +716,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
} }
if (badInput && comm->me == 0) { if (badInput && comm->me == 0) {
error->warning(FLERR,fmt::format("Bad volume / pressure-correction data: {}\nSee details above", filename)); error->warning(FLERR,"Bad volume / pressure-correction data: {}\nSee details above", filename);
} }
if (p_basis_type == BASIS_LINEAR_SPLINE) if (p_basis_type == BASIS_LINEAR_SPLINE)
@ -752,9 +739,6 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
} }
int FixBocs::build_linear_splines(double **data) { int FixBocs::build_linear_splines(double **data) {
//if (comm->me == 0) {
//error->message(FLERR, fmt::format("INFO: entering build_linear_splines, spline_length = {}", spline_length));
//}
splines = (double **) calloc(NUM_LINEAR_SPLINE_COLUMNS,sizeof(double *)); splines = (double **) calloc(NUM_LINEAR_SPLINE_COLUMNS,sizeof(double *));
splines[VOLUME] = (double *) calloc(spline_length,sizeof(double)); splines[VOLUME] = (double *) calloc(spline_length,sizeof(double));
splines[PRESSURE_CORRECTION] = (double *) calloc(spline_length,sizeof(double)); splines[PRESSURE_CORRECTION] = (double *) calloc(spline_length,sizeof(double));
@ -766,7 +750,7 @@ int FixBocs::build_linear_splines(double **data) {
} }
if (comm->me == 0) { if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: leaving build_linear_splines, spline_length = {}", spline_length)); error->message(FLERR, "INFO: leaving build_linear_splines, spline_length = {}", spline_length);
} }
return spline_length; return spline_length;
@ -774,9 +758,6 @@ int FixBocs::build_linear_splines(double **data) {
int FixBocs::build_cubic_splines(double **data) int FixBocs::build_cubic_splines(double **data)
{ {
//if (comm->me == 0) {
//error->message(FLERR, fmt::format("INFO: entering build_cubic_splines, spline_length = {}", spline_length));
//}
int n = spline_length; int n = spline_length;
double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z; double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z;
// 2020-07-17 ag: // 2020-07-17 ag:
@ -867,7 +848,7 @@ int FixBocs::build_cubic_splines(double **data)
memory->destroy(z); memory->destroy(z);
if (comm->me == 0) { if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: leaving build_cubic_splines, numSplines = {}", numSplines)); error->message(FLERR, "INFO: leaving build_cubic_splines, numSplines = {}", numSplines);
} }
// Tell the caller how many splines we created // Tell the caller how many splines we created

View File

@ -920,20 +920,17 @@ void PairMesoCNT::read_data(FILE *fp, double **data,
// warn if data was read incompletely, e.g. columns were missing // warn if data was read incompletely, e.g. columns were missing
if (cerror) if (cerror)
error->warning(FLERR,fmt::format("{} of {} lines were incomplete or could " error->warning(FLERR,"{} of {} lines were incomplete or could not be parsed "
"not be parsed completely in pair table: {}", "completely in pair table: {}",cerror,ninput*ninput,file);
cerror,ninput*ninput,file));
// warn if spacing between data points is not constant // warn if spacing between data points is not constant
if (sxerror) if (sxerror)
error->warning(FLERR,fmt::format("{} spacings in first column were different " error->warning(FLERR,"{} spacings in first column were different from "
" from first spacing in pair table: {}", "first spacing in pair table: {}",sxerror,file);
sxerror,file));
if (syerror) if (syerror)
error->warning(FLERR,fmt::format("{} spacings in second column were different " error->warning(FLERR,"{} spacings in second column were different from "
" from first spacing in pair table: {}", "first spacing in pair table: {}",syerror,file);
syerror,file));
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -349,8 +349,7 @@ void PairAGNI::read_file(char *filename)
params[curparam].gwidth = 0.0; params[curparam].gwidth = 0.0;
wantdata = curparam; wantdata = curparam;
curparam = -1; curparam = -1;
} else error->warning(FLERR,fmt::format("Ignoring unknown tag '{}' " } else error->warning(FLERR,"Ignoring unknown tag '{}' in AGNI potential file.",tag);
"in AGNI potential file.",tag));
} else { } else {
if (params && wantdata >=0) { if (params && wantdata >=0) {
if ((int)values.count() == params[wantdata].numeta + 2) { if ((int)values.count() == params[wantdata].numeta + 2) {

View File

@ -389,9 +389,8 @@ void ChangeBox::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 (natoms != atom->natoms && comm->me == 0) if (natoms != atom->natoms && comm->me == 0)
error->warning(FLERR,fmt::format("Lost atoms via change_box: " error->warning(FLERR,"Lost atoms via change_box: original {} "
"original {} current {}", "current {}", atom->natoms,natoms);
atom->natoms,natoms));
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -655,18 +655,16 @@ double Comm::get_comm_cutoff()
maxcommcutoff = MAX(maxcommcutoff,maxbondcutoff); maxcommcutoff = MAX(maxcommcutoff,maxbondcutoff);
} else { } else {
if ((me == 0) && (maxbondcutoff > maxcommcutoff)) if ((me == 0) && (maxbondcutoff > maxcommcutoff))
error->warning(FLERR,fmt::format("Communication cutoff {} is shorter " error->warning(FLERR,"Communication cutoff {} is shorter than a bond "
"than a bond length based estimate of " "length based estimate of {}. This may lead to errors.",
"{}. This may lead to errors.", maxcommcutoff,maxbondcutoff);
maxcommcutoff,maxbondcutoff));
} }
// print warning if neighborlist cutoff overrides user cutoff // print warning if neighborlist cutoff overrides user cutoff
if ((me == 0) && (update->setupflag == 1)) { if ((me == 0) && (update->setupflag == 1)) {
if ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser)) if ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser))
error->warning(FLERR,fmt::format("Communication cutoff adjusted to {}", error->warning(FLERR,"Communication cutoff adjusted to {}",maxcommcutoff);
maxcommcutoff));
} }
return maxcommcutoff; return maxcommcutoff;

View File

@ -186,8 +186,7 @@ void ComputeCNAAtom::compute_peratom()
int nerrorall; int nerrorall;
MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world);
if (nerrorall && comm->me == 0) if (nerrorall && comm->me == 0)
error->warning(FLERR,fmt::format("Too many neighbors in CNA for {} " error->warning(FLERR,"Too many neighbors in CNA for {} atoms",nerrorall);
"atoms",nerrorall));
// compute CNA for each atom in group // compute CNA for each atom in group
// only performed if # of nearest neighbors = 12 or 14 (fcc,hcp) // only performed if # of nearest neighbors = 12 or 14 (fcc,hcp)
@ -345,8 +344,7 @@ void ComputeCNAAtom::compute_peratom()
MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world);
if (nerrorall && comm->me == 0) if (nerrorall && comm->me == 0)
error->warning(FLERR,fmt::format("Too many common neighbors in CNA {} " error->warning(FLERR,"Too many common neighbors in CNA: {}x", nerrorall);
"times", nerrorall));
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -354,9 +354,8 @@ void DisplaceAtoms::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 (natoms != atom->natoms && comm->me == 0) if (natoms != atom->natoms && comm->me == 0)
error->warning(FLERR,fmt::format("Lost atoms via displace_atoms: " error->warning(FLERR,"Lost atoms via displace_atoms: original {} "
"original {} current {}", "current {}",atom->natoms,natoms);
atom->natoms,natoms));
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -258,6 +258,20 @@ void Error::warning(const std::string &file, int line, const std::string &str)
if (logfile) fputs(mesg.c_str(),logfile); if (logfile) fputs(mesg.c_str(),logfile);
} }
/* ----------------------------------------------------------------------
forward vararg version to single string version
------------------------------------------------------------------------- */
void Error::_warning(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
warning(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
warning(file,line,e.what());
}
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
called by one proc in world, typically proc 0 called by one proc in world, typically proc 0
write message to screen and logfile (if logflag is set) write message to screen and logfile (if logflag is set)
@ -271,6 +285,20 @@ void Error::message(const std::string &file, int line, const std::string &str)
if (logfile) fputs(mesg.c_str(),logfile); if (logfile) fputs(mesg.c_str(),logfile);
} }
/* ----------------------------------------------------------------------
forward vararg version to single string version
------------------------------------------------------------------------- */
void Error::_message(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
message(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
message(file,line,e.what());
}
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
shutdown LAMMPS shutdown LAMMPS
called by all procs in one world called by all procs in one world

View File

@ -31,12 +31,13 @@ class Error : protected Pointers {
void universe_warn(const std::string &, int, const std::string &); void universe_warn(const std::string &, int, const std::string &);
[[ noreturn ]] void all(const std::string &, int, const std::string &); [[ noreturn ]] void all(const std::string &, int, const std::string &);
[[ noreturn ]] void one(const std::string &, int, const std::string &);
template <typename S, typename... Args> template <typename S, typename... Args>
void all(const std::string &file, int line, const S &format, void all(const std::string &file, int line, const S &format,
Args&&... args) { Args&&... args) {
_all(file, line, format, fmt::make_args_checked<Args...>(format, args...)); _all(file, line, format, fmt::make_args_checked<Args...>(format, args...));
} }
[[ noreturn ]] void one(const std::string &, int, const std::string &);
template <typename S, typename... Args> template <typename S, typename... Args>
void one(const std::string &file, int line, const S &format, void one(const std::string &file, int line, const S &format,
Args&&... args) { Args&&... args) {
@ -44,7 +45,16 @@ class Error : protected Pointers {
} }
void warning(const std::string &, int, const std::string &); void warning(const std::string &, int, const std::string &);
template <typename S, typename... Args>
void warning(const std::string &file, int line, const S &format, Args&&... args) {
_warning(file, line, format, fmt::make_args_checked<Args...>(format, args...));
}
void message(const std::string &, int, const std::string &); void message(const std::string &, int, const std::string &);
template <typename S, typename... Args>
void message(const std::string &file, int line, const S &format, Args&&... args) {
_message(file, line, format, fmt::make_args_checked<Args...>(format, args...));
}
[[ noreturn ]] void done(int = 0); // 1 would be fully backwards compatible [[ noreturn ]] void done(int = 0); // 1 would be fully backwards compatible
int get_numwarn() const { return numwarn; } int get_numwarn() const { return numwarn; }
@ -70,6 +80,8 @@ class Error : protected Pointers {
fmt::format_args args); fmt::format_args args);
[[ noreturn ]] void _one(const std::string &, int, fmt::string_view, [[ noreturn ]] void _one(const std::string &, int, fmt::string_view,
fmt::format_args args); fmt::format_args args);
void _warning(const std::string &, int, fmt::string_view, fmt::format_args args);
void _message(const std::string &, int, fmt::string_view, fmt::format_args args);
}; };
} }

View File

@ -336,7 +336,7 @@ double KSpace::estimate_table_accuracy(double q2_over_sqrt, double spr)
int nctb = force->pair->ncoultablebits; int nctb = force->pair->ncoultablebits;
if (comm->me == 0) { if (comm->me == 0) {
if (nctb) if (nctb)
error->message(FLERR,fmt::format(" using {}-bit tables for long-range coulomb",nctb)); error->message(FLERR," using {}-bit tables for long-range coulomb",nctb);
else else
error->message(FLERR," using polynomial approximation for long-range coulomb"); error->message(FLERR," using polynomial approximation for long-range coulomb");
} }

View File

@ -88,6 +88,5 @@ void NTopoAngleAll::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Angle atoms missing at step {}", error->warning(FLERR,"Angle atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -89,6 +89,5 @@ void NTopoAnglePartial::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Angle atoms missing at step {}", error->warning(FLERR,"Angle atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -109,6 +109,5 @@ void NTopoAngleTemplate::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Angle atoms missing at step {}", error->warning(FLERR,"Angle atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -81,6 +81,5 @@ void NTopoBondAll::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Bond atoms missing at step {}", error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -82,6 +82,5 @@ void NTopoBondPartial::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Bond atoms missing at step {}", error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -100,6 +100,5 @@ void NTopoBondTemplate::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Bond atoms missing at step {}", error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -94,6 +94,5 @@ void NTopoDihedralAll::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}", error->warning(FLERR,"Dihedral atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -96,6 +96,5 @@ void NTopoDihedralPartial::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}", error->warning(FLERR,"Dihedral atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -115,6 +115,5 @@ void NTopoDihedralTemplate::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}", error->warning(FLERR,"Dihedral atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -94,6 +94,5 @@ void NTopoImproperAll::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Improper atoms missing at step {}", error->warning(FLERR,"Improper atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -98,6 +98,5 @@ 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 && me == 0) if (all && me == 0)
error->warning(FLERR,fmt::format("Improper atoms missing at step {}", error->warning(FLERR,"Improper atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -115,6 +115,5 @@ void NTopoImproperTemplate::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 && (me == 0)) if (all && (me == 0))
error->warning(FLERR,fmt::format("Improper atoms missing at step {}", error->warning(FLERR,"Improper atoms missing at step {}",update->ntimestep);
update->ntimestep));
} }

View File

@ -458,25 +458,23 @@ void PairTable::read_table(Table *tb, char *file, char *keyword)
} }
if (ferror) if (ferror)
error->warning(FLERR,fmt::format("{} of {} force values in table {} are " error->warning(FLERR,"{} of {} force values in table {} are inconsistent "
"inconsistent with -dE/dr.\n Should " "with -dE/dr.\nWARNING: Should only be flagged at "
"only be flagged at inflection points", "inflection points",ferror,tb->ninput,keyword);
ferror,tb->ninput,keyword));
// warn if re-computed distance values differ from file values // warn if re-computed distance values differ from file values
if (rerror) if (rerror)
error->warning(FLERR,fmt::format("{} of {} distance values in table {} " error->warning(FLERR,"{} of {} distance values in table {} with relative "
"with relative error\n over {} to " "error\nWARNING: over {} to re-computed values",
"re-computed values", rerror,tb->ninput,EPSILONR,keyword);
rerror,tb->ninput,EPSILONR,keyword));
// warn if data was read incompletely, e.g. columns were missing // warn if data was read incompletely, e.g. columns were missing
if (cerror) if (cerror)
error->warning(FLERR,fmt::format("{} of {} lines in table {} were " error->warning(FLERR,"{} of {} lines in table {} were incomplete\n"
"incomplete\n or could not be parsed " "WARNING: or could not be parsed completely",
"completely",cerror,tb->ninput,keyword)); cerror,tb->ninput,keyword);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -275,8 +275,8 @@ TextFileReader *PotentialFileReader::open_potential(const std::string &path) {
} }
} }
if (unit_convert != utils::NOCONVERT) if (unit_convert != utils::NOCONVERT)
lmp->error->warning(FLERR, fmt::format("Converting {} in {} units to {} " lmp->error->warning(FLERR, "Converting {} in {} units to {} units",
"units", filetype, units, unit_style)); filetype, units, unit_style);
return new TextFileReader(filepath, filetype); return new TextFileReader(filepath, filetype);
} }
return nullptr; return nullptr;

View File

@ -694,9 +694,8 @@ void ReadRestart::header()
} else if (flag == NPROCS) { } else if (flag == NPROCS) {
nprocs_file = read_int(); nprocs_file = read_int();
if (nprocs_file != comm->nprocs && me == 0) if (nprocs_file != comm->nprocs && me == 0)
error->warning(FLERR,fmt::format("Restart file used different # of " error->warning(FLERR,"Restart file used different # of processors: "
"processors: {} vs. {}",nprocs_file, "{} vs. {}",nprocs_file,comm->nprocs);
comm->nprocs));
// don't set procgrid, warn if different // don't set procgrid, warn if different

View File

@ -419,9 +419,8 @@ bigint Thermo::lost_check()
if ((maxwarn > 0) && (warnbefore == 0) && (ntotal[1] > maxwarn)) { if ((maxwarn > 0) && (warnbefore == 0) && (ntotal[1] > maxwarn)) {
warnbefore = 1; warnbefore = 1;
if (comm->me == 0) if (comm->me == 0)
error->message(FLERR,fmt::format("WARNING: Too many warnings: {} vs {}. All " error->message(FLERR,"WARNING: Too many warnings: {} vs {}. All "
"future warnings will be suppressed", "future warnings will be suppressed",ntotal[1],maxwarn);
ntotal[1],maxwarn));
} }
error->set_allwarn(ntotal[1]); error->set_allwarn(ntotal[1]);
@ -438,13 +437,13 @@ bigint Thermo::lost_check()
if (lostflag == Thermo::ERROR) if (lostflag == Thermo::ERROR)
error->all(FLERR,"Lost atoms: original {} current {}", error->all(FLERR,"Lost atoms: original {} current {}",
atom->natoms,ntotal[0]); atom->natoms,ntotal[0]);
// warning message // warning message
if (me == 0) if (me == 0)
error->warning(FLERR,fmt::format("Lost atoms: original {} current {}", error->warning(FLERR,"Lost atoms: original {} current {}",
atom->natoms,ntotal[0])); atom->natoms,ntotal[0]);
// reset total atom count // reset total atom count

View File

@ -305,9 +305,8 @@ void Update::set_units(const char *style)
// check if timestep was changed from default value // check if timestep was changed from default value
if (!dt_default && (comm->me == 0)) { if (!dt_default && (comm->me == 0)) {
error->warning(FLERR,fmt::format("Changing timestep from {:.6} to {:.6} " error->warning(FLERR,"Changing timestep from {:.6} to {:.6} due to "
"due to changing units to {}", "changing units to {}", dt_old, dt, unit_style);
dt_old, dt, unit_style));
} }
dt_default = 1; dt_default = 1;
} }

View File

@ -1200,16 +1200,14 @@ FILE *utils::open_potential(const std::string &name, LAMMPS *lmp,
&& (*auto_convert & REAL2METAL)) { && (*auto_convert & REAL2METAL)) {
*auto_convert = REAL2METAL; *auto_convert = REAL2METAL;
} else { } else {
error->one(FLERR, "Potential file {} requires {} units " error->one(FLERR, "Potential file {} requires {} units but {} units "
"but {} units are in use", name, "are in use", name, units, unit_style);
units, unit_style);
return nullptr; return nullptr;
} }
} }
if ((*auto_convert != NOCONVERT) && (me == 0)) if ((*auto_convert != NOCONVERT) && (me == 0))
error->warning(FLERR, fmt::format("Converting potential file in " error->warning(FLERR, "Converting potential file in {} units to {} "
"{} units to {} units", "units", units, unit_style);
units, unit_style));
} }
return fopen(filepath.c_str(), "r"); return fopen(filepath.c_str(), "r");
} }