diff --git a/src/balance.cpp b/src/balance.cpp index d6579e9199..49cd6ecad5 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -113,7 +113,7 @@ void Balance::command(int narg, char **arg) if (domain->box_exist == 0) error->all(FLERR,"Balance command before simulation box is defined"); - if (me == 0 && screen) fprintf(screen,"Balancing ...\n"); + if (me == 0) utils::logmesg(lmp,"Balancing ...\n"); // parse required arguments diff --git a/src/change_box.cpp b/src/change_box.cpp index f50ba23db4..ff7658a01f 100644 --- a/src/change_box.cpp +++ b/src/change_box.cpp @@ -49,7 +49,7 @@ void ChangeBox::command(int narg, char **arg) error->all(FLERR,"Change_box command before simulation box is defined"); if (narg < 2) error->all(FLERR,"Illegal change_box command"); - if (comm->me == 0 && screen) fprintf(screen,"Changing box ...\n"); + if (comm->me == 0) utils::logmesg(lmp,"Changing box ...\n"); // group diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index ba8940de95..03d5d2f65d 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -282,8 +282,7 @@ void DeleteAtoms::delete_overlap(int narg, char **arg) int group1bit = group->bitmask[igroup1]; int group2bit = group->bitmask[igroup2]; - if (comm->me == 0 && screen) - fprintf(screen,"System init for delete_atoms ...\n"); + if (comm->me == 0) utils::logmesg(lmp,"System init for delete_atoms ...\n"); // request a full neighbor list for use by this command diff --git a/src/delete_bonds.cpp b/src/delete_bonds.cpp index 99c0f1b951..7b9260bc52 100644 --- a/src/delete_bonds.cpp +++ b/src/delete_bonds.cpp @@ -51,11 +51,10 @@ void DeleteBonds::command(int narg, char **arg) // init entire system since comm->borders is done // comm::init needs neighbor::init needs pair::init needs kspace::init, etc - if (comm->me == 0 && screen) - fprintf(screen,"System init for delete_bonds ...\n"); + if (comm->me == 0) utils::logmesg(lmp,"System init for delete_bonds ...\n"); lmp->init(); - if (comm->me == 0 && screen) fprintf(screen,"Deleting bonds ...\n"); + if (comm->me == 0) utils::logmesg(lmp,"Deleting bonds ...\n"); // identify group diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp index 748adca811..82b7bf9492 100644 --- a/src/displace_atoms.cpp +++ b/src/displace_atoms.cpp @@ -34,6 +34,7 @@ #include "math_extra.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "fmt/format.h" using namespace LAMMPS_NS; @@ -68,7 +69,7 @@ void DisplaceAtoms::command(int narg, char **arg) error->all(FLERR,"Cannot displace_atoms after " "reading restart file with per-atom info"); - if (comm->me == 0 && screen) fprintf(screen,"Displacing atoms ...\n"); + if (comm->me == 0) utils::logmesg(lmp,"Displacing atoms ...\n"); // group and style diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 0426323a21..f47eda3262 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -120,7 +120,7 @@ void ReadDump::command(int narg, char **arg) // find the snapshot and read/bcast/process header info - if (me == 0 && screen) fprintf(screen,"Scanning dump file ...\n"); + if (me == 0) utils::logmesg(lmp,"Scanning dump file ...\n"); bigint ntimestep = seek(nstep,1); if (ntimestep < 0) @@ -135,8 +135,7 @@ void ReadDump::command(int narg, char **arg) // read in the snapshot and reset system - if (me == 0 && screen) - fprintf(screen,"Reading snapshot from dump file ...\n"); + if (me == 0) utils::logmesg(lmp,"Reading snapshot from dump file ...\n"); bigint natoms_prev = atom->natoms; atoms(); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 3bbae596d1..157992bce3 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -103,7 +103,7 @@ void ReadRestart::command(int narg, char **arg) // open single restart file or base file for multiproc case if (me == 0) { - if (screen) fprintf(screen,"Reading restart file ...\n"); + utils::logmesg(lmp,"Reading restart file ...\n"); std::string hfile = file; if (multiproc) { hfile.replace(hfile.find("%"),1,"base"); @@ -620,10 +620,9 @@ void ReadRestart::header() if (flag == VERSION) { char *version = read_string(); - if (me == 0) { - if (screen) fprintf(screen," restart file = %s, LAMMPS = %s\n", - version,universe->version); - } + if (me == 0) + utils::logmesg(lmp,fmt::format(" restart file = {}, LAMMPS = {}\n", + version,universe->version)); delete [] version; // we have no forward compatibility, thus exit with error diff --git a/src/replicate.cpp b/src/replicate.cpp index 51ef75c37b..a9c0dbf7b3 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -48,7 +48,7 @@ void Replicate::command(int narg, char **arg) int me = comm->me; int nprocs = comm->nprocs; - if (me == 0 && screen) fprintf(screen,"Replicating atoms ...\n"); + if (me == 0) utils::logmesg(lmp,"Replicating atoms ...\n"); // nrep = total # of replications @@ -349,12 +349,14 @@ void Replicate::command(int narg, char **arg) int size_buf_all = 0; MPI_Allreduce(&n, &size_buf_all, 1, MPI_INT, MPI_SUM, world); - if (me == 0 && screen) { - fmt::print(screen," bounding box image = ({} {} {}) to ({} {} {})\n", - _imagelo[0],_imagelo[1],_imagelo[2], - _imagehi[0],_imagehi[1],_imagehi[2]); - fmt::print(screen," bounding box extra memory = {:.2f} MB\n", - (double)size_buf_all*sizeof(double)/1024/1024); + if (me == 0) { + auto mesg = fmt::format(" bounding box image = ({:.8} {:.8} {:.8}) " + "to ({:.8} {:.8} {:.8})\n", + _imagelo[0],_imagelo[1],_imagelo[2], + _imagehi[0],_imagehi[1],_imagehi[2]); + mesg += fmt::format(" bounding box extra memory = {:.2f} MB\n", + (double)size_buf_all*sizeof(double)/1024/1024); + utils::logmesg(lmp,mesg); } // rnk offsets @@ -632,11 +634,10 @@ void Replicate::command(int narg, char **arg) int sum = 0; MPI_Reduce(&num_replicas_added, &sum, 1, MPI_INT, MPI_SUM, 0, world); double avg = (double) sum / nprocs; - if (me == 0 && screen) - fprintf(screen," average # of replicas added to proc = %.2f " - "out of %i (%.2f %%)\n", - avg,nx*ny*nz,avg/(nx*ny*nz)*100.0); - + if (me == 0) + utils::logmesg(lmp,fmt::format(" average # of replicas added to proc =" + " {:.2f} out of {} ({:.2f}%)\n", + avg,nx*ny*nz,avg/(nx*ny*nz)*100.0)); } else { for (int iproc = 0; iproc < nprocs; iproc++) { diff --git a/src/set.cpp b/src/set.cpp index 8527f93df7..01176f68c0 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -82,7 +82,7 @@ void Set::command(int narg, char **arg) // loop over keyword/value pairs // call appropriate routine to reset attributes - if (comm->me == 0 && screen) fprintf(screen,"Setting atom values ...\n"); + if (comm->me == 0) utils::logmesg(lmp,"Setting atom values ...\n"); int allcount,origarg; @@ -1264,7 +1264,7 @@ void Set::topology(int keyword) // init entire system since comm->exchange is done // comm::init needs neighbor::init needs pair::init needs kspace::init, etc - if (comm->me == 0 && screen) fprintf(screen," system init for set ...\n"); + if (comm->me == 0) utils::logmesg(lmp," system init for set ...\n"); lmp->init(); if (domain->triclinic) domain->x2lamda(atom->nlocal); diff --git a/src/write_data.cpp b/src/write_data.cpp index 1ec24a99cd..511552cf69 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -105,8 +105,7 @@ void WriteData::command(int narg, char **arg) // e.g. pair hybrid coeffs, dpd ghost-atom velocity setting if (noinit == 0) { - if (comm->me == 0 && screen) - fputs("System init for write_data ...\n",screen); + if (comm->me == 0) utils::logmesg(lmp,"System init for write_data ...\n"); lmp->init(); // move atoms to new processors before writing file diff --git a/src/write_restart.cpp b/src/write_restart.cpp index 9129126aae..062add3b3c 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -87,8 +87,7 @@ void WriteRestart::command(int narg, char **arg) // comm::init needs neighbor::init needs pair::init needs kspace::init, etc if (noinit == 0) { - if (comm->me == 0 && screen) - fprintf(screen,"System init for write_restart ...\n"); + if (comm->me == 0) utils::logmesg(lmp,"System init for write_restart ...\n"); lmp->init(); // move atoms to new processors before writing file