diff --git a/src/COMPRESS/dump_atom_gz.cpp b/src/COMPRESS/dump_atom_gz.cpp index 73f1ddf5a2..d4edb07a3a 100644 --- a/src/COMPRESS/dump_atom_gz.cpp +++ b/src/COMPRESS/dump_atom_gz.cpp @@ -72,7 +72,7 @@ void DumpAtomGZ::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/COMPRESS/dump_atom_zstd.cpp b/src/COMPRESS/dump_atom_zstd.cpp index 430deda177..561c784739 100644 --- a/src/COMPRESS/dump_atom_zstd.cpp +++ b/src/COMPRESS/dump_atom_zstd.cpp @@ -80,7 +80,7 @@ void DumpAtomZstd::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/COMPRESS/dump_cfg_gz.cpp b/src/COMPRESS/dump_cfg_gz.cpp index 25328797dd..277db7dd23 100644 --- a/src/COMPRESS/dump_cfg_gz.cpp +++ b/src/COMPRESS/dump_cfg_gz.cpp @@ -74,7 +74,7 @@ void DumpCFGGZ::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/COMPRESS/dump_cfg_zstd.cpp b/src/COMPRESS/dump_cfg_zstd.cpp index 0ea92f3807..defee75ee8 100644 --- a/src/COMPRESS/dump_cfg_zstd.cpp +++ b/src/COMPRESS/dump_cfg_zstd.cpp @@ -82,7 +82,7 @@ void DumpCFGZstd::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/COMPRESS/dump_custom_gz.cpp b/src/COMPRESS/dump_custom_gz.cpp index 9ed5a10b02..844cfac1c3 100644 --- a/src/COMPRESS/dump_custom_gz.cpp +++ b/src/COMPRESS/dump_custom_gz.cpp @@ -72,7 +72,7 @@ void DumpCustomGZ::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/COMPRESS/dump_custom_zstd.cpp b/src/COMPRESS/dump_custom_zstd.cpp index 073e39a87e..d097b29ad1 100644 --- a/src/COMPRESS/dump_custom_zstd.cpp +++ b/src/COMPRESS/dump_custom_zstd.cpp @@ -79,7 +79,7 @@ void DumpCustomZstd::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/COMPRESS/dump_local_gz.cpp b/src/COMPRESS/dump_local_gz.cpp index 9c6c06e65a..6af26fd944 100644 --- a/src/COMPRESS/dump_local_gz.cpp +++ b/src/COMPRESS/dump_local_gz.cpp @@ -72,7 +72,7 @@ void DumpLocalGZ::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/COMPRESS/dump_local_zstd.cpp b/src/COMPRESS/dump_local_zstd.cpp index f20dc5016c..ec00800e37 100644 --- a/src/COMPRESS/dump_local_zstd.cpp +++ b/src/COMPRESS/dump_local_zstd.cpp @@ -79,7 +79,7 @@ void DumpLocalZstd::openfile() ++numfiles; } else { 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]; nameslist[fileidx] = utils::strdup(filecurrent); diff --git a/src/KSPACE/ewald_disp.cpp b/src/KSPACE/ewald_disp.cpp index 927485ef84..620d371b1f 100644 --- a/src/KSPACE/ewald_disp.cpp +++ b/src/KSPACE/ewald_disp.cpp @@ -213,11 +213,10 @@ void EwaldDisp::init() error->all(FLERR,"Cannot (yet) use 'electron' units with dipoles"); if (qsqsum == 0.0 && bsbsum == 0.0 && M2 == 0.0) - error->all(FLERR,"Cannot use Ewald/disp solver " - "on system with no charge, dipole, or LJ particles"); + error->all(FLERR,"Cannot use Ewald/disp solver on system without " + "charged, dipole, or LJ particles"); if (fabs(qsum) > SMALL && comm->me == 0) - error->warning(FLERR,fmt::format("System is not charge neutral, " - "net charge = {:.8g}",qsum)); + error->warning(FLERR,"System is not charge neutral, net charge = {:.8g}",qsum); if (!function[1] && !function[2]) dispersionflag = 0; if (!function[3]) dipoleflag = 0; diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index 490fbae0e0..bbd4b01a68 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -1085,8 +1085,8 @@ void MSM::set_grid_global() *p_cutoff = cutoff; if (me == 0) - error->warning(FLERR,fmt::format("Adjusting Coulombic cutoff for " - "MSM, new cutoff = {:.8}", cutoff)); + error->warning(FLERR,"Adjusting Coulombic cutoff for " + "MSM, new cutoff = {:.8}", cutoff); } if (triclinic == 0) { diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index eba653e7d7..a912cf9a45 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1362,8 +1362,8 @@ void PPPMDisp::init_coeffs() err = bmax/amax; if (err > 1.0e-4 && comm->me == 0) - error->warning(FLERR,fmt::format("Estimated error in splitting of " - "dispersion coeffs is {}",err)); + error->warning(FLERR,"Estimated error in splitting of " + "dispersion coeffs is {}",err); // set B B = new double[nsplit*n+nsplit]; diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index 7aa7b69ecf..13eef1d2b4 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -287,8 +287,8 @@ void FixDeposit::init() double separation = MAX(2.0*maxradinsert,maxradall+maxradinsert); if (sqrt(nearsq) < separation && comm->me == 0) - error->warning(FLERR,fmt::format("Fix deposit near setting < possible " - "overlap separation {}",separation)); + error->warning(FLERR,"Fix deposit near setting < possible " + "overlap separation {}",separation); } } diff --git a/src/MOLECULE/bond_fene.cpp b/src/MOLECULE/bond_fene.cpp index 4607e6ebb1..a81ad34e69 100644 --- a/src/MOLECULE/bond_fene.cpp +++ b/src/MOLECULE/bond_fene.cpp @@ -85,8 +85,8 @@ void BondFENE::compute(int eflag, int vflag) // if r > 2*r0 something serious is wrong, abort if (rlogarg < 0.1) { - error->warning(FLERR,fmt::format("FENE bond too long: {} {} {} {}", - update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq))); + error->warning(FLERR,"FENE bond too long: {} {} {} {}", + update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq)); if (rlogarg <= -3.0) error->one(FLERR,"Bad FENE bond"); rlogarg = 0.1; } diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp index af5eb36bf9..a0bbcdb512 100644 --- a/src/MOLECULE/bond_table.cpp +++ b/src/MOLECULE/bond_table.cpp @@ -378,15 +378,15 @@ void BondTable::read_table(Table *tb, char *file, char *keyword) } if (ferror) { - error->warning(FLERR, fmt::format("{} of {} force values in table are inconsistent with -dE/dr.\n" - " Should only be flagged at inflection points",ferror,tb->ninput)); + error->warning(FLERR, "{} of {} force values in table are inconsistent with -dE/dr.\n" + "WARNING: Should only be flagged at inflection points",ferror,tb->ninput); } // warn if data was read incompletely, e.g. columns were missing if (cerror) { - error->warning(FLERR, fmt::format("{} of {} lines in table were incomplete or could not be" - " parsed completely",cerror,tb->ninput)); + error->warning(FLERR, "{} of {} lines in table were incomplete or could not be" + " parsed completely",cerror,tb->ninput); } } diff --git a/src/PLUGIN/plugin.cpp b/src/PLUGIN/plugin.cpp index 4434b28d16..1650284747 100644 --- a/src/PLUGIN/plugin.cpp +++ b/src/PLUGIN/plugin.cpp @@ -171,9 +171,8 @@ namespace LAMMPS_NS auto pair_map = lmp->force->pair_map; if (pair_map->find(plugin->name) != pair_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in pair " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in pair " + "style {} from plugin",plugin->name); } (*pair_map)[plugin->name] = (Force::PairCreator)plugin->creator.v1; @@ -181,9 +180,8 @@ namespace LAMMPS_NS auto bond_map = lmp->force->bond_map; if (bond_map->find(plugin->name) != bond_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in bond " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in bond " + "style {} from plugin",plugin->name); } (*bond_map)[plugin->name] = (Force::BondCreator)plugin->creator.v1; @@ -191,9 +189,8 @@ namespace LAMMPS_NS auto angle_map = lmp->force->angle_map; if (angle_map->find(plugin->name) != angle_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in angle " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in angle " + "style {} from plugin",plugin->name); } (*angle_map)[plugin->name] = (Force::AngleCreator)plugin->creator.v1; @@ -201,9 +198,8 @@ namespace LAMMPS_NS auto dihedral_map = lmp->force->dihedral_map; if (dihedral_map->find(plugin->name) != dihedral_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in dihedral " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in dihedral " + "style {} from plugin",plugin->name); } (*dihedral_map)[plugin->name] = (Force::DihedralCreator)plugin->creator.v1; @@ -211,9 +207,8 @@ namespace LAMMPS_NS auto improper_map = lmp->force->improper_map; if (improper_map->find(plugin->name) != improper_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in improper " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in improper " + "style {} from plugin",plugin->name); } (*improper_map)[plugin->name] = (Force::ImproperCreator)plugin->creator.v1; @@ -221,9 +216,8 @@ namespace LAMMPS_NS auto compute_map = lmp->modify->compute_map; if (compute_map->find(plugin->name) != compute_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in compute " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in compute " + "style {} from plugin",plugin->name); } (*compute_map)[plugin->name] = (Modify::ComputeCreator)plugin->creator.v2; @@ -231,9 +225,8 @@ namespace LAMMPS_NS auto fix_map = lmp->modify->fix_map; if (fix_map->find(plugin->name) != fix_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in fix " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in fix " + "style {} from plugin",plugin->name); } (*fix_map)[plugin->name] = (Modify::FixCreator)plugin->creator.v2; @@ -241,9 +234,8 @@ namespace LAMMPS_NS auto region_map = lmp->domain->region_map; if (region_map->find(plugin->name) != region_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in region " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in region " + "style {} from plugin",plugin->name); } (*region_map)[plugin->name] = (Domain::RegionCreator)plugin->creator.v2; @@ -251,9 +243,8 @@ namespace LAMMPS_NS auto command_map = lmp->input->command_map; if (command_map->find(plugin->name) != command_map->end()) { if (lmp->comm->me == 0) - lmp->error->warning(FLERR,fmt::format("Overriding built-in command " - "style {} from plugin", - plugin->name)); + lmp->error->warning(FLERR,"Overriding built-in command " + "style {} from plugin",plugin->name); } (*command_map)[plugin->name] = (Input::CommandCreator)plugin->creator.v1; diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index fe6948c6a0..bca2914b82 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -387,10 +387,9 @@ int FixQEq::CG( double *b, double *x ) } if ((comm->me == 0) && (loop >= maxiter)) - error->warning(FLERR,fmt::format("Fix qeq CG convergence failed ({}) " - "after {} iterations at step {}", - sqrt(sig_new)/b_norm,loop, - update->ntimestep)); + error->warning(FLERR,"Fix qeq CG convergence failed ({}) after {} " + "iterations at step {}",sqrt(sig_new)/b_norm,loop, + update->ntimestep); return loop; } diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index 397393b786..84ad081cdc 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -155,8 +155,8 @@ void FixQEqDynamic::pre_force(int /*vflag*/) } if ((comm->me == 0) && (iloop >= maxiter)) - error->warning(FLERR,fmt::format("Charges did not converge at step " - "{}: {}",update->ntimestep,enegchk)); + error->warning(FLERR,"Charges did not converge at step {}: {}", + update->ntimestep,enegchk); if (force->kspace) force->kspace->qsum_qsq(); } diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 0bdf65dc18..3860e775d4 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -215,8 +215,8 @@ void FixQEqFire::pre_force(int /*vflag*/) } if ((comm->me == 0) && (iloop >= maxiter)) - error->warning(FLERR,fmt::format("Charges did not converge at step " - "{}: {}",update->ntimestep,enegchk)); + error->warning(FLERR,"Charges did not converge at step {}: {}", + update->ntimestep,enegchk); if (force->kspace) force->kspace->qsum_qsq(); } diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index e8f251856d..24ce241670 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -697,8 +697,8 @@ void FixRigid::init() if (modify->fix[i]->rigid_flag) rflag = 1; if (rflag && (modify->fmask[i] & POST_FORCE) && !modify->fix[i]->rigid_flag) - error->warning(FLERR,fmt::format("Fix {} alters forces after fix " - "rigid",modify->fix[i]->id)); + error->warning(FLERR,"Fix {} alters forces after fix rigid", + modify->fix[i]->id); } } diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 05856dc3fa..60348fb5ce 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -548,8 +548,8 @@ void FixRigidSmall::init() if (modify->fix[i]->rigid_flag) rflag = 1; if (rflag && (modify->fmask[i] & POST_FORCE) && !modify->fix[i]->rigid_flag) - error->warning(FLERR,fmt::format("Fix {} alters forces after fix " - "rigid",modify->fix[i]->id)); + error->warning(FLERR,"Fix {} alters forces after fix rigid", + modify->fix[i]->id); } } diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index 20c2a9dfe8..da0ea3658b 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -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 // foregoing reading with getline 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. @@ -645,7 +645,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) numEntries = inputLines.size(); 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); if (test_sscanf == 2) { - //if (comm->me == 0) { - // error->message(FLERR, fmt::format("INFO: f1 = {}, f2 = {}", f1, f2)); - //} data[VOLUME][i] = (double)f1; data[PRESSURE_CORRECTION][i] = (double)f2; if (i == 1) { // second entry is used to compute the validation interval used below 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) { // after second entry, all intervals are validated 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 (comm->me == 0) { - message = fmt::format("Bad volume interval. Spline analysis requires uniform" - " volume distribution, found inconsistent volume" - " differential, line {} of file {}\n\tline: {}", - lineNum, filename, inputLines.at(i)); - error->warning(FLERR, message); - } + if (comm->me == 0) + error->warning(FLERR,"Bad volume interval. Spline analysis requires uniform" + " volume distribution, found inconsistent volume" + " differential, line {} of file {}\nWARNING:\tline: {}", + lineNum, filename, inputLines.at(i)); badInput = true; numBadVolumeIntervals++; } @@ -706,12 +695,10 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) } else { - if (comm->me == 0) { - message = fmt::format("Bad input format: did not find 2 comma separated numeric" - " values in line {} of file {}\n\tline: {}", - lineNum, filename, inputLines.at(i)); - error->warning(FLERR, message); - } + if (comm->me == 0) + error->warning(FLERR,"Bad input format: did not find 2 comma separated numeric" + " values in line {} of file {}\nWARNING:\tline: {}", + lineNum, filename, inputLines.at(i)); badInput = true; } if (badInput) @@ -721,7 +708,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) } 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 { @@ -729,7 +716,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) } 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) @@ -752,9 +739,6 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) } 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[VOLUME] = (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) { - 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; @@ -774,9 +758,6 @@ int FixBocs::build_linear_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; double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z; // 2020-07-17 ag: @@ -867,7 +848,7 @@ int FixBocs::build_cubic_splines(double **data) memory->destroy(z); 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 diff --git a/src/USER-MESONT/pair_mesocnt.cpp b/src/USER-MESONT/pair_mesocnt.cpp index 3a56c69d2d..cff99395ff 100644 --- a/src/USER-MESONT/pair_mesocnt.cpp +++ b/src/USER-MESONT/pair_mesocnt.cpp @@ -920,20 +920,17 @@ void PairMesoCNT::read_data(FILE *fp, double **data, // warn if data was read incompletely, e.g. columns were missing if (cerror) - error->warning(FLERR,fmt::format("{} of {} lines were incomplete or could " - "not be parsed completely in pair table: {}", - cerror,ninput*ninput,file)); + error->warning(FLERR,"{} of {} lines were incomplete or could not be parsed " + "completely in pair table: {}",cerror,ninput*ninput,file); // warn if spacing between data points is not constant if (sxerror) - error->warning(FLERR,fmt::format("{} spacings in first column were different " - " from first spacing in pair table: {}", - sxerror,file)); + error->warning(FLERR,"{} spacings in first column were different from " + "first spacing in pair table: {}",sxerror,file); if (syerror) - error->warning(FLERR,fmt::format("{} spacings in second column were different " - " from first spacing in pair table: {}", - syerror,file)); + error->warning(FLERR,"{} spacings in second column were different from " + "first spacing in pair table: {}",syerror,file); } /* ---------------------------------------------------------------------- diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index 7acaf90e4f..ec5cfaad06 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -349,8 +349,7 @@ void PairAGNI::read_file(char *filename) params[curparam].gwidth = 0.0; wantdata = curparam; curparam = -1; - } else error->warning(FLERR,fmt::format("Ignoring unknown tag '{}' " - "in AGNI potential file.",tag)); + } else error->warning(FLERR,"Ignoring unknown tag '{}' in AGNI potential file.",tag); } else { if (params && wantdata >=0) { if ((int)values.count() == params[wantdata].numeta + 2) { diff --git a/src/change_box.cpp b/src/change_box.cpp index 78f1261caf..d57ce3e640 100644 --- a/src/change_box.cpp +++ b/src/change_box.cpp @@ -389,9 +389,8 @@ void ChangeBox::command(int narg, char **arg) bigint nblocal = atom->nlocal; MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); if (natoms != atom->natoms && comm->me == 0) - error->warning(FLERR,fmt::format("Lost atoms via change_box: " - "original {} current {}", - atom->natoms,natoms)); + error->warning(FLERR,"Lost atoms via change_box: original {} " + "current {}", atom->natoms,natoms); } /* ---------------------------------------------------------------------- diff --git a/src/comm.cpp b/src/comm.cpp index 50d20ac7bb..ec56bbe28d 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -655,18 +655,16 @@ double Comm::get_comm_cutoff() maxcommcutoff = MAX(maxcommcutoff,maxbondcutoff); } else { if ((me == 0) && (maxbondcutoff > maxcommcutoff)) - error->warning(FLERR,fmt::format("Communication cutoff {} is shorter " - "than a bond length based estimate of " - "{}. This may lead to errors.", - maxcommcutoff,maxbondcutoff)); + error->warning(FLERR,"Communication cutoff {} is shorter than a bond " + "length based estimate of {}. This may lead to errors.", + maxcommcutoff,maxbondcutoff); } // print warning if neighborlist cutoff overrides user cutoff if ((me == 0) && (update->setupflag == 1)) { if ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser)) - error->warning(FLERR,fmt::format("Communication cutoff adjusted to {}", - maxcommcutoff)); + error->warning(FLERR,"Communication cutoff adjusted to {}",maxcommcutoff); } return maxcommcutoff; diff --git a/src/compute_cna_atom.cpp b/src/compute_cna_atom.cpp index 5288504a4f..318450e2b7 100644 --- a/src/compute_cna_atom.cpp +++ b/src/compute_cna_atom.cpp @@ -186,8 +186,7 @@ void ComputeCNAAtom::compute_peratom() int nerrorall; MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world); if (nerrorall && comm->me == 0) - error->warning(FLERR,fmt::format("Too many neighbors in CNA for {} " - "atoms",nerrorall)); + error->warning(FLERR,"Too many neighbors in CNA for {} atoms",nerrorall); // compute CNA for each atom in group // 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); if (nerrorall && comm->me == 0) - error->warning(FLERR,fmt::format("Too many common neighbors in CNA {} " - "times", nerrorall)); + error->warning(FLERR,"Too many common neighbors in CNA: {}x", nerrorall); } /* ---------------------------------------------------------------------- diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp index 6bc3b0ab35..a8d55b8011 100644 --- a/src/displace_atoms.cpp +++ b/src/displace_atoms.cpp @@ -354,9 +354,8 @@ void DisplaceAtoms::command(int narg, char **arg) bigint nblocal = atom->nlocal; MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); if (natoms != atom->natoms && comm->me == 0) - error->warning(FLERR,fmt::format("Lost atoms via displace_atoms: " - "original {} current {}", - atom->natoms,natoms)); + error->warning(FLERR,"Lost atoms via displace_atoms: original {} " + "current {}",atom->natoms,natoms); } /* ---------------------------------------------------------------------- diff --git a/src/error.cpp b/src/error.cpp index 5d9061b7ce..660acf775b 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -258,6 +258,20 @@ void Error::warning(const std::string &file, int line, const std::string &str) 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 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); } +/* ---------------------------------------------------------------------- + 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 called by all procs in one world diff --git a/src/error.h b/src/error.h index c39f5d07c9..fb82b05b34 100644 --- a/src/error.h +++ b/src/error.h @@ -31,12 +31,13 @@ class Error : protected Pointers { void universe_warn(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 void all(const std::string &file, int line, const S &format, Args&&... args) { _all(file, line, format, fmt::make_args_checked(format, args...)); } + + [[ noreturn ]] void one(const std::string &, int, const std::string &); template void one(const std::string &file, int line, const S &format, Args&&... args) { @@ -44,7 +45,16 @@ class Error : protected Pointers { } void warning(const std::string &, int, const std::string &); + template + void warning(const std::string &file, int line, const S &format, Args&&... args) { + _warning(file, line, format, fmt::make_args_checked(format, args...)); + } + void message(const std::string &, int, const std::string &); + template + void message(const std::string &file, int line, const S &format, Args&&... args) { + _message(file, line, format, fmt::make_args_checked(format, args...)); + } [[ noreturn ]] void done(int = 0); // 1 would be fully backwards compatible int get_numwarn() const { return numwarn; } @@ -70,6 +80,8 @@ class Error : protected Pointers { fmt::format_args args); [[ noreturn ]] void _one(const std::string &, int, fmt::string_view, 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); }; } diff --git a/src/kspace.cpp b/src/kspace.cpp index f44cc42aaf..fa7e68d90e 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -336,7 +336,7 @@ double KSpace::estimate_table_accuracy(double q2_over_sqrt, double spr) int nctb = force->pair->ncoultablebits; if (comm->me == 0) { 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 error->message(FLERR," using polynomial approximation for long-range coulomb"); } diff --git a/src/ntopo_angle_all.cpp b/src/ntopo_angle_all.cpp index b7811052df..c8187c0469 100644 --- a/src/ntopo_angle_all.cpp +++ b/src/ntopo_angle_all.cpp @@ -88,6 +88,5 @@ void NTopoAngleAll::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Angle atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Angle atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_angle_partial.cpp b/src/ntopo_angle_partial.cpp index 543658f19f..1dea896758 100644 --- a/src/ntopo_angle_partial.cpp +++ b/src/ntopo_angle_partial.cpp @@ -89,6 +89,5 @@ void NTopoAnglePartial::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Angle atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Angle atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_angle_template.cpp b/src/ntopo_angle_template.cpp index ad09979a7a..ede8c398dc 100644 --- a/src/ntopo_angle_template.cpp +++ b/src/ntopo_angle_template.cpp @@ -109,6 +109,5 @@ void NTopoAngleTemplate::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Angle atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Angle atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_bond_all.cpp b/src/ntopo_bond_all.cpp index 578f98ec81..02d44f090c 100644 --- a/src/ntopo_bond_all.cpp +++ b/src/ntopo_bond_all.cpp @@ -81,6 +81,5 @@ void NTopoBondAll::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Bond atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_bond_partial.cpp b/src/ntopo_bond_partial.cpp index 8d077106db..c5afe08630 100644 --- a/src/ntopo_bond_partial.cpp +++ b/src/ntopo_bond_partial.cpp @@ -82,6 +82,5 @@ void NTopoBondPartial::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Bond atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_bond_template.cpp b/src/ntopo_bond_template.cpp index 887ac3aa81..45297fc92c 100644 --- a/src/ntopo_bond_template.cpp +++ b/src/ntopo_bond_template.cpp @@ -100,6 +100,5 @@ void NTopoBondTemplate::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Bond atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_dihedral_all.cpp b/src/ntopo_dihedral_all.cpp index b77e0cc33f..cbe2e46e5c 100644 --- a/src/ntopo_dihedral_all.cpp +++ b/src/ntopo_dihedral_all.cpp @@ -94,6 +94,5 @@ void NTopoDihedralAll::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Dihedral atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_dihedral_partial.cpp b/src/ntopo_dihedral_partial.cpp index 980f073b67..c8a1f22100 100644 --- a/src/ntopo_dihedral_partial.cpp +++ b/src/ntopo_dihedral_partial.cpp @@ -96,6 +96,5 @@ void NTopoDihedralPartial::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Dihedral atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_dihedral_template.cpp b/src/ntopo_dihedral_template.cpp index 5c6f3d333f..564e7aca69 100644 --- a/src/ntopo_dihedral_template.cpp +++ b/src/ntopo_dihedral_template.cpp @@ -115,6 +115,5 @@ void NTopoDihedralTemplate::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Dihedral atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_improper_all.cpp b/src/ntopo_improper_all.cpp index 936ed279d7..52f323b735 100644 --- a/src/ntopo_improper_all.cpp +++ b/src/ntopo_improper_all.cpp @@ -94,6 +94,5 @@ void NTopoImproperAll::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Improper atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Improper atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_improper_partial.cpp b/src/ntopo_improper_partial.cpp index 911e968326..76d31061b7 100644 --- a/src/ntopo_improper_partial.cpp +++ b/src/ntopo_improper_partial.cpp @@ -98,6 +98,5 @@ void NTopoImproperPartial::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && me == 0) - error->warning(FLERR,fmt::format("Improper atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Improper atoms missing at step {}",update->ntimestep); } diff --git a/src/ntopo_improper_template.cpp b/src/ntopo_improper_template.cpp index 68cbebd40e..7fd2f3352e 100644 --- a/src/ntopo_improper_template.cpp +++ b/src/ntopo_improper_template.cpp @@ -115,6 +115,5 @@ void NTopoImproperTemplate::build() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); if (all && (me == 0)) - error->warning(FLERR,fmt::format("Improper atoms missing at step {}", - update->ntimestep)); + error->warning(FLERR,"Improper atoms missing at step {}",update->ntimestep); } diff --git a/src/pair_table.cpp b/src/pair_table.cpp index 3c9b51e3f2..17bd222ca0 100644 --- a/src/pair_table.cpp +++ b/src/pair_table.cpp @@ -458,25 +458,23 @@ void PairTable::read_table(Table *tb, char *file, char *keyword) } if (ferror) - error->warning(FLERR,fmt::format("{} of {} force values in table {} are " - "inconsistent with -dE/dr.\n Should " - "only be flagged at inflection points", - ferror,tb->ninput,keyword)); + error->warning(FLERR,"{} of {} force values in table {} are inconsistent " + "with -dE/dr.\nWARNING: Should only be flagged at " + "inflection points",ferror,tb->ninput,keyword); // warn if re-computed distance values differ from file values if (rerror) - error->warning(FLERR,fmt::format("{} of {} distance values in table {} " - "with relative error\n over {} to " - "re-computed values", - rerror,tb->ninput,EPSILONR,keyword)); + error->warning(FLERR,"{} of {} distance values in table {} with relative " + "error\nWARNING: over {} to re-computed values", + rerror,tb->ninput,EPSILONR,keyword); // warn if data was read incompletely, e.g. columns were missing if (cerror) - error->warning(FLERR,fmt::format("{} of {} lines in table {} were " - "incomplete\n or could not be parsed " - "completely",cerror,tb->ninput,keyword)); + error->warning(FLERR,"{} of {} lines in table {} were incomplete\n" + "WARNING: or could not be parsed completely", + cerror,tb->ninput,keyword); } /* ---------------------------------------------------------------------- diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp index 3d357771c7..a299eb32fc 100644 --- a/src/potential_file_reader.cpp +++ b/src/potential_file_reader.cpp @@ -275,8 +275,8 @@ TextFileReader *PotentialFileReader::open_potential(const std::string &path) { } } if (unit_convert != utils::NOCONVERT) - lmp->error->warning(FLERR, fmt::format("Converting {} in {} units to {} " - "units", filetype, units, unit_style)); + lmp->error->warning(FLERR, "Converting {} in {} units to {} units", + filetype, units, unit_style); return new TextFileReader(filepath, filetype); } return nullptr; diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 7edc0bc006..8518aca724 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -694,9 +694,8 @@ void ReadRestart::header() } else if (flag == NPROCS) { nprocs_file = read_int(); if (nprocs_file != comm->nprocs && me == 0) - error->warning(FLERR,fmt::format("Restart file used different # of " - "processors: {} vs. {}",nprocs_file, - comm->nprocs)); + error->warning(FLERR,"Restart file used different # of processors: " + "{} vs. {}",nprocs_file,comm->nprocs); // don't set procgrid, warn if different diff --git a/src/thermo.cpp b/src/thermo.cpp index ce448efdc5..9a543446a9 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -419,9 +419,8 @@ bigint Thermo::lost_check() if ((maxwarn > 0) && (warnbefore == 0) && (ntotal[1] > maxwarn)) { warnbefore = 1; if (comm->me == 0) - error->message(FLERR,fmt::format("WARNING: Too many warnings: {} vs {}. All " - "future warnings will be suppressed", - ntotal[1],maxwarn)); + error->message(FLERR,"WARNING: Too many warnings: {} vs {}. All " + "future warnings will be suppressed",ntotal[1],maxwarn); } error->set_allwarn(ntotal[1]); @@ -438,13 +437,13 @@ bigint Thermo::lost_check() if (lostflag == Thermo::ERROR) error->all(FLERR,"Lost atoms: original {} current {}", - atom->natoms,ntotal[0]); + atom->natoms,ntotal[0]); // warning message if (me == 0) - error->warning(FLERR,fmt::format("Lost atoms: original {} current {}", - atom->natoms,ntotal[0])); + error->warning(FLERR,"Lost atoms: original {} current {}", + atom->natoms,ntotal[0]); // reset total atom count diff --git a/src/update.cpp b/src/update.cpp index 1f78e48bb3..542e272cb3 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -305,9 +305,8 @@ void Update::set_units(const char *style) // check if timestep was changed from default value if (!dt_default && (comm->me == 0)) { - error->warning(FLERR,fmt::format("Changing timestep from {:.6} to {:.6} " - "due to changing units to {}", - dt_old, dt, unit_style)); + error->warning(FLERR,"Changing timestep from {:.6} to {:.6} due to " + "changing units to {}", dt_old, dt, unit_style); } dt_default = 1; } diff --git a/src/utils.cpp b/src/utils.cpp index edb9e0e4da..dc9ee453db 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1200,16 +1200,14 @@ FILE *utils::open_potential(const std::string &name, LAMMPS *lmp, && (*auto_convert & REAL2METAL)) { *auto_convert = REAL2METAL; } else { - error->one(FLERR, "Potential file {} requires {} units " - "but {} units are in use", name, - units, unit_style); + error->one(FLERR, "Potential file {} requires {} units but {} units " + "are in use", name, units, unit_style); return nullptr; } } if ((*auto_convert != NOCONVERT) && (me == 0)) - error->warning(FLERR, fmt::format("Converting potential file in " - "{} units to {} units", - units, unit_style)); + error->warning(FLERR, "Converting potential file in {} units to {} " + "units", units, unit_style); } return fopen(filepath.c_str(), "r"); }