diff --git a/src/REAXFF/fix_reaxff_bonds.cpp b/src/REAXFF/fix_reaxff_bonds.cpp index 30c55d8f1a..80cd8c7c85 100644 --- a/src/REAXFF/fix_reaxff_bonds.cpp +++ b/src/REAXFF/fix_reaxff_bonds.cpp @@ -56,8 +56,8 @@ FixReaxFFBonds::FixReaxFFBonds(LAMMPS *lmp, int narg, char **arg) : if (!fp) error->one(FLERR,"Cannot open compressed file"); } else fp = fopen(arg[4],"w"); - if (!fp) error->one(FLERR,fmt::format("Cannot open fix reaxff/bonds file {}: " - "{}",arg[4],utils::getsyserror())); + if (!fp) error->one(FLERR,fmt::format("Cannot open fix reaxff/bonds file {}: {}", + arg[4],utils::getsyserror())); } if (atom->tag_consecutive() == 0) @@ -249,14 +249,12 @@ void FixReaxFFBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, MPI_Request irequest, irequest2; if (me == 0) { - fprintf(fp,"# Timestep " BIGINT_FORMAT " \n",ntimestep); - fprintf(fp,"# \n"); - fprintf(fp,"# Number of particles %d \n",natoms); - fprintf(fp,"# \n"); - fprintf(fp,"# Max number of bonds per atom %d with " - "coarse bond order cutoff %5.3f \n",maxnum,cutof3); - fprintf(fp,"# Particle connection table and bond orders \n"); - fprintf(fp,"# id type nb id_1...id_nb mol bo_1...bo_nb abo nlp q \n"); + fmt::print(fp,"# Timestep {}\n#\n",ntimestep); + fmt::print(fp,"# Number of particles {}\n#\n",natoms); + fmt::print(fp,"# Max number of bonds per atom {} with coarse bond order cutoff {:5.3f}\n", + maxnum,cutof3); + fmt::print(fp,"# Particle connection table and bond orders\n" + "# id type nb id_1...id_nb mol bo_1...bo_nb abo nlp q\n"); } j = 2; @@ -278,30 +276,26 @@ void FixReaxFFBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, avqtmp = buf[j+3]; numbonds = nint(buf[j+4]); - fprintf(fp," " TAGINT_FORMAT " %d %d",itag,itype,numbonds); - - for (k = 5; k < 5+numbonds; k++) { - jtag = static_cast (buf[j+k]); - fprintf(fp," " TAGINT_FORMAT,jtag); - } + auto mesg = fmt::format(" {} {} {}",itag,itype,numbonds); + for (k = 5; k < 5+numbonds; k++) + mesg += " " + std::to_string(static_cast (buf[j+k])); j += (5+numbonds); - fprintf(fp," " TAGINT_FORMAT,static_cast (buf[j])); + mesg += " " + std::to_string(static_cast (buf[j])); j ++; - for (k = 0; k < numbonds; k++) { - abotmp = buf[j+k]; - fprintf(fp,"%14.3f",abotmp); - } + for (k = 0; k < numbonds; k++) mesg += fmt::format("{:14.3f}",buf[j+k]); j += (1+numbonds); - fprintf(fp,"%14.3f%14.3f%14.3f\n",sbotmp,nlptmp,avqtmp); + + mesg += fmt::format("{:14.3f}{:14.3f}{:14.3f}\n",sbotmp,nlptmp,avqtmp); + fmt::print(fp, mesg); } } } else { MPI_Isend(&buf[0],nbuf_local,MPI_DOUBLE,0,0,world,&irequest2); MPI_Wait(&irequest2,MPI_STATUS_IGNORE); } - if (me ==0) fprintf(fp,"# \n"); + if (me ==0) fputs("# \n",fp); }