remove redundant calls to fmt::format() from calls to error->one/all() and utils::logmesg()

This commit is contained in:
Axel Kohlmeyer
2023-09-26 23:56:51 -04:00
parent 6115edefcb
commit 5a455c5e3a
19 changed files with 57 additions and 70 deletions

View File

@ -84,7 +84,7 @@ void ElectrodeMatrix::compute_array(double **array, bool timer_flag)
electrode_kspace->compute_matrix(&mpos[0], array, timer_flag); electrode_kspace->compute_matrix(&mpos[0], array, timer_flag);
MPI_Barrier(world); MPI_Barrier(world);
if (timer_flag && (comm->me == 0)) if (timer_flag && (comm->me == 0))
utils::logmesg(lmp, fmt::format("KSpace time: {:.4g} s\n", MPI_Wtime() - kspace_time)); utils::logmesg(lmp, "KSpace time: {:.4g} s\n", MPI_Wtime() - kspace_time);
//cout << array[0][0] << ", " << array[0][1] << endl; //cout << array[0][0] << ", " << array[0][1] << endl;
pair_contribution(array); pair_contribution(array);
//cout << array[0][0] << ", " << array[0][1] << endl; //cout << array[0][0] << ", " << array[0][1] << endl;

View File

@ -60,10 +60,10 @@ ElectrodeVector::~ElectrodeVector()
{ {
if (timer_flag && (comm->me == 0)) { if (timer_flag && (comm->me == 0)) {
try { try {
utils::logmesg(lmp, fmt::format("B time: {:.4g} s\n", b_time_total)); utils::logmesg(lmp, "B time: {:.4g} s\n", b_time_total);
utils::logmesg(lmp, fmt::format("B kspace time: {:.4g} s\n", kspace_time_total)); utils::logmesg(lmp, "B kspace time: {:.4g} s\n", kspace_time_total);
utils::logmesg(lmp, fmt::format("B pair time: {:.4g} s\n", pair_time_total)); utils::logmesg(lmp, "B pair time: {:.4g} s\n", pair_time_total);
utils::logmesg(lmp, fmt::format("B boundary time: {:.4g} s\n", boundary_time_total)); utils::logmesg(lmp, "B boundary time: {:.4g} s\n", boundary_time_total);
} catch (std::exception &) { } catch (std::exception &) {
} }
} }

View File

@ -136,7 +136,7 @@ void PPPMElectrode::init()
} }
if (order < 2 || order > MAXORDER) if (order < 2 || order > MAXORDER)
error->all(FLERR, fmt::format("PPPM/electrode order cannot be < 2 or > {}", MAXORDER)); error->all(FLERR, "PPPM/electrode order cannot be < 2 or > {}", MAXORDER);
// compute two charge force // compute two charge force
@ -816,7 +816,7 @@ void PPPMElectrode::one_step_multiplication(bigint *imat, double *greens_real, d
memory->destroy(rho1d_j); memory->destroy(rho1d_j);
MPI_Barrier(world); MPI_Barrier(world);
if (timer_flag && (comm->me == 0)) if (timer_flag && (comm->me == 0))
utils::logmesg(lmp, fmt::format("Single step time: {:.4g} s\n", MPI_Wtime() - step1_time)); utils::logmesg(lmp, "Single step time: {:.4g} s\n", MPI_Wtime() - step1_time);
} }
/* ----------------------------------------------------------------------*/ /* ----------------------------------------------------------------------*/
@ -917,7 +917,7 @@ void PPPMElectrode::two_step_multiplication(bigint *imat, double *greens_real, d
} }
MPI_Barrier(world); MPI_Barrier(world);
if (timer_flag && (comm->me == 0)) if (timer_flag && (comm->me == 0))
utils::logmesg(lmp, fmt::format("step 1 time: {:.4g} s\n", MPI_Wtime() - step1_time)); utils::logmesg(lmp, "step 1 time: {:.4g} s\n", MPI_Wtime() - step1_time);
// nested loop over electrode atoms i and j and stencil of i // nested loop over electrode atoms i and j and stencil of i
// in theory could reuse make_rho1d_j here -- but this step is already // in theory could reuse make_rho1d_j here -- but this step is already
@ -958,7 +958,7 @@ void PPPMElectrode::two_step_multiplication(bigint *imat, double *greens_real, d
MPI_Barrier(world); MPI_Barrier(world);
memory->destroy(gw); memory->destroy(gw);
if (timer_flag && (comm->me == 0)) if (timer_flag && (comm->me == 0))
utils::logmesg(lmp, fmt::format("step 2 time: {:.4g} s\n", MPI_Wtime() - step2_time)); utils::logmesg(lmp, "step 2 time: {:.4g} s\n", MPI_Wtime() - step2_time);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -719,7 +719,7 @@ void PPPMElectrodeIntel::one_step_multiplication(bigint *imat, double *greens_re
MPI_Barrier(world); MPI_Barrier(world);
memory->destroy(rho1d_j); memory->destroy(rho1d_j);
if (timer_flag && (comm->me == 0)) if (timer_flag && (comm->me == 0))
utils::logmesg(lmp, fmt::format("Single step time: {:.4g} s\n", MPI_Wtime() - step1_time)); utils::logmesg(lmp, "Single step time: {:.4g} s\n", MPI_Wtime() - step1_time);
} }
/* ----------------------------------------------------------------------*/ /* ----------------------------------------------------------------------*/
@ -844,7 +844,7 @@ void PPPMElectrodeIntel::two_step_multiplication(bigint *imat, double *greens_re
} }
MPI_Barrier(world); MPI_Barrier(world);
if (timer_flag && (comm->me == 0)) if (timer_flag && (comm->me == 0))
utils::logmesg(lmp, fmt::format("step 1 time: {:.4g} s\n", MPI_Wtime() - step1_time)); utils::logmesg(lmp, "step 1 time: {:.4g} s\n", MPI_Wtime() - step1_time);
// nested loop over electrode atoms i and j and stencil of i // nested loop over electrode atoms i and j and stencil of i
double step2_time = MPI_Wtime(); double step2_time = MPI_Wtime();
@ -914,7 +914,7 @@ void PPPMElectrodeIntel::two_step_multiplication(bigint *imat, double *greens_re
} }
MPI_Barrier(world); MPI_Barrier(world);
if (timer_flag && (comm->me == 0)) if (timer_flag && (comm->me == 0))
utils::logmesg(lmp, fmt::format("step 2 time: {:.4g} s\n", MPI_Wtime() - step2_time)); utils::logmesg(lmp, "step 2 time: {:.4g} s\n", MPI_Wtime() - step2_time);
} }
template <class flt_t, class acc_t, int use_table> template <class flt_t, class acc_t, int use_table>

View File

@ -382,8 +382,7 @@ void PairReaxFFKokkos<DeviceType>::init_md()
if (swb < 0) if (swb < 0)
error->one(FLERR,"Negative upper Taper-radius cutoff"); error->one(FLERR,"Negative upper Taper-radius cutoff");
else if (swb < 5) else if (swb < 5)
error->one(FLERR,fmt::format("Warning: very low Taper-radius cutoff: " error->one(FLERR,"Warning: very low Taper-radius cutoff: {}\n", swb);
"{}\n", swb));
d1 = swb - swa; d1 = swb - swa;
d7 = powint(d1,7); d7 = powint(d1,7);

View File

@ -1873,7 +1873,7 @@ void PairBOP::read_table(char *filename)
reader = new PotentialFileReader(lmp, filename, "BOP"); reader = new PotentialFileReader(lmp, filename, "BOP");
bop_types = reader->next_int(); bop_types = reader->next_int();
if (bop_types <= 0) if (bop_types <= 0)
error->one(FLERR,fmt::format("BOP potential file with {} elements",bop_types)); error->one(FLERR,"BOP potential file with {} elements",bop_types);
bop_elements = new char*[bop_types]; bop_elements = new char*[bop_types];
bop_masses = new double[bop_types]; bop_masses = new double[bop_types];
@ -2221,8 +2221,7 @@ void PairBOP::write_tables(int npts)
int param = elem2param[i][j]; int param = elem2param[i][j];
PairParameters & pair = pairParameters[param]; PairParameters & pair = pairParameters[param];
filename = fmt::format("{}{}_Pair_SPR_{}",bop_elements[i], filename = fmt::format("{}{}_Pair_SPR_{}",bop_elements[i],bop_elements[j],comm->me);
bop_elements[j],comm->me);
fp = fopen(filename.c_str(), "w"); fp = fopen(filename.c_str(), "w");
xmin = (pair.betaS)->get_xmin(); xmin = (pair.betaS)->get_xmin();
@ -2240,8 +2239,7 @@ void PairBOP::write_tables(int npts)
fclose(fp); fclose(fp);
if (pair.cutL != 0) { if (pair.cutL != 0) {
filename = fmt::format("{}{}_Pair_L_{}",bop_elements[i], filename = fmt::format("{}{}_Pair_L_{}",bop_elements[i],bop_elements[j],comm->me);
bop_elements[j],comm->me);
fp = fopen(filename.c_str(), "w"); fp = fopen(filename.c_str(), "w");
xmin = (pair.cphi)->get_xmin(); xmin = (pair.cphi)->get_xmin();
xmax = (pair.cphi)->get_xmax(); xmax = (pair.cphi)->get_xmax();
@ -2254,8 +2252,7 @@ void PairBOP::write_tables(int npts)
} }
fclose(fp); fclose(fp);
} }
filename = fmt::format("{}{}_Pair_BO_{}", bop_elements[i], filename = fmt::format("{}{}_Pair_BO_{}", bop_elements[i],bop_elements[j], comm->me);
bop_elements[j], comm->me);
fp = fopen(filename.c_str(), "w"); fp = fopen(filename.c_str(), "w");
xmin = (pair.bo)->get_xmin(); xmin = (pair.bo)->get_xmin();
xmax = (pair.bo)->get_xmax(); xmax = (pair.bo)->get_xmax();

View File

@ -240,7 +240,7 @@ MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
break; break;
} else } else
error->all(FLERR, fmt::format("MDI engine exited with invalid command: {}", mdicmd)); error->all(FLERR, "MDI engine exited with invalid command: {}", mdicmd);
} }
// clean up // clean up

View File

@ -224,8 +224,8 @@ void FixQEqReaxFFOMP::compute_H()
} // omp } // omp
if (m_fill >= H.m) if (m_fill >= H.m)
error->all(FLERR,fmt::format("Fix qeq/reaxff: H matrix size has been " error->all(FLERR,"Fix qeq/reaxff: H matrix size has been exceeded: m_fill={} H.m={}\n",
"exceeded: m_fill={} H.m={}\n", m_fill, H.m)); m_fill, H.m);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -467,9 +467,8 @@ int FixQEqReaxFFOMP::CG(double *b, double *x)
} }
if ((i >= imax) && maxwarn && (comm->me == 0)) if ((i >= imax) && maxwarn && (comm->me == 0))
error->warning(FLERR,fmt::format("Fix qeq/reaxff/omp CG convergence failed " error->warning(FLERR,"Fix qeq/reaxff/omp CG convergence failed after {} iterations at step {}",
"after {} iterations at step {}", i,update->ntimestep);
i,update->ntimestep));
return i; return i;
} }
@ -796,9 +795,8 @@ int FixQEqReaxFFOMP::dual_CG(double *b1, double *b2, double *x1, double *x2)
} }
if ((i >= imax) && maxwarn && (comm->me == 0)) if ((i >= imax) && maxwarn && (comm->me == 0))
error->warning(FLERR,fmt::format("Fix qeq/reaxff/omp CG convergence failed " error->warning(FLERR,"Fix qeq/reaxff/omp CG convergence failed after {} iterations at step {}",
"after {} iterations at step {}", i,update->ntimestep);
i,update->ntimestep));
return matvecs_s + matvecs_t; return matvecs_s + matvecs_t;
} }

View File

@ -138,11 +138,10 @@ void MSMCGOMP::compute(int eflag, int vflag)
/ static_cast<double>(atom->natoms); / static_cast<double>(atom->natoms);
if (me == 0) if (me == 0)
utils::logmesg(MSM::lmp,fmt::format(" MSM/cg optimization cutoff: {:.8}\n" utils::logmesg(MSM::lmp," MSM/cg optimization cutoff: {:.8}\n"
" Total charged atoms: {:.1f}%\n" " Total charged atoms: {:.1f}%\n"
" Min/max charged atoms/proc: {:.1f}%" " Min/max charged atoms/proc: {:.1f}%"
" {:.1f}%\n",smallq, " {:.1f}%\n",smallq, charged_frac,charged_fmin,charged_fmax);
charged_frac,charged_fmin,charged_fmax));
} }
// only need to rebuild this list after a neighbor list update // only need to rebuild this list after a neighbor list update

View File

@ -810,8 +810,7 @@ void FixQEq::read_file(char *file)
for (int n=1; n <= ntypes; ++n) for (int n=1; n <= ntypes; ++n)
if (setflag[n] == 0) if (setflag[n] == 0)
error->one(FLERR,fmt::format("Parameters for atom type {} missing in " error->one(FLERR,"Parameters for atom type {} missing in qeq parameter file", n);
"qeq parameter file", n));
delete[] setflag; delete[] setflag;
} }

View File

@ -697,8 +697,8 @@ void FixQEqReaxFF::compute_H()
} }
if (m_fill >= H.m) if (m_fill >= H.m)
error->all(FLERR,fmt::format("Fix qeq/reaxff H matrix size has been " error->all(FLERR,"Fix qeq/reaxff H matrix size has been exceeded: m_fill={} H.m={}\n",
"exceeded: m_fill={} H.m={}\n", m_fill, H.m)); m_fill, H.m);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -772,9 +772,8 @@ int FixQEqReaxFF::CG(double *b, double *x)
} }
if ((i >= imax) && maxwarn && (comm->me == 0)) if ((i >= imax) && maxwarn && (comm->me == 0))
error->warning(FLERR,fmt::format("Fix qeq/reaxff CG convergence failed " error->warning(FLERR, "Fix qeq/reaxff CG convergence failed after {} iterations at step {}",
"after {} iterations at step {}", i,update->ntimestep);
i,update->ntimestep));
return i; return i;
} }

View File

@ -56,8 +56,8 @@ FixReaxFFBonds::FixReaxFFBonds(LAMMPS *lmp, int narg, char **arg) :
if (!fp) error->one(FLERR,"Cannot open compressed file"); if (!fp) error->one(FLERR,"Cannot open compressed file");
} else fp = fopen(arg[4],"w"); } else fp = fopen(arg[4],"w");
if (!fp) error->one(FLERR,fmt::format("Cannot open fix reaxff/bonds file {}: {}", if (!fp) error->one(FLERR,"Cannot open fix reaxff/bonds file {}: {}",
arg[4],utils::getsyserror())); arg[4],utils::getsyserror());
} }
if (atom->tag_consecutive() == 0) if (atom->tag_consecutive() == 0)

View File

@ -253,8 +253,8 @@ namespace ReaxFF {
if (Nflag || wsr->num_far >= far_nbrs->num_intrs * DANGER_ZONE) { if (Nflag || wsr->num_far >= far_nbrs->num_intrs * DANGER_ZONE) {
if (wsr->num_far > far_nbrs->num_intrs) if (wsr->num_far > far_nbrs->num_intrs)
error->one(FLERR,fmt::format("step{}: ran out of space on far_nbrs: top={}, max={}", error->one(FLERR, "step{}: ran out of space on far_nbrs: top={}, max={}",
data->step, wsr->num_far, far_nbrs->num_intrs)); data->step, wsr->num_far, far_nbrs->num_intrs);
newsize = static_cast<int> newsize = static_cast<int>
(MAX(wsr->num_far*safezone, mincap*REAX_MIN_NBRS)); (MAX(wsr->num_far*safezone, mincap*REAX_MIN_NBRS));

View File

@ -129,9 +129,11 @@ void NEB::command(int narg, char **arg)
if (nevery <= 0) if (nevery <= 0)
error->universe_all(FLERR, fmt::format("Illegal NEB command every parameter: {}", nevery)); error->universe_all(FLERR, fmt::format("Illegal NEB command every parameter: {}", nevery));
if (n1steps % nevery) if (n1steps % nevery)
error->all(FLERR, fmt::format("NEB N1 value {} incompatible with every {}", n1steps, nevery)); error->universe_all(FLERR, fmt::format("NEB N1 value {} incompatible with every {}",
n1steps, nevery));
if (n2steps % nevery) if (n2steps % nevery)
error->all(FLERR, fmt::format("NEB N2 value {} incompatible with every {}", n2steps, nevery)); error->universe_all(FLERR, fmt::format("NEB N2 value {} incompatible with every {}",
n2steps, nevery));
// replica info // replica info

View File

@ -97,7 +97,7 @@ void TemperGrem::command(int narg, char **arg)
FixNH *nh = dynamic_cast<FixNH *>(modify->get_fix_by_id(arg[4])); FixNH *nh = dynamic_cast<FixNH *>(modify->get_fix_by_id(arg[4]));
if (!nh) if (!nh)
error->all(FLERR,fmt::format("Fix {} for Nose-Hoover fix does not exist", arg[4])); error->universe_all(FLERR,fmt::format("Fix {} for Nose-Hoover fix does not exist", arg[4]));
// get result from nvt vs npt check from fix_grem // get result from nvt vs npt check from fix_grem

View File

@ -530,7 +530,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
if (infile == nullptr) if (infile == nullptr)
error->one(FLERR,"Cannot open input script {}: {}", arg[inflag], utils::getsyserror()); error->one(FLERR,"Cannot open input script {}: {}", arg[inflag], utils::getsyserror());
if (!helpflag) if (!helpflag)
utils::logmesg(this,fmt::format("LAMMPS ({}{})\n", version, update_string)); utils::logmesg(this,"LAMMPS ({}{})\n", version, update_string);
// warn against using I/O redirection in parallel runs // warn against using I/O redirection in parallel runs
if ((inflag == 0) && (universe->nprocs > 1)) if ((inflag == 0) && (universe->nprocs > 1))
@ -626,8 +626,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
} }
if ((me == 0) && (!helpflag)) if ((me == 0) && (!helpflag))
utils::logmesg(this,fmt::format("LAMMPS ({})\nProcessor partition = {}\n", utils::logmesg(this,"LAMMPS ({})\nProcessor partition = {}\n", version, universe->iworld);
version, universe->iworld));
} }
// check consistency of datatype settings in lmptype.h // check consistency of datatype settings in lmptype.h
@ -762,8 +761,7 @@ LAMMPS::~LAMMPS() noexcept(false)
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;
utils::logmesg(this,fmt::format("Total wall time: {}:{:02d}:{:02d}\n", utils::logmesg(this, "Total wall time: {}:{:02d}:{:02d}\n", hours, minutes, seconds);
hours, minutes, seconds));
} }
if (universe->nworlds == 1) { if (universe->nworlds == 1) {

View File

@ -364,7 +364,7 @@ void ReadData::command(int narg, char **arg)
// check if data file is available and readable // check if data file is available and readable
if (!platform::file_is_readable(arg[0])) if (!platform::file_is_readable(arg[0]))
error->all(FLERR, fmt::format("Cannot open file {}: {}", arg[0], utils::getsyserror())); error->all(FLERR, "Cannot open file {}: {}", arg[0], utils::getsyserror());
// reset so we can warn about reset image flags exactly once per data file // reset so we can warn about reset image flags exactly once per data file

View File

@ -62,12 +62,11 @@ void Special::build()
if (me == 0) { if (me == 0) {
const double * const special_lj = force->special_lj; const double * const special_lj = force->special_lj;
const double * const special_coul = force->special_coul; const double * const special_coul = force->special_coul;
auto mesg = fmt::format("Finding 1-2 1-3 1-4 neighbors ...\n" utils::logmesg(lmp, "Finding 1-2 1-3 1-4 neighbors ...\n"
" special bond factors lj: {:<8} {:<8} {:<8}\n" " special bond factors lj: {:<8} {:<8} {:<8}\n"
" special bond factors coul: {:<8} {:<8} {:<8}\n", " special bond factors coul: {:<8} {:<8} {:<8}\n",
special_lj[1],special_lj[2],special_lj[3], special_lj[1],special_lj[2],special_lj[3],
special_coul[1],special_coul[2],special_coul[3]); special_coul[1],special_coul[2],special_coul[3]);
utils::logmesg(lmp,mesg);
} }
// set onefive_flag if special_bonds command set it // set onefive_flag if special_bonds command set it
@ -162,7 +161,7 @@ void Special::build()
if (onefive_flag) { if (onefive_flag) {
onefive_build(); onefive_build();
if (me == 0) if (me == 0)
utils::logmesg(lmp,fmt::format("{:>6} = max # of 1-5 neighbors\n",maxall)); utils::logmesg(lmp,"{:>6} = max # of 1-5 neighbors\n",maxall);
} }
// finish processing the onetwo, onethree, onefour, onefive lists // finish processing the onetwo, onethree, onefour, onefive lists

View File

@ -557,7 +557,7 @@ void utils::bounds(const char *file, int line, const std::string &str,
// check for illegal charcters // check for illegal charcters
size_t found = str.find_first_not_of("*-0123456789"); size_t found = str.find_first_not_of("*-0123456789");
if (found != std::string::npos) { if (found != std::string::npos) {
if (error) error->all(file, line, fmt::format("Invalid range string: {}", str)); if (error) error->all(file, line, "Invalid range string: {}", str);
return; return;
} }
@ -580,17 +580,14 @@ void utils::bounds(const char *file, int line, const std::string &str,
if (error) { if (error) {
if ((nlo <= 0) || (nhi <= 0)) if ((nlo <= 0) || (nhi <= 0))
error->all(file, line, fmt::format("Invalid range string: {}", str)); error->all(file, line, "Invalid range string: {}", str);
if (nlo < nmin) if (nlo < nmin)
error->all(file, line, fmt::format("Numeric index {} is out of bounds ({}-{})", error->all(file, line, "Numeric index {} is out of bounds ({}-{})", nlo, nmin, nmax);
nlo, nmin, nmax));
else if (nhi > nmax) else if (nhi > nmax)
error->all(file, line, fmt::format("Numeric index {} is out of bounds ({}-{})", error->all(file, line, "Numeric index {} is out of bounds ({}-{})", nhi, nmin, nmax);
nhi, nmin, nmax));
else if (nlo > nhi) else if (nlo > nhi)
error->all(file, line, fmt::format("Numeric index {} is out of bounds ({}-{})", error->all(file, line, "Numeric index {} is out of bounds ({}-{})", nlo, nmin, nhi);
nlo, nmin, nhi));
} }
} }