From 353439c4148fb733f13ee0b0710ead6dcec86d18 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 15:14:19 +0000 Subject: [PATCH 1/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5546 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- lib/gpu/crml_gpu_kernel.cu | 393 +++++++++++++++++++++++++++++++++++++ 1 file changed, 393 insertions(+) create mode 100644 lib/gpu/crml_gpu_kernel.cu diff --git a/lib/gpu/crml_gpu_kernel.cu b/lib/gpu/crml_gpu_kernel.cu new file mode 100644 index 0000000000..47dad50753 --- /dev/null +++ b/lib/gpu/crml_gpu_kernel.cu @@ -0,0 +1,393 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Mike Brown (ORNL), brownw@ornl.gov +------------------------------------------------------------------------- */ + +#ifndef CRML_GPU_KERNEL +#define CRML_GPU_KERNEL + +#define MAX_BIO_SHARED_TYPES 128 + +#ifdef _DOUBLE_DOUBLE +#define numtyp double +#define numtyp2 double2 +#define numtyp4 double4 +#define acctyp double +#define acctyp4 double4 +#endif + +#ifdef _SINGLE_DOUBLE +#define numtyp float +#define numtyp2 float2 +#define numtyp4 float4 +#define acctyp double +#define acctyp4 double4 +#endif + +#ifndef numtyp +#define numtyp float +#define numtyp2 float2 +#define numtyp4 float4 +#define acctyp float +#define acctyp4 float4 +#endif + +#define EWALD_F (numtyp)1.12837917 +#define EWALD_P (numtyp)0.3275911 +#define A1 (numtyp)0.254829592 +#define A2 (numtyp)-0.284496736 +#define A3 (numtyp)1.421413741 +#define A4 (numtyp)-1.453152027 +#define A5 (numtyp)1.061405429 + +#ifdef NV_KERNEL + +#include "geryon/ucl_nv_kernel.h" +texture pos_tex; +texture q_tex; + +#ifdef _DOUBLE_DOUBLE +__inline double4 fetch_pos(const int& i, const double4 *pos) +{ + return pos[i]; +} +__inline double fetch_q(const int& i, const double *q) +{ + return q[i]; +} +#else +__inline float4 fetch_pos(const int& i, const float4 *pos) +{ + return tex1Dfetch(pos_tex, i); +} +__inline float fetch_q(const int& i, const float *q) +{ + return tex1Dfetch(q_tex, i); +} +#endif + +#else + +#pragma OPENCL EXTENSION cl_khr_fp64: enable +#define GLOBAL_ID_X get_global_id(0) +#define THREAD_ID_X get_local_id(0) +#define BLOCK_ID_X get_group_id(0) +#define BLOCK_SIZE_X get_local_size(0) +#define __syncthreads() barrier(CLK_LOCAL_MEM_FENCE) +#define __inline inline + +#define fetch_pos(i,y) x_[i] +#define fetch_q(i,y) q_[i] + +#endif + +__kernel void kernel_pair(__global numtyp4 *x_, __global numtyp4 *lj1, + const int lj_types, + __global numtyp *sp_lj_in, __global int *dev_nbor, + __global acctyp4 *ans, __global acctyp *engv, + const int eflag, const int vflag, const int inum, + const int nall, const int nbor_pitch, + __global numtyp *q_, const numtyp cut_coulsq, + const numtyp qqrd2e, const numtyp g_ewald, + const numtyp denom_lj, const numtyp cut_bothsq, + const numtyp cut_ljsq, const numtyp cut_lj_innersq) { + + // ii indexes the two interacting particles in gi + int ii=GLOBAL_ID_X; + __local numtyp sp_lj[8]; + sp_lj[0]=sp_lj_in[0]; + sp_lj[1]=sp_lj_in[1]; + sp_lj[2]=sp_lj_in[2]; + sp_lj[3]=sp_lj_in[3]; + sp_lj[4]=sp_lj_in[4]; + sp_lj[5]=sp_lj_in[5]; + sp_lj[6]=sp_lj_in[6]; + sp_lj[7]=sp_lj_in[7]; + + if (ii cut_lj_innersq) { + switch1 = (cut_ljsq-rsq); + numtyp switch2 = (numtyp)12.0*rsq*switch1*(rsq-cut_lj_innersq)/ + denom_lj; + switch1 *= switch1; + switch1 *= (cut_ljsq+(numtyp)2.0*rsq-(numtyp)3.0*cut_lj_innersq)/ + denom_lj; + switch2 *= r6inv*(lj1[mtype].z*r6inv-lj1[mtype].w); + force_lj = force_lj*switch1+switch2; + } + } else + force_lj = (numtyp)0.0; + + if (rsq < cut_coulsq) { + numtyp r = sqrt(rsq); + numtyp grij = g_ewald * r; + numtyp expm2 = exp(-grij*grij); + numtyp t = (numtyp)1.0 / ((numtyp)1.0 + EWALD_P*grij); + _erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor = qqrd2e * qtmp*fetch_q(j,q_)/r; + forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2-factor_coul); + } else { + forcecoul = (numtyp)0.0; + prefactor = (numtyp)0.0; + } + + force = (force_lj + forcecoul) * r2inv; + + f.x+=delx*force; + f.y+=dely*force; + f.z+=delz*force; + + if (eflag>0) { + e_coul += prefactor*(_erfc-factor_coul); + if (rsq < cut_ljsq) { + numtyp e=r6inv*(lj1[mtype].z*r6inv-lj1[mtype].w); + if (rsq > cut_lj_innersq) + e *= switch1; + energy+=factor_lj*e; + } + } + if (vflag>0) { + virial[0] += delx*delx*force; + virial[1] += dely*dely*force; + virial[2] += delz*delz*force; + virial[3] += delx*dely*force; + virial[4] += delx*delz*force; + virial[5] += dely*delz*force; + } + } + + } // for nbor + + // Store answers + __global acctyp *ap1=engv+ii; + if (eflag>0) { + *ap1=energy; + ap1+=inum; + *ap1=e_coul; + ap1+=inum; + } + if (vflag>0) { + for (int i=0; i<6; i++) { + *ap1=virial[i]; + ap1+=inum; + } + } + ans[ii]=f; + } // if ii +} + +__kernel void kernel_pair_fast(__global numtyp4 *x_, __global numtyp2 *ljd_in, + __global numtyp* sp_lj_in, __global int *dev_nbor, + __global acctyp4 *ans, __global acctyp *engv, + const int eflag, const int vflag, const int inum, + const int nall, const int nbor_pitch, + __global numtyp *q_, const numtyp cut_coulsq, + const numtyp qqrd2e, const numtyp g_ewald, + const numtyp denom_lj, const numtyp cut_bothsq, + const numtyp cut_ljsq, + const numtyp cut_lj_innersq) { + // ii indexes the two interacting particles in gi + int ii=THREAD_ID_X; + __local numtyp2 ljd[MAX_BIO_SHARED_TYPES]; + __local numtyp sp_lj[8]; + if (ii<8) + sp_lj[ii]=sp_lj_in[ii]; + ljd[ii]=ljd_in[ii]; + ljd[ii+64]=ljd_in[ii+64]; + + ii+=mul24((int)BLOCK_ID_X,(int)BLOCK_SIZE_X); + __syncthreads(); + + if (ii cut_lj_innersq) { + switch1 = (cut_ljsq-rsq); + numtyp switch2 = (numtyp)12.0*rsq*switch1*(rsq-cut_lj_innersq)/ + denom_lj; + switch1 *= switch1; + switch1 *= (cut_ljsq+(numtyp)2.0*rsq-(numtyp)3.0*cut_lj_innersq)/ + denom_lj; + switch2 *= lj3-lj4; + force_lj = force_lj*switch1+switch2; + } + } else + force_lj = (numtyp)0.0; + + if (rsq < cut_coulsq) { + numtyp r = sqrt(rsq); + numtyp grij = g_ewald * r; + numtyp expm2 = exp(-grij*grij); + numtyp t = (numtyp)1.0 / ((numtyp)1.0 + EWALD_P*grij); + _erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor = qqrd2e * qtmp*fetch_q(j,q_)/r; + forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2-factor_coul); + } else { + forcecoul = (numtyp)0.0; + prefactor = (numtyp)0.0; + } + + force = (force_lj + forcecoul) * r2inv; + + f.x+=delx*force; + f.y+=dely*force; + f.z+=delz*force; + + if (eflag>0) { + e_coul += prefactor*(_erfc-factor_coul); + if (rsq < cut_ljsq) { + numtyp e=lj3-lj4; + if (rsq > cut_lj_innersq) + e *= switch1; + energy+=factor_lj*e; + } + } + if (vflag>0) { + virial[0] += delx*delx*force; + virial[1] += dely*dely*force; + virial[2] += delz*delz*force; + virial[3] += delx*dely*force; + virial[4] += delx*delz*force; + virial[5] += dely*delz*force; + } + } + + } // for nbor + + // Store answers + __global acctyp *ap1=engv+ii; + if (eflag>0) { + *ap1=energy; + ap1+=inum; + *ap1=e_coul; + ap1+=inum; + } + if (vflag>0) { + for (int i=0; i<6; i++) { + *ap1=virial[i]; + ap1+=inum; + } + } + ans[ii]=f; + } // if ii +} + +#endif + From d5b494397e8e39a92c0d225c30adab481c0c6c55 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 15:53:06 +0000 Subject: [PATCH 2/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5547 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/CLASS2/dihedral_class2.cpp | 6 +- src/MANYBODY/fix_qeq_comb.cpp | 8 +-- src/MOLECULE/bond_fene.cpp | 12 ++-- src/MOLECULE/bond_fene_expand.cpp | 12 ++-- src/MOLECULE/dihedral_charmm.cpp | 6 +- src/MOLECULE/dihedral_harmonic.cpp | 6 +- src/MOLECULE/dihedral_helix.cpp | 6 +- src/MOLECULE/dihedral_multi_harmonic.cpp | 6 +- src/MOLECULE/dihedral_opls.cpp | 6 +- src/MOLECULE/improper_cvff.cpp | 7 ++- src/MOLECULE/improper_harmonic.cpp | 7 ++- src/MOLECULE/improper_umbrella.cpp | 7 ++- src/REAX/fix_reax_bonds.cpp | 6 +- src/REPLICA/neb.cpp | 6 +- src/REPLICA/prd.cpp | 19 +++--- src/REPLICA/tad.cpp | 40 ++++++------ src/SRD/fix_srd.cpp | 78 ++++++++++++------------ src/create_atoms.cpp | 8 +-- src/delete_atoms.cpp | 11 ++-- src/delete_bonds.cpp | 57 ++++++++++------- src/displace_atoms.cpp | 7 +-- src/displace_box.cpp | 7 +-- src/dump.cpp | 5 +- src/dump_atom.cpp | 8 +-- src/dump_custom.cpp | 8 +-- src/dump_local.cpp | 4 +- src/dump_xyz.cpp | 2 +- src/finish.cpp | 15 +++-- src/fix_ave_correlate.cpp | 4 +- src/fix_ave_histo.cpp | 4 +- src/fix_ave_spatial.cpp | 4 +- src/fix_ave_time.cpp | 4 +- src/fix_orient_fcc.cpp | 13 ++-- src/fix_shake.cpp | 35 +++++------ src/fix_tmd.cpp | 6 +- src/lmptype.h | 6 -- src/neigh_bond.cpp | 64 +++++++++---------- src/output.cpp | 8 +-- src/read_data.cpp | 36 ++++------- src/read_restart.cpp | 36 +++++------ src/replicate.cpp | 38 ++++++------ src/thermo.cpp | 20 +++--- src/write_restart.cpp | 4 +- 43 files changed, 318 insertions(+), 334 deletions(-) diff --git a/src/CLASS2/dihedral_class2.cpp b/src/CLASS2/dihedral_class2.cpp index bf29f64579..9b43673da5 100644 --- a/src/CLASS2/dihedral_class2.cpp +++ b/src/CLASS2/dihedral_class2.cpp @@ -210,9 +210,9 @@ void DihedralClass2::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Dihedral problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 7c91cd51cc..e01a8cefbc 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -172,11 +172,9 @@ void FixQEQComb::post_force(int vflag) // charge-equilibration loop - if (me == 0 && fp) { - char fstr[64]; - sprintf(fstr,"Charge equilibration on step %s\n",BIGINT_FORMAT); - fprintf(fp,fstr,update->ntimestep); - } + if (me == 0 && fp) + fprintf(fp,"Charge equilibration on step " BIGINT_FORMAT "\n", + update->ntimestep); heatpq = 0.01; qmass = 0.06; diff --git a/src/MOLECULE/bond_fene.cpp b/src/MOLECULE/bond_fene.cpp index f1c7b7782b..a2ac3edcf6 100644 --- a/src/MOLECULE/bond_fene.cpp +++ b/src/MOLECULE/bond_fene.cpp @@ -86,9 +86,9 @@ void BondFENE::compute(int eflag, int vflag) // if r > 2*r0 something serious is wrong, abort if (rlogarg < 0.1) { - char str[128],fstr[64]; - sprintf(fstr,"FENE bond too long: %s %%d %%d %%g",BIGINT_FORMAT); - sprintf(str,fstr,update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq)); + char str[128]; + sprintf(str,"FENE bond too long: " BIGINT_FORMAT " %d %d %g", + update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq)); error->warning(str,0); if (rlogarg <= -3.0) error->one("Bad FENE bond"); rlogarg = 0.1; @@ -243,9 +243,9 @@ double BondFENE::single(int type, double rsq, int i, int j) // if r > 2*r0 something serious is wrong, abort if (rlogarg < 0.1) { - char str[128],fstr[64]; - sprintf(fstr,"FENE bond too long: %s %%g",BIGINT_FORMAT); - sprintf(str,fstr,update->ntimestep,sqrt(rsq)); + char str[128]; + sprintf(str,"FENE bond too long: " BIGINT_FORMAT " %g", + update->ntimestep,sqrt(rsq)); error->warning(str,0); if (rlogarg <= -3.0) error->one("Bad FENE bond"); rlogarg = 0.1; diff --git a/src/MOLECULE/bond_fene_expand.cpp b/src/MOLECULE/bond_fene_expand.cpp index 588bc3f306..e628941025 100644 --- a/src/MOLECULE/bond_fene_expand.cpp +++ b/src/MOLECULE/bond_fene_expand.cpp @@ -91,9 +91,9 @@ void BondFENEExpand::compute(int eflag, int vflag) // if r > 2*r0 something serious is wrong, abort if (rlogarg < 0.1) { - char str[128],fstr[64]; - sprintf(fstr,"FENE bond too long: %s %%d %%d %%g",BIGINT_FORMAT); - sprintf(str,fstr,update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq)); + char str[128]; + sprintf(str,"FENE bond too long: " BIGINT_FORMAT " %d %d %g", + update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq)); error->warning(str,0); if (rlogarg <= -3.0) error->one("Bad FENE bond"); rlogarg = 0.1; @@ -257,9 +257,9 @@ double BondFENEExpand::single(int type, double rsq, int i, int j) // if r > 2*r0 something serious is wrong, abort if (rlogarg < 0.1) { - char str[128],fstr[64]; - sprintf(fstr,"FENE bond too long: %s %%g",BIGINT_FORMAT); - sprintf(str,fstr,update->ntimestep,sqrt(rsq)); + char str[128]; + sprintf(str,"FENE bond too long: " BIGINT_FORMAT " %g", + update->ntimestep,sqrt(rsq)); error->warning(str,0); if (rlogarg <= -3.0) error->one("Bad FENE bond"); rlogarg = 0.1; diff --git a/src/MOLECULE/dihedral_charmm.cpp b/src/MOLECULE/dihedral_charmm.cpp index 2aae7fd3ef..5bfbd69aac 100644 --- a/src/MOLECULE/dihedral_charmm.cpp +++ b/src/MOLECULE/dihedral_charmm.cpp @@ -147,9 +147,9 @@ void DihedralCharmm::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Dihedral problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MOLECULE/dihedral_harmonic.cpp b/src/MOLECULE/dihedral_harmonic.cpp index a2f62f5b4f..f4dad74653 100644 --- a/src/MOLECULE/dihedral_harmonic.cpp +++ b/src/MOLECULE/dihedral_harmonic.cpp @@ -137,9 +137,9 @@ void DihedralHarmonic::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Dihedral problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MOLECULE/dihedral_helix.cpp b/src/MOLECULE/dihedral_helix.cpp index 6b9520339c..d9c4b78f72 100644 --- a/src/MOLECULE/dihedral_helix.cpp +++ b/src/MOLECULE/dihedral_helix.cpp @@ -169,9 +169,9 @@ void DihedralHelix::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Dihedral problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MOLECULE/dihedral_multi_harmonic.cpp b/src/MOLECULE/dihedral_multi_harmonic.cpp index d369db2032..4636089e4e 100644 --- a/src/MOLECULE/dihedral_multi_harmonic.cpp +++ b/src/MOLECULE/dihedral_multi_harmonic.cpp @@ -162,9 +162,9 @@ void DihedralMultiHarmonic::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Dihedral problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MOLECULE/dihedral_opls.cpp b/src/MOLECULE/dihedral_opls.cpp index 576f6ca4e6..5ef2d0b7ce 100644 --- a/src/MOLECULE/dihedral_opls.cpp +++ b/src/MOLECULE/dihedral_opls.cpp @@ -168,9 +168,9 @@ void DihedralOPLS::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Dihedral problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MOLECULE/improper_cvff.cpp b/src/MOLECULE/improper_cvff.cpp index a4a6624496..b688a59989 100644 --- a/src/MOLECULE/improper_cvff.cpp +++ b/src/MOLECULE/improper_cvff.cpp @@ -151,9 +151,10 @@ void ImproperCvff::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Improper problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str, + "Improper problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MOLECULE/improper_harmonic.cpp b/src/MOLECULE/improper_harmonic.cpp index 0174ce3c98..527fbf19b8 100644 --- a/src/MOLECULE/improper_harmonic.cpp +++ b/src/MOLECULE/improper_harmonic.cpp @@ -122,9 +122,10 @@ void ImproperHarmonic::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Improper problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str, + "Improper problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/MOLECULE/improper_umbrella.cpp b/src/MOLECULE/improper_umbrella.cpp index 3fc2aad607..7695dab63d 100644 --- a/src/MOLECULE/improper_umbrella.cpp +++ b/src/MOLECULE/improper_umbrella.cpp @@ -128,9 +128,10 @@ void ImproperUmbrella::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Improper problem: %%d %s %%d %%d %%d %%d",BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str, + "Improper problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", diff --git a/src/REAX/fix_reax_bonds.cpp b/src/REAX/fix_reax_bonds.cpp index 66ebb41463..0607acc5b6 100644 --- a/src/REAX/fix_reax_bonds.cpp +++ b/src/REAX/fix_reax_bonds.cpp @@ -121,13 +121,11 @@ void FixReaxBonds::OutputReaxBonds(bigint ntimestep, FILE *fp) MPI_Allreduce(&nsbmax,&nsbmax_most,1,MPI_INT,MPI_MAX,world); if (me == 0) { - char fstr[32]; - sprintf(fstr,"# Timestep %s \n",BIGINT_FORMAT); - fprintf(fp,fstr,ntimestep); + fprintf(fp,"# Timestep " BIGINT_FORMAT " \n",ntimestep); fprintf(fp,"# \n"); fprintf(fp,"# Number of particles %d \n",nparticles_tot); fprintf(fp,"# \n"); - fprintf(fp,"# Max.number of bonds per atom %d with " + fprintf(fp,"# Max number of bonds per atom %d with " "coarse bond order cutoff %5.3f \n", nsbmax_most,cutof3); fprintf(fp,"# Particle connection table and bond orders \n"); diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 6e7b54660a..fe5e74a1d4 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -487,10 +487,8 @@ void NEB::print_status() } if (me_universe == 0) { - char fstr[32]; - sprintf(fstr,"%s %%g %%g ",BIGINT_FORMAT); if (universe->uscreen) { - fprintf(universe->uscreen,fstr,update->ntimestep, + fprintf(universe->uscreen,BIGINT_FORMAT " %g %g ",update->ntimestep, fmaxreplica,fmaxatom); fprintf(universe->uscreen,"%g %g %g ", gradvnorm0,gradvnorm1,gradvnormc); @@ -500,7 +498,7 @@ void NEB::print_status() fprintf(universe->uscreen,"\n"); } if (universe->ulogfile) { - fprintf(universe->ulogfile,fstr,update->ntimestep, + fprintf(universe->ulogfile,BIGINT_FORMAT " %g %g ",update->ntimestep, fmaxreplica,fmaxatom); fprintf(universe->ulogfile,"%g %g %g ", gradvnorm0,gradvnorm1,gradvnormc); diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index 95ebf5e9cb..28ec841d4d 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -378,14 +378,15 @@ void PRD::command(int narg, char **arg) neighbor->ndanger = ndanger; if (me_universe == 0) { - char str[128]; - sprintf(str,"Loop time of %%g on %%d procs for %%d steps with %s atoms\n", - BIGINT_FORMAT); if (universe->uscreen) - fprintf(universe->uscreen,str, + fprintf(universe->uscreen, + "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT + " atoms\n", timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms); if (universe->ulogfile) - fprintf(universe->ulogfile,str, + fprintf(universe->ulogfile, + "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT + " atoms\n", timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms); } @@ -653,10 +654,9 @@ void PRD::log_event() { timer->array[TIME_LOOP] = time_start; if (universe->me == 0) { - char fstr[32]; - sprintf(fstr,"%s %%.3f %%d %%d %%d %%d %%d\n",BIGINT_FORMAT); if (universe->uscreen) - fprintf(universe->uscreen,fstr, + fprintf(universe->uscreen, + BIGINT_FORMAT " %.3f %d %d %d %d %d\n", fix_event->event_timestep, timer->elapsed(TIME_LOOP), fix_event->clock, @@ -664,7 +664,8 @@ void PRD::log_event() fix_event->ncoincident, fix_event->replica_number); if (universe->ulogfile) - fprintf(universe->ulogfile,fstr, + fprintf(universe->ulogfile, + BIGINT_FORMAT " %.3f %d %d %d %d %d\n", fix_event->event_timestep, timer->elapsed(TIME_LOOP), fix_event->clock, diff --git a/src/REPLICA/tad.cpp b/src/REPLICA/tad.cpp index ad4602696f..a70009e474 100644 --- a/src/REPLICA/tad.cpp +++ b/src/REPLICA/tad.cpp @@ -386,14 +386,15 @@ void TAD::command(int narg, char **arg) neighbor->ndanger = ndanger; if (me_universe == 0) { - char str[128]; - sprintf(str,"Loop time of %%g on %%d procs for %%d steps with %s atoms\n", - BIGINT_FORMAT); if (universe->uscreen) - fprintf(universe->uscreen,str, + fprintf(universe->uscreen, + "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT + " atoms\n", timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms); if (universe->ulogfile) - fprintf(universe->ulogfile,str, + fprintf(universe->ulogfile, + "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT + " atoms\n", timer->array[TIME_LOOP],nprocs_universe,nsteps,atom->natoms); } @@ -521,16 +522,14 @@ void TAD::log_event() { timer->array[TIME_LOOP] = time_start; if (universe->me == 0) { - char fstr[32]; - sprintf(fstr,"%s %%.3f %%.3f %%d\n",BIGINT_FORMAT); if (universe->uscreen) - fprintf(universe->uscreen,fstr, + fprintf(universe->uscreen,BIGINT_FORMAT " %.3f %.3f %d\n", fix_event->event_timestep, timer->elapsed(TIME_LOOP), fix_event->tlo, fix_event->event_number); if (universe->ulogfile) - fprintf(universe->ulogfile,fstr, + fprintf(universe->ulogfile,BIGINT_FORMAT " %.3f %.3f %d\n", fix_event->event_timestep, timer->elapsed(TIME_LOOP), fix_event->tlo, @@ -918,22 +917,27 @@ void TAD::compute_tlo(int ievent) // first-replica output about each event if (universe->me == 0) { - char str[128],fstr[128]; double tfrac = 0.0; if (ievent > 0) tfrac = delthi/deltstop; -// sprintf(str, -// "New event: ievent = %d eb = %g t_lo = %g t_hi = %g t_hi/t_stop = %g \n", -// ievent,ebarrier,deltlo,delthi,tfrac); -// error->warning(str); - sprintf(fstr,"New event: t_hi = %s ievent = %%d eb = %%g " - "dt_lo = %%g dt_hi/t_stop = %%g \n",BIGINT_FORMAT); + // char str[128]; + // sprintf(str, + // "New event: ievent = %d eb = %g t_lo = %g t_hi = %g t_hi/t_stop = %g \n", + // ievent,ebarrier,deltlo,delthi,tfrac); + // error->warning(str); + if (screen) - fprintf(screen,fstr,fix_event_list[ievent]->event_timestep, + fprintf(screen, + "New event: t_hi = " BIGINT_FORMAT " ievent = %d eb = %g " + "dt_lo = %g dt_hi/t_stop = %g \n", + fix_event_list[ievent]->event_timestep, ievent,ebarrier,deltlo,tfrac); if (logfile) - fprintf(logfile,fstr,fix_event_list[ievent]->event_timestep, + fprintf(logfile, + "New event: t_hi = " BIGINT_FORMAT " ievent = %d eb = %g " + "dt_lo = %g dt_hi/t_stop = %g \n", + fix_event_list[ievent]->event_timestep, ievent,ebarrier,deltlo,tfrac); } diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index 71ce7698ea..d7ec560fa0 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -692,13 +692,14 @@ void FixSRD::post_force(int vflag) if (ix < 0 || ix >= nbin2x || iy < 0 || iy >= nbin2y || iz < 0 || iz >= nbin2z) { - char fstr[64]; - sprintf(fstr,"SRD particle %%d on step %s\n",BIGINT_FORMAT); - printf(fstr,atom->tag[i],update->ntimestep); - printf("v = %g %g %g\n",v[i][0],v[i][1],v[i][2]); - printf("x = %g %g %g\n",x[i][0],x[i][1],x[i][2]); - printf("ix,iy,iz nx,ny,nz = %d %d %d %d %d %d\n", - ix,iy,iz,nbin2x,nbin2y,nbin2z); + if (screen) { + fprintf(screen,"SRD particle %d on step " BIGINT_FORMAT "\n", + atom->tag[i],update->ntimestep); + fprintf(screen,"v = %g %g %g\n",v[i][0],v[i][1],v[i][2]); + fprintf(screen,"x = %g %g %g\n",x[i][0],x[i][1],x[i][2]); + fprintf(screen,"ix,iy,iz nx,ny,nz = %d %d %d %d %d %d\n", + ix,iy,iz,nbin2x,nbin2y,nbin2z); + } error->one("Fix SRD: bad bin assignment for SRD advection"); } } @@ -1152,20 +1153,19 @@ void FixSRD::collisions_single() if (t_remain > dt) { ninside++; if (insideflag == INSIDE_ERROR || insideflag == INSIDE_WARN) { - char str[128],fstr[128]; - if (type != WALL) { - sprintf(fstr,"SRD particle %%d started " - "inside big particle %%d on step %s bounce %%d\n", - BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + if (type != WALL) + sprintf(str, + "SRD particle %d started " + "inside big particle %d on step " BIGINT_FORMAT + " bounce %d\n", + atom->tag[i],atom->tag[j],update->ntimestep,ibounce+1); + else + sprintf(str, + "SRD particle %d started " + "inside big particle %d on step " BIGINT_FORMAT + " bounce %d\n", atom->tag[i],atom->tag[j],update->ntimestep,ibounce+1); - } else { - sprintf(fstr,"SRD particle %%d started " - "inside wall %%d on step %s bounce %%d\n", - BIGINT_FORMAT); - sprintf(str,fstr, - atom->tag[i],j,update->ntimestep,ibounce+1); - } if (insideflag == INSIDE_ERROR) error->one(str); error->warning(str); } @@ -1296,11 +1296,11 @@ void FixSRD::collisions_multi() if (t_remain > dt || t_remain < 0.0) { ninside++; if (insideflag == INSIDE_ERROR || insideflag == INSIDE_WARN) { - char str[128],fstr[128]; - sprintf(fstr,"SRD particle %%d started " - "inside big particle %%d on step %s bounce %%d\n", - BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "SRD particle %d started " + "inside big particle %d on step " BIGINT_FORMAT + " bounce %d\n", atom->tag[i],atom->tag[j],update->ntimestep,ibounce+1); if (insideflag == INSIDE_ERROR) error->one(str); error->warning(str); @@ -2071,15 +2071,15 @@ int FixSRD::update_srd(int i, double dt, double *xscoll, double *vsnew, if (xs[0] < srdlo[0] || xs[0] > srdhi[0] || xs[1] < srdlo[1] || xs[1] > srdhi[1] || xs[2] < srdlo[2] || xs[2] > srdhi[2]) { - printf("Bad SRD particle move\n"); - char fstr[64]; - sprintf(fstr," particle %%d on proc %%d at timestep %s\n",BIGINT_FORMAT); - printf(fstr,atom->tag[i],me,update->ntimestep); - printf(" xnew %g %g %g\n",xs[0],xs[1],xs[2]); - printf(" srdlo/hi x %g %g\n",srdlo[0],srdhi[0]); - printf(" srdlo/hi y %g %g\n",srdlo[1],srdhi[1]); - printf(" srdlo/hi z %g %g\n",srdlo[2],srdhi[2]); - error->warning("Fix srd particle moved outside valid domain"); + if (screen) { + error->warning("Fix srd particle moved outside valid domain"); + fprintf(screen," particle %d on proc %d at timestep " BIGINT_FORMAT, + atom->tag[i],me,update->ntimestep); + fprintf(screen," xnew %g %g %g\n",xs[0],xs[1],xs[2]); + fprintf(screen," srdlo/hi x %g %g\n",srdlo[0],srdhi[0]); + fprintf(screen," srdlo/hi y %g %g\n",srdlo[1],srdhi[1]); + fprintf(screen," srdlo/hi z %g %g\n",srdlo[2],srdhi[2]); + } } if (triclinic) domain->lamda2x(xs,xs); @@ -2307,11 +2307,11 @@ void FixSRD::parameterize() // print SRD parameters if (me == 0) { - char str[64]; - sprintf(str," SRD/big particles = %s %s\n",BIGINT_FORMAT,BIGINT_FORMAT); if (screen) { fprintf(screen,"SRD info:\n"); - fprintf(screen,str,nsrd,mbig); + fprintf(screen, + " SRD/big particles = " BIGINT_FORMAT " " BIGINT_FORMAT "\n", + nsrd,mbig); fprintf(screen," big particle diameter max/min = %g %g\n", maxbigdiam,minbigdiam); fprintf(screen," SRD temperature & lamda = %g %g\n", @@ -2326,7 +2326,9 @@ void FixSRD::parameterize() } if (logfile) { fprintf(logfile,"SRD info:\n"); - fprintf(logfile,str,nsrd,mbig); + fprintf(logfile, + " SRD/big particles = " BIGINT_FORMAT " " BIGINT_FORMAT "\n", + nsrd,mbig); fprintf(logfile," big particle diameter max/min = %g %g\n", maxbigdiam,minbigdiam); fprintf(logfile," SRD temperature & lamda = %g %g\n", diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 60f823909c..11eda7d7ed 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -176,12 +176,12 @@ void CreateAtoms::command(int narg, char **arg) // print status if (comm->me == 0) { - char str[32]; - sprintf(str,"Created %s atoms\n",BIGINT_FORMAT); if (screen) - fprintf(screen,str,atom->natoms-natoms_previous); + fprintf(screen,"Created " BIGINT_FORMAT " atoms\n", + atom->natoms-natoms_previous); if (logfile) - fprintf(logfile,str,atom->natoms-natoms_previous); + fprintf(logfile,"Created " BIGINT_FORMAT " atoms\n", + atom->natoms-natoms_previous); } // reset simulation now that more atoms are defined diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index f140c52372..d92085ffe0 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -105,11 +105,12 @@ void DeleteAtoms::command(int narg, char **arg) bigint ndelete = natoms_previous - atom->natoms; if (comm->me == 0) { - char str[64]; - sprintf(str,"Deleted %s atoms, new total = %s\n", - BIGINT_FORMAT,BIGINT_FORMAT); - if (screen) fprintf(screen,str,ndelete,atom->natoms); - if (logfile) fprintf(logfile,str,ndelete,atom->natoms); + if (screen) fprintf(screen,"Deleted " BIGINT_FORMAT + " atoms, new total = " BIGINT_FORMAT "\n", + ndelete,atom->natoms); + if (logfile) fprintf(logfile,"Deleted " BIGINT_FORMAT + " atoms, new total = " BIGINT_FORMAT "\n", + ndelete,atom->natoms); } } diff --git a/src/delete_bonds.cpp b/src/delete_bonds.cpp index 0b1ff6daec..0c3a0e14d6 100644 --- a/src/delete_bonds.cpp +++ b/src/delete_bonds.cpp @@ -447,33 +447,48 @@ void DeleteBonds::command(int narg, char **arg) if (comm->me == 0) { if (atom->avec->bonds_allow) { char str[128]; - sprintf(str," %s total bonds, %s turned on, %s turned off\n", - BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nbonds,bond_on,bond_off); - if (logfile) fprintf(logfile,str,atom->nbonds,bond_on,bond_off); + if (screen) fprintf(screen, + " " BIGINT_FORMAT " total bonds, " BIGINT_FORMAT + " turned on, " BIGINT_FORMAT " turned off\n", + atom->nbonds,bond_on,bond_off); + if (logfile) fprintf(logfile, + " " BIGINT_FORMAT " total bonds, " BIGINT_FORMAT + " turned on, " BIGINT_FORMAT " turned off\n", + atom->nbonds,bond_on,bond_off); } if (atom->avec->angles_allow) { - char str[128]; - sprintf(str," %s total angles, %s turned on, %s turned off\n", - BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nangles,angle_on,angle_off); - if (logfile) fprintf(logfile,str,atom->nangles,angle_on,angle_off); + if (screen) fprintf(screen, + " " BIGINT_FORMAT " total angles, " BIGINT_FORMAT + " turned on, " BIGINT_FORMAT " turned off\n", + atom->nangles,angle_on,angle_off); + if (logfile) fprintf(logfile, + " " BIGINT_FORMAT " total angles, " BIGINT_FORMAT + " turned on, " BIGINT_FORMAT " turned off\n", + atom->nangles,angle_on,angle_off); } if (atom->avec->dihedrals_allow) { - char str[128]; - sprintf(str," %s total dihedrals, %s turned on, %s turned off\n", - BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->ndihedrals,dihedral_on,dihedral_off); - if (logfile) fprintf(logfile,str, - atom->ndihedrals,dihedral_on,dihedral_off); + if (screen) fprintf(screen, + " " BIGINT_FORMAT " total dihedrals, " + BIGINT_FORMAT " turned on, " BIGINT_FORMAT + " turned off\n", + atom->ndihedrals,dihedral_on,dihedral_off); + if (logfile) fprintf(logfile, + " " BIGINT_FORMAT " total dihedrals, " + BIGINT_FORMAT " turned on, " BIGINT_FORMAT + " turned off\n", + atom->ndihedrals,dihedral_on,dihedral_off); } if (atom->avec->impropers_allow) { - char str[128]; - sprintf(str," %s total impropers, %s turned on, %s turned off\n", - BIGINT_FORMAT,BIGINT_FORMAT,BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nimpropers,improper_on,improper_off); - if (logfile) fprintf(logfile,str, - atom->nimpropers,improper_on,improper_off); + if (screen) fprintf(screen, + " " BIGINT_FORMAT " total impropers, " + BIGINT_FORMAT " turned on, " BIGINT_FORMAT + " turned off\n", + atom->nimpropers,improper_on,improper_off); + if (logfile) fprintf(logfile, + " " BIGINT_FORMAT " total impropers, " + BIGINT_FORMAT " turned on, " BIGINT_FORMAT + " turned off\n", + atom->nimpropers,improper_on,improper_off); } } diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp index 1e93c919bf..64cb195df6 100644 --- a/src/displace_atoms.cpp +++ b/src/displace_atoms.cpp @@ -215,10 +215,9 @@ 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) { - char fstr[64],str[128]; - sprintf(fstr,"Lost atoms via displace_atoms: original %s current %s", - BIGINT_FORMAT,BIGINT_FORMAT); - sprintf(str,fstr,atom->natoms,natoms); + char str[128]; + sprintf(str,"Lost atoms via displace_atoms: original " BIGINT_FORMAT + " current " BIGINT_FORMAT,atom->natoms,natoms); error->all(str); } } diff --git a/src/displace_box.cpp b/src/displace_box.cpp index e80ddbbd3f..e8b88fb314 100644 --- a/src/displace_box.cpp +++ b/src/displace_box.cpp @@ -381,10 +381,9 @@ void DisplaceBox::command(int narg, char **arg) bigint nblocal = atom->nlocal; MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); if (natoms != atom->natoms) { - char fstr[64],str[128]; - sprintf(fstr,"Lost atoms via displace_box: original %s current %s", - BIGINT_FORMAT,BIGINT_FORMAT); - sprintf(str,fstr,atom->natoms,natoms); + char str[128]; + sprintf(str,"Lost atoms via displace_box: original " BIGINT_FORMAT + " current " BIGINT_FORMAT,atom->natoms,natoms); error->all(str); } } diff --git a/src/dump.cpp b/src/dump.cpp index a382c7fa92..6bd3018a0f 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -359,9 +359,8 @@ void Dump::openfile() filecurrent = new char[strlen(filename) + 16]; char *ptr = strchr(filename,'*'); *ptr = '\0'; - char fstr[16]; - sprintf(fstr,"%%s%s%%s",BIGINT_FORMAT); - sprintf(filecurrent,fstr,filename,update->ntimestep,ptr+1); + sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", + filename,update->ntimestep,ptr+1); *ptr = '*'; } diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 11152f5b72..9d33cb37b1 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -206,9 +206,9 @@ void DumpAtom::header_binary_triclinic(bigint ndump) void DumpAtom::header_item(bigint ndump) { fprintf(fp,"ITEM: TIMESTEP\n"); - fprintf(fp,BIGINT_FORMAT_NL,update->ntimestep); + fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); - fprintf(fp,BIGINT_FORMAT_NL,ndump); + fprintf(fp,BIGINT_FORMAT "\n",ndump); fprintf(fp,"ITEM: BOX BOUNDS\n"); fprintf(fp,"%g %g\n",boxxlo,boxxhi); fprintf(fp,"%g %g\n",boxylo,boxyhi); @@ -221,9 +221,9 @@ void DumpAtom::header_item(bigint ndump) void DumpAtom::header_item_triclinic(bigint ndump) { fprintf(fp,"ITEM: TIMESTEP\n"); - fprintf(fp,BIGINT_FORMAT_NL,update->ntimestep); + fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); - fprintf(fp,BIGINT_FORMAT_NL,ndump); + fprintf(fp,BIGINT_FORMAT "\n",ndump); fprintf(fp,"ITEM: BOX BOUNDS xy xz yz\n"); fprintf(fp,"%g %g %g\n",boxxlo,boxxhi,boxxy); fprintf(fp,"%g %g %g\n",boxylo,boxyhi,boxxz); diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 2ee551c1d7..3e0b2c192f 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -290,9 +290,9 @@ void DumpCustom::header_binary_triclinic(bigint ndump) void DumpCustom::header_item(bigint ndump) { fprintf(fp,"ITEM: TIMESTEP\n"); - fprintf(fp,BIGINT_FORMAT_NL,update->ntimestep); + fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); - fprintf(fp,BIGINT_FORMAT_NL,ndump); + fprintf(fp,BIGINT_FORMAT "\n",ndump); fprintf(fp,"ITEM: BOX BOUNDS\n"); fprintf(fp,"%g %g\n",boxxlo,boxxhi); fprintf(fp,"%g %g\n",boxylo,boxyhi); @@ -305,9 +305,9 @@ void DumpCustom::header_item(bigint ndump) void DumpCustom::header_item_triclinic(bigint ndump) { fprintf(fp,"ITEM: TIMESTEP\n"); - fprintf(fp,BIGINT_FORMAT_NL,update->ntimestep); + fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); - fprintf(fp,BIGINT_FORMAT_NL,ndump); + fprintf(fp,BIGINT_FORMAT "\n",ndump); fprintf(fp,"ITEM: BOX BOUNDS xy xz yz\n"); fprintf(fp,"%g %g %g\n",boxxlo,boxxhi,boxxy); fprintf(fp,"%g %g %g\n",boxylo,boxyhi,boxxz); diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 0230a0ac1c..811d06bc22 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -191,9 +191,9 @@ void DumpLocal::write_header(bigint ndump) { if (me == 0) { fprintf(fp,"ITEM: TIMESTEP\n"); - fprintf(fp,BIGINT_FORMAT_NL,update->ntimestep); + fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF %s\n",label); - fprintf(fp,BIGINT_FORMAT_NL,ndump); + fprintf(fp,BIGINT_FORMAT "\n",ndump); fprintf(fp,"ITEM: %s %s\n",label,columns); } } diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index 06c0686e7b..d9814cdf7a 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -61,7 +61,7 @@ void DumpXYZ::init_style() void DumpXYZ::write_header(bigint n) { if (me == 0) { - fprintf(fp,BIGINT_FORMAT_NL,n); + fprintf(fp,BIGINT_FORMAT "\n",n); fprintf(fp,"Atoms\n"); } } diff --git a/src/finish.cpp b/src/finish.cpp index 92496b5b9a..b7efb30dc4 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -89,12 +89,15 @@ void Finish::end(int flag) MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); if (me == 0) { - char str[128]; - sprintf(str,"Loop time of %%g on %%d procs for %%d steps with %s atoms\n", - BIGINT_FORMAT); - if (screen) fprintf(screen,str,time_loop,nprocs,update->nsteps,natoms); - if (logfile) fprintf(logfile,str,time_loop,nprocs,update->nsteps,natoms); - } + if (screen) fprintf(screen, + "Loop time of %g on %d procs for %d steps with " + BIGINT_FORMAT " atoms\n", + time_loop,nprocs,update->nsteps,natoms); + if (logfile) fprintf(logfile, + "Loop time of %g on %d procs for %d steps with " + BIGINT_FORMAT " atoms\n", + time_loop,nprocs,update->nsteps,natoms); + } if (time_loop == 0.0) time_loop = 1.0; } diff --git a/src/fix_ave_correlate.cpp b/src/fix_ave_correlate.cpp index b962a0d590..4984c587cf 100644 --- a/src/fix_ave_correlate.cpp +++ b/src/fix_ave_correlate.cpp @@ -467,9 +467,7 @@ void FixAveCorrelate::end_of_step() // output to file if (fp && me == 0) { - char fstr[16]; - sprintf(fstr,"%s %%d\n",BIGINT_FORMAT); - fprintf(fp,fstr,ntimestep,nrepeat); + fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrepeat); for (i = 0; i < nrepeat; i++) { fprintf(fp,"%d %d %d",i+1,i*nevery,count[i]); if (count[i]) diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index b0c2345839..984d5022ae 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -789,9 +789,7 @@ void FixAveHisto::end_of_step() // output result to file if (fp && me == 0) { - char fstr[32]; - sprintf(fstr,"%s %%d %%g %%g %%g %%g\n",BIGINT_FORMAT); - fprintf(fp,fstr,ntimestep,nbins, + fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins, stats_total[0],stats_total[1],stats_total[2],stats_total[3]); if (stats_total[0] != 0.0) for (i = 0; i < nbins; i++) diff --git a/src/fix_ave_spatial.cpp b/src/fix_ave_spatial.cpp index 760464223b..511e429faa 100644 --- a/src/fix_ave_spatial.cpp +++ b/src/fix_ave_spatial.cpp @@ -789,9 +789,7 @@ void FixAveSpatial::end_of_step() // output result to file if (fp && me == 0) { - char fstr[16]; - sprintf(fstr,"%s %%d\n",BIGINT_FORMAT); - fprintf(fp,fstr,ntimestep,nbins); + fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nbins); if (ndim == 1) for (m = 0; m < nbins; m++) { fprintf(fp," %d %g %g",m+1,coord[m][0], diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index a2138243c6..d3c4f3207b 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -770,9 +770,7 @@ void FixAveTime::invoke_vector(bigint ntimestep) // output result to file if (fp && me == 0) { - char fstr[16]; - sprintf(fstr,"%s %%d\n",BIGINT_FORMAT); - fprintf(fp,fstr,ntimestep,nrows); + fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrows); for (i = 0; i < nrows; i++) { fprintf(fp,"%d",i+1); for (j = 0; j < nvalues; j++) fprintf(fp," %g",array_total[i][j]/norm); diff --git a/src/fix_orient_fcc.cpp b/src/fix_orient_fcc.cpp index cf91d3f0ae..061884ff56 100644 --- a/src/fix_orient_fcc.cpp +++ b/src/fix_orient_fcc.cpp @@ -403,11 +403,14 @@ void FixOrientFCC::post_force(int vflag) MPI_Allreduce(&maxcount,&max,1,MPI_INT,MPI_MAX,world); if (me == 0) { - char str[64]; - sprintf(str,"orient step %%d: %s atoms have %%d neighbors\n", - BIGINT_FORMAT); - if (screen) fprintf(screen,str,update->ntimestep,atom->natoms,total); - if (logfile) fprintf(logfile,str,update->ntimestep,atom->natoms,total); + if (screen) fprintf(screen, + "orient step %d: " BIGINT_FORMAT + " atoms have %d neighbors\n", + update->ntimestep,atom->natoms,total); + if (logfile) fprintf(logfile, + "orient step %d: " BIGINT_FORMAT + " atoms have %d neighbors\n", + update->ntimestep,atom->natoms,total); if (screen) fprintf(screen," neighs: min = %d, max = %d, ave = %g\n", min,max,ave); diff --git a/src/fix_shake.cpp b/src/fix_shake.cpp index cf38f11e4d..70e1fbb4e6 100644 --- a/src/fix_shake.cpp +++ b/src/fix_shake.cpp @@ -454,10 +454,9 @@ void FixShake::pre_neighbor() atom1 = atom->map(shake_atom[i][0]); atom2 = atom->map(shake_atom[i][1]); if (atom1 == -1 || atom2 == -1) { - char str[128],fstr[64]; - sprintf(fstr,"Shake atoms %%d %%d missing on proc %%d at step %s", - BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Shake atoms %d %d missing on proc %d at step " BIGINT_FORMAT, shake_atom[i][0],shake_atom[i][1],me,update->ntimestep); error->one(str); } @@ -467,10 +466,10 @@ void FixShake::pre_neighbor() atom2 = atom->map(shake_atom[i][1]); atom3 = atom->map(shake_atom[i][2]); if (atom1 == -1 || atom2 == -1 || atom3 == -1) { - char str[128],fstr[64]; - sprintf(fstr,"Shake atoms %%d %%d %%d missing on proc %%d at step %s", - BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Shake atoms %d %d %d missing on proc %d at step " + BIGINT_FORMAT, shake_atom[i][0],shake_atom[i][1],shake_atom[i][2], me,update->ntimestep); error->one(str); @@ -482,11 +481,10 @@ void FixShake::pre_neighbor() atom3 = atom->map(shake_atom[i][2]); atom4 = atom->map(shake_atom[i][3]); if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) { - char str[128],fstr[64]; - sprintf(fstr, - "Shake atoms %%d %%d %%d %%d missing on proc %%d at step %s", - BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Shake atoms %d %d %d %d missing on proc %d at step " + BIGINT_FORMAT, shake_atom[i][0],shake_atom[i][1], shake_atom[i][2],shake_atom[i][3], me,update->ntimestep); @@ -2147,10 +2145,11 @@ void FixShake::stats() // print stats only for non-zero counts if (me == 0) { - char fstr[64]; - sprintf(fstr,"SHAKE stats (type/ave/delta) on step %s\n",BIGINT_FORMAT); + if (screen) { - fprintf(screen,fstr,update->ntimestep); + fprintf(screen, + "SHAKE stats (type/ave/delta) on step " BIGINT_FORMAT "\n", + update->ntimestep); for (i = 1; i < nb; i++) if (b_count_all[i]) fprintf(screen," %d %g %g\n",i, @@ -2161,7 +2160,9 @@ void FixShake::stats() a_ave_all[i]/a_count_all[i],a_max_all[i]-a_min_all[i]); } if (logfile) { - fprintf(logfile,fstr,update->ntimestep); + fprintf(logfile, + "SHAKE stats (type/ave/delta) on step " BIGINT_FORMAT "\n", + update->ntimestep); for (i = 0; i < nb; i++) if (b_count_all[i]) fprintf(logfile," %d %g %g\n",i, diff --git a/src/fix_tmd.cpp b/src/fix_tmd.cpp index f976fd18ed..24cb8bc8fc 100644 --- a/src/fix_tmd.cpp +++ b/src/fix_tmd.cpp @@ -285,9 +285,9 @@ void FixTMD::initial_integrate(int vflag) work_lambda += lambda*(rho_target - rho_old); if (!(update->ntimestep % nfileevery) && (previous_stat != update->ntimestep)) { - char fstr[64]; - sprintf(fstr,"%s %%g %%g %%g %%g %%g %%g %%g\n",BIGINT_FORMAT); - fprintf(fp,fstr,update->ntimestep,rho_target,rho_old, + fprintf(fp, + BIGINT_FORMAT " %g %g %g %g %g %g %g\n", + update->ntimestep,rho_target,rho_old, gamma_back,gamma_forward,lambda,work_lambda,work_analytical); fflush(fp); previous_stat = update->ntimestep; diff --git a/src/lmptype.h b/src/lmptype.h index 6d45da2709..3dc59b0af0 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -58,8 +58,6 @@ typedef int64_t bigint; #define TAGINT_FORMAT "%d" #define BIGINT_FORMAT "%lld" -#define TAGINT_FORMAT_NL "%d\n" -#define BIGINT_FORMAT_NL "%lld\n" #define ATOTAGINT atoi #define ATOBIGINT atoll @@ -82,8 +80,6 @@ typedef int64_t bigint; #define TAGINT_FORMAT "%lld" #define BIGINT_FORMAT "%lld" -#define TAGINT_FORMAT_NL "%lld\n" -#define BIGINT_FORMAT_NL "%lld\n" #define ATOTAGINT atoll #define ATOBIGINT atoll @@ -106,8 +102,6 @@ typedef int bigint; #define TAGINT_FORMAT "%d" #define BIGINT_FORMAT "%d" -#define TAGINT_FORMAT_NL "%d\n" -#define BIGINT_FORMAT_NL "%d\n" #define ATOTAGINT atoi #define ATOBIGINT atoi diff --git a/src/neigh_bond.cpp b/src/neigh_bond.cpp index 6383dae8fd..e89c31cf37 100644 --- a/src/neigh_bond.cpp +++ b/src/neigh_bond.cpp @@ -42,10 +42,10 @@ void Neighbor::bond_all() for (m = 0; m < num_bond[i]; m++) { atom1 = atom->map(bond_atom[i][m]); if (atom1 == -1) { - char str[128],fstr[64]; - sprintf(fstr,"Bond atoms %%d %%d missing on proc %%d at step %s", - BIGINT_FORMAT); - sprintf(str,fstr,tag[i],bond_atom[i][m],me,update->ntimestep); + char str[128]; + sprintf(str, + "Bond atoms %d %d missing on proc %d at step " BIGINT_FORMAT, + tag[i],bond_atom[i][m],me,update->ntimestep); error->one(str); } if (newton_bond || i < atom1) { @@ -82,10 +82,10 @@ void Neighbor::bond_partial() if (bond_type[i][m] <= 0) continue; atom1 = atom->map(bond_atom[i][m]); if (atom1 == -1) { - char str[128],fstr[64]; - sprintf(fstr,"Bond atoms %%d %%d missing on proc %%d at step %s", - BIGINT_FORMAT); - sprintf(str,fstr,tag[i],bond_atom[i][m],me,update->ntimestep); + char str[128]; + sprintf(str, + "Bond atoms %d %d missing on proc %d at step " BIGINT_FORMAT, + tag[i],bond_atom[i][m],me,update->ntimestep); error->one(str); } if (newton_bond || i < atom1) { @@ -124,10 +124,10 @@ void Neighbor::angle_all() atom2 = atom->map(angle_atom2[i][m]); atom3 = atom->map(angle_atom3[i][m]); if (atom1 == -1 || atom2 == -1 || atom3 == -1) { - char str[128],fstr[64]; - sprintf(fstr,"Angle atoms %%d %%d %%d missing on proc %%d at step %s", - BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Angle atoms %d %d %d missing on proc %d at step " + BIGINT_FORMAT, angle_atom1[i][m],angle_atom2[i][m],angle_atom3[i][m], me,update->ntimestep); error->one(str); @@ -170,10 +170,10 @@ void Neighbor::angle_partial() atom2 = atom->map(angle_atom2[i][m]); atom3 = atom->map(angle_atom3[i][m]); if (atom1 == -1 || atom2 == -1 || atom3 == -1) { - char str[128],fstr[64]; - sprintf(fstr,"Angle atoms %%d %%d %%d missing on proc %%d at step %s", - BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Angle atoms %d %d %d missing on proc %d at step " + BIGINT_FORMAT, angle_atom1[i][m],angle_atom2[i][m],angle_atom3[i][m], me,update->ntimestep); error->one(str); @@ -217,10 +217,10 @@ void Neighbor::dihedral_all() atom3 = atom->map(dihedral_atom3[i][m]); atom4 = atom->map(dihedral_atom4[i][m]); if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) { - char str[128],fstr[128]; - sprintf(fstr,"Dihedral atoms %%d %%d %%d %%d " - "missing on proc %%d at step %s",BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Dihedral atoms %d %d %d %d missing on proc %d at step " + BIGINT_FORMAT, dihedral_atom1[i][m],dihedral_atom2[i][m], dihedral_atom3[i][m],dihedral_atom4[i][m], me,update->ntimestep); @@ -269,10 +269,10 @@ void Neighbor::dihedral_partial() atom3 = atom->map(dihedral_atom3[i][m]); atom4 = atom->map(dihedral_atom4[i][m]); if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) { - char str[128],fstr[128]; - sprintf(fstr,"Dihedral atoms %%d %%d %%d %%d " - "missing on proc %%d at step %s",BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Dihedral atoms %d %d %d %d missing on proc %d at step " + BIGINT_FORMAT, dihedral_atom1[i][m],dihedral_atom2[i][m], dihedral_atom3[i][m],dihedral_atom4[i][m], me,update->ntimestep); @@ -320,10 +320,10 @@ void Neighbor::improper_all() atom3 = atom->map(improper_atom3[i][m]); atom4 = atom->map(improper_atom4[i][m]); if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) { - char str[128],fstr[128]; - sprintf(fstr,"Improper atoms %%d %%d %%d %%d " - "missing on proc %%d at step %s",BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Improper atoms %d %d %d %d missing on proc %d at step " + BIGINT_FORMAT, improper_atom1[i][m],improper_atom2[i][m], improper_atom3[i][m],improper_atom4[i][m], me,update->ntimestep); @@ -372,10 +372,10 @@ void Neighbor::improper_partial() atom3 = atom->map(improper_atom3[i][m]); atom4 = atom->map(improper_atom4[i][m]); if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) { - char str[128],fstr[128]; - sprintf(fstr,"Improper atoms %%d %%d %%d %%d " - "missing on proc %%d at step %s",BIGINT_FORMAT); - sprintf(str,fstr, + char str[128]; + sprintf(str, + "Improper atoms %d %d %d %d missing on proc %d at step " + BIGINT_FORMAT, improper_atom1[i][m],improper_atom2[i][m], improper_atom3[i][m],improper_atom4[i][m], me,update->ntimestep); diff --git a/src/output.cpp b/src/output.cpp index a9b7018487..97de70438a 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -273,9 +273,7 @@ void Output::write(bigint ntimestep) char *file = new char[strlen(restart1) + 16]; char *ptr = strchr(restart1,'*'); *ptr = '\0'; - char fstr[16]; - sprintf(fstr,"%%s%s%%s",BIGINT_FORMAT); - sprintf(file,fstr,restart1,ntimestep,ptr+1); + sprintf(file,"%s" BIGINT_FORMAT "%s",restart1,ntimestep,ptr+1); *ptr = '*'; restart->write(file); delete [] file; @@ -336,9 +334,7 @@ void Output::write_restart(bigint ntimestep) char *file = new char[strlen(restart1) + 16]; char *ptr = strchr(restart1,'*'); *ptr = '\0'; - char fstr[16]; - sprintf(fstr,"%%s%s%%s",BIGINT_FORMAT); - sprintf(file,fstr,restart1,ntimestep,ptr+1); + sprintf(file,"%s" BIGINT_FORMAT "%s",restart1,ntimestep,ptr+1); *ptr = '*'; restart->write(file); delete [] file; diff --git a/src/read_data.cpp b/src/read_data.cpp index b38f228698..c1a3f010e5 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -452,10 +452,8 @@ void ReadData::atoms() MPI_Allreduce(&tmp,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); if (me == 0) { - char str[32]; - sprintf(str," %s atoms\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,natoms); - if (logfile) fprintf(logfile,str,natoms); + if (screen) fprintf(screen," " BIGINT_FORMAT " atoms\n",natoms); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",natoms); } if (natoms != atom->natoms) error->all("Did not assign all atoms correctly"); @@ -545,10 +543,8 @@ void ReadData::velocities() } if (me == 0) { - char str[32]; - sprintf(str," %s velocities\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,natoms); - if (logfile) fprintf(logfile,str,natoms); + if (screen) fprintf(screen," " BIGINT_FORMAT " velocities\n",natoms); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " velocities\n",natoms); } } @@ -591,10 +587,8 @@ void ReadData::bonds() if (!force->newton_bond) factor = 2; if (me == 0) { - char str[32]; - sprintf(str," %s bonds\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,sum/factor); - if (logfile) fprintf(logfile,str,sum/factor); + if (screen) fprintf(screen," " BIGINT_FORMAT " bonds\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " bonds\n",sum/factor); } if (sum != factor*atom->nbonds) error->all("Bonds assigned incorrectly"); } @@ -638,10 +632,8 @@ void ReadData::angles() if (!force->newton_bond) factor = 3; if (me == 0) { - char str[32]; - sprintf(str," %s angles\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,sum/factor); - if (logfile) fprintf(logfile,str,sum/factor); + if (screen) fprintf(screen," " BIGINT_FORMAT " angles\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " angles\n",sum/factor); } if (sum != factor*atom->nangles) error->all("Angles assigned incorrectly"); } @@ -685,10 +677,8 @@ void ReadData::dihedrals() if (!force->newton_bond) factor = 4; if (me == 0) { - char str[32]; - sprintf(str," %s dihedrals\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,sum/factor); - if (logfile) fprintf(logfile,str,sum/factor); + if (screen) fprintf(screen," " BIGINT_FORMAT " dihedrals\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " dihedrals\n",sum/factor); } if (sum != factor*atom->ndihedrals) error->all("Dihedrals assigned incorrectly"); @@ -733,10 +723,8 @@ void ReadData::impropers() if (!force->newton_bond) factor = 4; if (me == 0) { - char str[32]; - sprintf(str," %s impropers\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,sum/factor); - if (logfile) fprintf(logfile,str,sum/factor); + if (screen) fprintf(screen," " BIGINT_FORMAT " impropers\n",sum/factor); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " impropers\n",sum/factor); } if (sum != factor*atom->nimpropers) error->all("Impropers assigned incorrectly"); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 15ddcf72ec..51b4783069 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -299,38 +299,34 @@ void ReadRestart::command(int narg, char **arg) MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); if (me == 0) { - char str[32]; - sprintf(str," %s atoms\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,natoms); - if (logfile) fprintf(logfile,str,natoms); + if (screen) fprintf(screen," " BIGINT_FORMAT " atoms\n",natoms); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",natoms); } if (natoms != atom->natoms) error->all("Did not assign all atoms correctly"); if (me == 0) { if (atom->nbonds) { - char str[32]; - sprintf(str," %s bonds\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nbonds); - if (logfile) fprintf(logfile,str,atom->nbonds); + if (screen) fprintf(screen," " BIGINT_FORMAT " bonds\n",atom->nbonds); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " bonds\n",atom->nbonds); } if (atom->nangles) { - char str[32]; - sprintf(str," %s angles\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nangles); - if (logfile) fprintf(logfile,str,atom->nangles); + if (screen) fprintf(screen," " BIGINT_FORMAT " angles\n", + atom->nangles); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " angles\n", + atom->nangles); } if (atom->ndihedrals) { - char str[32]; - sprintf(str," %s dihedrals\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->ndihedrals); - if (logfile) fprintf(logfile,str,atom->ndihedrals); + if (screen) fprintf(screen," " BIGINT_FORMAT " dihedrals\n", + atom->ndihedrals); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " dihedrals\n", + atom->ndihedrals); } if (atom->nimpropers) { - char str[32]; - sprintf(str," %s impropers\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nimpropers); - if (logfile) fprintf(logfile,str,atom->nimpropers); + if (screen) fprintf(screen," " BIGINT_FORMAT " impropers\n", + atom->nimpropers); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " impropers\n", + atom->nimpropers); } } diff --git a/src/replicate.cpp b/src/replicate.cpp index 5ade979e61..d0a15af918 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -370,39 +370,35 @@ void Replicate::command(int narg, char **arg) MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); if (me == 0) { - char str[32]; - sprintf(str," %s atoms\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,natoms); - if (logfile) fprintf(logfile,str,natoms); + if (screen) fprintf(screen," " BIGINT_FORMAT " atoms\n",natoms); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",natoms); } if (natoms != atom->natoms) error->all("Replicate did not assign all atoms correctly"); - + if (me == 0) { if (atom->nbonds) { - char str[32]; - sprintf(str," %s bonds\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nbonds); - if (logfile) fprintf(logfile,str,atom->nbonds); + if (screen) fprintf(screen," " BIGINT_FORMAT " bonds\n",atom->nbonds); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " bonds\n",atom->nbonds); } if (atom->nangles) { - char str[32]; - sprintf(str," %s angles\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nangles); - if (logfile) fprintf(logfile,str,atom->nangles); + if (screen) fprintf(screen," " BIGINT_FORMAT " angles\n", + atom->nangles); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " angles\n", + atom->nangles); } if (atom->ndihedrals) { - char str[32]; - sprintf(str," %s dihedrals\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->ndihedrals); - if (logfile) fprintf(logfile,str,atom->ndihedrals); + if (screen) fprintf(screen," " BIGINT_FORMAT " dihedrals\n", + atom->ndihedrals); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " dihedrals\n", + atom->ndihedrals); } if (atom->nimpropers) { - char str[32]; - sprintf(str," %s impropers\n",BIGINT_FORMAT); - if (screen) fprintf(screen,str,atom->nimpropers); - if (logfile) fprintf(logfile,str,atom->nimpropers); + if (screen) fprintf(screen," " BIGINT_FORMAT " impropers\n", + atom->nimpropers); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " impropers\n", + atom->nimpropers); } } diff --git a/src/thermo.cpp b/src/thermo.cpp index b3d6cece7f..4a7ae0afc8 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -369,19 +369,19 @@ bigint Thermo::lost_check() // error message if (lostflag == ERROR) { - char fstr[64],str[64]; - sprintf(fstr, - "Lost atoms: original %s current %s",BIGINT_FORMAT,BIGINT_FORMAT); - sprintf(str,fstr,atom->natoms,ntotal); + char str[64]; + sprintf(str, + "Lost atoms: original " BIGINT_FORMAT " current " BIGINT_FORMAT, + atom->natoms,ntotal); error->all(str); } // warning message - char fstr[64],str[64]; - sprintf(fstr, - "Lost atoms: original %s current %s",BIGINT_FORMAT,BIGINT_FORMAT); - sprintf(str,fstr,atom->natoms,ntotal); + char str[64]; + sprintf(str, + "Lost atoms: original " BIGINT_FORMAT " current " BIGINT_FORMAT, + atom->natoms,ntotal); if (me == 0) error->warning(str,0); lostbefore = 1; return ntotal; @@ -514,8 +514,8 @@ void Thermo::modify_params(int narg, char **arg) if (ptr == NULL) error->all("Thermo_modify int format does not contain d character"); *ptr = '\0'; - sprintf(format_bigint_user,"%s%s%s",format_int_user, - BIGINT_FORMAT,ptr+1); + sprintf(format_bigint_user,"%s" BIGINT_FORMAT "%s", + format_int_user,ptr+1); *ptr = 'd'; } else if (strcmp(arg[iarg+1],"float") == 0) { if (format_float_user) delete [] format_float_user; diff --git a/src/write_restart.cpp b/src/write_restart.cpp index 6fdb24998d..5b19ada3e1 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -86,9 +86,7 @@ void WriteRestart::command(int narg, char **arg) if (ptr = strchr(arg[0],'*')) { *ptr = '\0'; - char fstr[16]; - sprintf(fstr,"%%s%s%%s",BIGINT_FORMAT); - sprintf(file,fstr,arg[0],update->ntimestep,ptr+1); + sprintf(file,"%s" BIGINT_FORMAT "%s",arg[0],update->ntimestep,ptr+1); } else strcpy(file,arg[0]); // init entire system since comm->exchange is done From 9b00fc4b997d3a3871e70b64ff5ae0fb68d879d5 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 16:04:55 +0000 Subject: [PATCH 3/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5548 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/CLASS2/improper_class2.cpp | 9 ++++----- src/fix_orient_fcc.cpp | 8 ++++---- src/thermo.cpp | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/CLASS2/improper_class2.cpp b/src/CLASS2/improper_class2.cpp index 716ced12f5..7f0f31bc1f 100644 --- a/src/CLASS2/improper_class2.cpp +++ b/src/CLASS2/improper_class2.cpp @@ -157,13 +157,12 @@ void ImproperClass2::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128],fstr[64]; - sprintf(fstr,"Improper problem: %%d %s %%d %%d %%d %%d", - BIGINT_FORMAT); - sprintf(str,fstr,me,update->ntimestep, + char str[128]; + sprintf(str, + "Improper problem: %d " BIGINT_FORMAT " %d %d %d %d", + me,update->ntimestep, atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); error->warning(str,0); - error->warning(str,0); fprintf(screen," 1st atom: %d %g %g %g\n", me,x[i1][0],x[i1][1],x[i1][2]); fprintf(screen," 2nd atom: %d %g %g %g\n", diff --git a/src/fix_orient_fcc.cpp b/src/fix_orient_fcc.cpp index 061884ff56..a02558040c 100644 --- a/src/fix_orient_fcc.cpp +++ b/src/fix_orient_fcc.cpp @@ -404,13 +404,13 @@ void FixOrientFCC::post_force(int vflag) if (me == 0) { if (screen) fprintf(screen, - "orient step %d: " BIGINT_FORMAT + "orient step " BIGINT_FORMAT ": " BIGINT_FORMAT " atoms have %d neighbors\n", update->ntimestep,atom->natoms,total); if (logfile) fprintf(logfile, - "orient step %d: " BIGINT_FORMAT - " atoms have %d neighbors\n", - update->ntimestep,atom->natoms,total); + "orient step " BIGINT_FORMAT ": " BIGINT_FORMAT + " atoms have %d neighbors\n", + update->ntimestep,atom->natoms,total); if (screen) fprintf(screen," neighs: min = %d, max = %d, ave = %g\n", min,max,ave); diff --git a/src/thermo.cpp b/src/thermo.cpp index 4a7ae0afc8..1931017099 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -514,8 +514,8 @@ void Thermo::modify_params(int narg, char **arg) if (ptr == NULL) error->all("Thermo_modify int format does not contain d character"); *ptr = '\0'; - sprintf(format_bigint_user,"%s" BIGINT_FORMAT "%s", - format_int_user,ptr+1); + sprintf(format_bigint_user,"%s%s%s",format_int_user, + BIGINT_FORMAT,ptr+1); *ptr = 'd'; } else if (strcmp(arg[iarg+1],"float") == 0) { if (format_float_user) delete [] format_float_user; From 57f91d6e5504de330efe311bb7885c7ee8cb24a7 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 16:06:07 +0000 Subject: [PATCH 4/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5549 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 1795e15cc0..51dc78fccf 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "15 Jan 2011" +#define LAMMPS_VERSION "16 Jan 2011" From 18b821f1d0d4e26c5ea90c2c170dd734c3983e39 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 16:08:31 +0000 Subject: [PATCH 5/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5551 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- doc/pair_reax.html | 24 +++++++++++------------- doc/pair_reax.txt | 24 +++++++++++------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/doc/pair_reax.html b/doc/pair_reax.html index c1d8f98ab9..c1c02a8d23 100644 --- a/doc/pair_reax.html +++ b/doc/pair_reax.html @@ -15,10 +15,10 @@

pair_style reax hbcut hbnewflag tripflag precision 
 
-
  • hbcut = hydrogen-bond cutoff (distance units) -
  • hbnewflag = use old or new hbond function style (0 or 1) -
  • tripflag = apply stabilization to all triple bonds (0 or 1) -
  • precision = precision for charge equilibration +
    • hbcut = hydrogen-bond cutoff (optional) (distance units) +
    • hbnewflag = use old or new hbond function style (0 or 1) (optional) +
    • tripflag = apply stabilization to all triple bonds (0 or 1) (optional) +
    • precision = precision for charge equilibration (optional)

    Examples:

    @@ -62,15 +62,13 @@ can use other ffield files for specific chemical systems that may be available elsewhere (but note that their accuracy may not have been tested).

    -

    The hbcut, hbnewflag, tripflag, and precision -settings are optional arguments. -If -neither is provided, default settings are used: hbcut = 6 (which is -Angstroms in real units), hbnewflag = 1 (use new hbond function style), -tripflag = 1 (apply stabilization to all triple bonds), -and precision = 1.0e-6 (one part in 10^6). -If you wish to override any of these defaults, then all settings -must be specified. +

    The hbcut, hbnewflag, tripflag, and precision settings are +optional arguments. If none are provided, default settings are used: +hbcut = 6 (which is Angstroms in real units), hbnewflag = 1 (use +new hbond function style), tripflag = 1 (apply stabilization to all +triple bonds), and precision = 1.0e-6 (one part in 10^6). If you +wish to override any of these defaults, then all of the settings must +be specified.

    Two examples using pair_style reax are provided in the examples/reax sub-directory, along with corresponding examples for diff --git a/doc/pair_reax.txt b/doc/pair_reax.txt index 84ba57b532..53d6948844 100644 --- a/doc/pair_reax.txt +++ b/doc/pair_reax.txt @@ -12,10 +12,10 @@ pair_style reax command :h3 pair_style reax hbcut hbnewflag tripflag precision :pre -hbcut = hydrogen-bond cutoff (distance units) -hbnewflag = use old or new hbond function style (0 or 1) -tripflag = apply stabilization to all triple bonds (0 or 1) -precision = precision for charge equilibration :ul +hbcut = hydrogen-bond cutoff (optional) (distance units) +hbnewflag = use old or new hbond function style (0 or 1) (optional) +tripflag = apply stabilization to all triple bonds (0 or 1) (optional) +precision = precision for charge equilibration (optional) :ul [Examples:] @@ -59,15 +59,13 @@ can use other ffield files for specific chemical systems that may be available elsewhere (but note that their accuracy may not have been tested). -The {hbcut}, {hbnewflag}, {tripflag}, and {precision} -settings are optional arguments. -If -neither is provided, default settings are used: {hbcut} = 6 (which is -Angstroms in real units), {hbnewflag} = 1 (use new hbond function style), -{tripflag} = 1 (apply stabilization to all triple bonds), -and {precision} = 1.0e-6 (one part in 10^6). -If you wish to override any of these defaults, then all settings -must be specified. +The {hbcut}, {hbnewflag}, {tripflag}, and {precision} settings are +optional arguments. If none are provided, default settings are used: +{hbcut} = 6 (which is Angstroms in real units), {hbnewflag} = 1 (use +new hbond function style), {tripflag} = 1 (apply stabilization to all +triple bonds), and {precision} = 1.0e-6 (one part in 10^6). If you +wish to override any of these defaults, then all of the settings must +be specified. Two examples using {pair_style reax} are provided in the examples/reax sub-directory, along with corresponding examples for From e969f7cd30a402df1780223eff987a9b9eaf3c43 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 21:33:45 +0000 Subject: [PATCH 6/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5552 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/variable.cpp | 2 +- src/velocity.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/variable.cpp b/src/variable.cpp index fd236b7102..29dbc69f0e 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -1597,8 +1597,8 @@ double Variable::collapse_tree(Tree *tree) if (tree->type == SIN) { arg1 = collapse_tree(tree->left); - tree->type = VALUE; if (tree->left->type != VALUE) return 0.0; + tree->type = VALUE; tree->value = sin(arg1); return tree->value; } diff --git a/src/velocity.cpp b/src/velocity.cpp index 1b7f982668..3a6226911d 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -356,21 +356,21 @@ void Velocity::set(int narg, char **arg) xstr = new char[n]; strcpy(xstr,&arg[0][2]); } else if (strcmp(arg[0],"NULL") == 0) xstyle = NONE; - else vx = xscale * atof(arg[0]); + else vx = atof(arg[0]); if (strstr(arg[1],"v_") == arg[1]) { int n = strlen(&arg[1][2]) + 1; ystr = new char[n]; strcpy(ystr,&arg[1][2]); } else if (strcmp(arg[1],"NULL") == 0) ystyle = NONE; - else vy = yscale * atof(arg[1]); + else vy = atof(arg[1]); if (strstr(arg[2],"v_") == arg[2]) { int n = strlen(&arg[2][2]) + 1; zstr = new char[n]; strcpy(zstr,&arg[2][2]); } else if (strcmp(arg[2],"NULL") == 0) zstyle = NONE; - else vz = zscale * atof(arg[2]); + else vz = atof(arg[2]); // set and apply scale factors From 588574343953d73348c730238de54edc99428877 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 21:35:22 +0000 Subject: [PATCH 7/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5553 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 51dc78fccf..36523f455d 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "16 Jan 2011" +#define LAMMPS_VERSION "17 Jam 2011" From 84772682105e0f4b4bcef5ae1f5311139e859ed1 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 14 Jan 2011 21:35:30 +0000 Subject: [PATCH 8/8] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5554 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 36523f455d..8a7f17470f 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "17 Jam 2011" +#define LAMMPS_VERSION "17 Jan 2011"