From 5fcfc9f575fc491ad3cdbaadbdab4c1de97ae0df Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 10 Apr 2014 18:21:12 +0200 Subject: [PATCH] various little cleanups to silence compiler warnings clarify/simplify some code and initialize variables where needed. also remove dead code and unused class members --- lib/colvars/colvaratoms.h | 4 +- src/COLLOID/fix_wall_colloid.h | 2 +- src/GRANULAR/fix_pour.cpp | 3 +- src/KSPACE/pppm_disp.cpp | 2 +- src/MISC/fix_deposit.cpp | 1 - src/USER-EFF/compute_temp_eff.h | 1 - src/USER-MISC/pair_cdeam.cpp | 4 +- src/USER-MOLFILE/molfile_interface.cpp | 41 ----------- src/USER-OMP/angle_class2_omp.cpp | 1 + src/USER-OMP/angle_cosine_delta_omp.cpp | 1 + src/USER-OMP/angle_cosine_omp.cpp | 1 + src/USER-OMP/angle_cosine_periodic_omp.cpp | 1 + src/USER-OMP/angle_cosine_shift_exp_omp.cpp | 1 + src/USER-OMP/angle_cosine_squared_omp.cpp | 1 + src/USER-OMP/angle_dipole_omp.cpp | 1 + src/USER-OMP/angle_fourier_simple_omp.cpp | 1 + src/USER-OMP/angle_quartic_omp.cpp | 1 + src/USER-OMP/angle_sdk_omp.cpp | 1 + src/USER-OMP/angle_table_omp.cpp | 1 + src/USER-OMP/bond_class2_omp.cpp | 1 + src/USER-OMP/bond_fene_expand_omp.cpp | 1 + src/USER-OMP/bond_fene_omp.cpp | 1 + src/USER-OMP/bond_harmonic_shift_cut_omp.cpp | 1 + src/USER-OMP/bond_morse_omp.cpp | 1 + src/USER-OMP/bond_table_omp.cpp | 1 + src/USER-OMP/neigh_respa_omp.cpp | 12 ++-- src/atom_vec_sphere.h | 2 +- src/balance.cpp | 75 ++++++++++---------- src/balance.h | 2 + src/compute_reduce.cpp | 4 +- src/compute_temp_ramp.h | 2 +- src/delete_bonds.cpp | 2 +- src/displace_atoms.cpp | 2 +- src/fix_ave_spatial.cpp | 8 ++- src/fix_balance.cpp | 5 +- src/fix_vector.h | 2 +- src/group.cpp | 2 +- src/input.cpp | 16 ++--- src/lattice.cpp | 4 +- 39 files changed, 94 insertions(+), 119 deletions(-) diff --git a/lib/colvars/colvaratoms.h b/lib/colvars/colvaratoms.h index e4d95537f8..aac8c857db 100644 --- a/lib/colvars/colvaratoms.h +++ b/lib/colvars/colvaratoms.h @@ -57,8 +57,8 @@ public: /// implementation cvm::rvector grad; - /// \brief Default constructor, setting id and index to invalid numbers - atom() : id (-1), index (-1) { reset_data(); } + /// \brief Default constructor, setting index and id to invalid numbers + atom() : index (-1), id (-1) { reset_data(); } /// \brief Initialize an atom for collective variable calculation /// and get its internal identifier \param atom_number Atom index in diff --git a/src/COLLOID/fix_wall_colloid.h b/src/COLLOID/fix_wall_colloid.h index d8a968a831..59b079f86e 100644 --- a/src/COLLOID/fix_wall_colloid.h +++ b/src/COLLOID/fix_wall_colloid.h @@ -32,7 +32,7 @@ class FixWallColloid : public FixWall { void wall_particle(int, int, double); private: - double coeff1[6],coeff2[6],coeff3[6],coeff4[6],offset[6]; + double coeff1[6],coeff2[6],coeff3[6],coeff4[6]; }; } diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index 69f95eb92e..abcd5d7335 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -209,7 +209,8 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) : // volume_one = volume of inserted particle (with max possible radius) // in 3d, insure dy >= 1, for quasi-2d simulations - double volume,volume_one; + double volume,volume_one=0.0; + dstyle = -1; if (domain->dimension == 3) { if (region_style == 1) { double dy = yhi - ylo; diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index f49f5c8bbb..8f06e84604 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1277,7 +1277,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs err = bmax/amax; if (err > 1.0e-4) { char str[128]; - sprintf(str,"Error in splitting of dispersion coeffs is estimated %g%",err); + sprintf(str,"Estimated error in splitting of dispersion coeffs is %g",err); error->warning(FLERR, str); } // set B diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index 196b3b489b..ef146ea11b 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -248,7 +248,6 @@ void FixDeposit::pre_exchange() { int i,j,m,n,nlocalprev,flag,flagall; double coord[3],lamda[3],delx,dely,delz,rsq; - double alpha,beta,gamma; double r[3],vnew[3],rotmat[3][3],quat[4]; double *newcoord; diff --git a/src/USER-EFF/compute_temp_eff.h b/src/USER-EFF/compute_temp_eff.h index bde38fe8cc..54c418d5f0 100644 --- a/src/USER-EFF/compute_temp_eff.h +++ b/src/USER-EFF/compute_temp_eff.h @@ -36,7 +36,6 @@ class ComputeTempEff : public Compute { private: int fix_dof; double tfactor; - double *inertia; void dof_compute(); }; diff --git a/src/USER-MISC/pair_cdeam.cpp b/src/USER-MISC/pair_cdeam.cpp index b3ce1b18f4..cbb8e23f7c 100644 --- a/src/USER-MISC/pair_cdeam.cpp +++ b/src/USER-MISC/pair_cdeam.cpp @@ -342,7 +342,7 @@ void PairCDEAM::compute(int eflag, int vflag) x_j = rhoB[j]/rho[j]; ASSERT(x_j >= 0 && x_j<=1.0); - double D_j; + double D_j=0.0; if(cdeamVersion == 1) { // Calculate derivative of h(x_j) polynomial function. double h_prime_j = evalHprime(x_j); @@ -375,7 +375,7 @@ void PairCDEAM::compute(int eflag, int vflag) } else { // We have a concentration dependence for the i-j interaction. - double h; + double h=0.0; if(cdeamVersion == 1) { // Calculate h(x_i) polynomial function. double h_i = evalH(x_i); diff --git a/src/USER-MOLFILE/molfile_interface.cpp b/src/USER-MOLFILE/molfile_interface.cpp index f3b63e7eda..d0aff40f32 100644 --- a/src/USER-MOLFILE/molfile_interface.cpp +++ b/src/USER-MOLFILE/molfile_interface.cpp @@ -173,33 +173,6 @@ extern "C" { return pte_vdw_radius[idx]; } - static int get_pte_idx(const char *label) - { - int i; - char atom[3]; - - /* zap string */ - atom[0] = (char) 0; - atom[1] = (char) 0; - atom[2] = (char) 0; - /* if we don't have a null-pointer, there must be at least two - * chars, which is all we need. we convert to the capitalization - * convention of the table above during assignment. */ - if (label != NULL) { - atom[0] = (char) toupper((int) label[0]); - atom[1] = (char) tolower((int) label[1]); - } - /* discard numbers in atom label */ - if (isdigit(atom[1])) atom[1] = (char) 0; - - for (i=0; i < nr_pte_entries; ++i) { - if ( (pte_label[i][0] == atom[0]) - && (pte_label[i][1] == atom[1]) ) return i; - } - - return 0; - } - static int get_pte_idx_from_string(const char *label) { int i, ind; char atom[3]; @@ -296,15 +269,6 @@ extern "C" { return (void *)LoadLibrary(fname); } - // report error message from dlopen - static const char *my_dlerror(void) { - static CHAR szBuf[80]; - DWORD dw = GetLastError(); - - sprintf(szBuf, "my_dlopen failed: GetLastError returned %u\n", dw); - return szBuf; - } - // resolve a symbol in shared object static void *my_dlsym(void *h, const char *sym) { return (void *)GetProcAddress((HINSTANCE)h, sym); @@ -377,11 +341,6 @@ extern "C" { return dlopen(fname, RTLD_NOW); } - // report error message from dlopen - static const char *my_dlerror(void) { - return dlerror(); - } - // resolve a symbol in shared object static void *my_dlsym(void *h, const char *sym) { return dlsym(h, sym); diff --git a/src/USER-OMP/angle_class2_omp.cpp b/src/USER-OMP/angle_class2_omp.cpp index 67590439cf..8f958b477c 100644 --- a/src/USER-OMP/angle_class2_omp.cpp +++ b/src/USER-OMP/angle_class2_omp.cpp @@ -98,6 +98,7 @@ void AngleClass2OMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_cosine_delta_omp.cpp b/src/USER-OMP/angle_cosine_delta_omp.cpp index 2620d757db..f9891dbb3d 100644 --- a/src/USER-OMP/angle_cosine_delta_omp.cpp +++ b/src/USER-OMP/angle_cosine_delta_omp.cpp @@ -95,6 +95,7 @@ void AngleCosineDeltaOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_cosine_omp.cpp b/src/USER-OMP/angle_cosine_omp.cpp index c72aa1819b..39ae3ce698 100644 --- a/src/USER-OMP/angle_cosine_omp.cpp +++ b/src/USER-OMP/angle_cosine_omp.cpp @@ -95,6 +95,7 @@ void AngleCosineOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_cosine_periodic_omp.cpp b/src/USER-OMP/angle_cosine_periodic_omp.cpp index ab4da435ee..311152f06c 100644 --- a/src/USER-OMP/angle_cosine_periodic_omp.cpp +++ b/src/USER-OMP/angle_cosine_periodic_omp.cpp @@ -98,6 +98,7 @@ void AngleCosinePeriodicOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_cosine_shift_exp_omp.cpp b/src/USER-OMP/angle_cosine_shift_exp_omp.cpp index 83bafdb0bb..3a3c31d625 100644 --- a/src/USER-OMP/angle_cosine_shift_exp_omp.cpp +++ b/src/USER-OMP/angle_cosine_shift_exp_omp.cpp @@ -96,6 +96,7 @@ void AngleCosineShiftExpOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_cosine_squared_omp.cpp b/src/USER-OMP/angle_cosine_squared_omp.cpp index 9acca40aa1..c7d14468f5 100644 --- a/src/USER-OMP/angle_cosine_squared_omp.cpp +++ b/src/USER-OMP/angle_cosine_squared_omp.cpp @@ -96,6 +96,7 @@ void AngleCosineSquaredOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_dipole_omp.cpp b/src/USER-OMP/angle_dipole_omp.cpp index 9d5cc7f9cf..cf391b2d60 100644 --- a/src/USER-OMP/angle_dipole_omp.cpp +++ b/src/USER-OMP/angle_dipole_omp.cpp @@ -95,6 +95,7 @@ void AngleDipoleOMP::eval(int nfrom, int nto, ThrData * const thr) const int nlocal = atom->nlocal; const double f1[3] = {0.0, 0.0, 0.0}; const double f3[3] = {0.0, 0.0, 0.0}; + eangle = 0.0; for (n = nfrom; n < nto; n++) { iDip = anglelist[n][0]; // dipole whose orientation is to be restrained diff --git a/src/USER-OMP/angle_fourier_simple_omp.cpp b/src/USER-OMP/angle_fourier_simple_omp.cpp index 296efe67e1..5bdbfce05d 100644 --- a/src/USER-OMP/angle_fourier_simple_omp.cpp +++ b/src/USER-OMP/angle_fourier_simple_omp.cpp @@ -96,6 +96,7 @@ void AngleFourierSimpleOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_quartic_omp.cpp b/src/USER-OMP/angle_quartic_omp.cpp index 7475277682..70383fd50a 100644 --- a/src/USER-OMP/angle_quartic_omp.cpp +++ b/src/USER-OMP/angle_quartic_omp.cpp @@ -96,6 +96,7 @@ void AngleQuarticOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_sdk_omp.cpp b/src/USER-OMP/angle_sdk_omp.cpp index 5767ac718e..9b4a967bf3 100644 --- a/src/USER-OMP/angle_sdk_omp.cpp +++ b/src/USER-OMP/angle_sdk_omp.cpp @@ -98,6 +98,7 @@ void AngleSDKOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/angle_table_omp.cpp b/src/USER-OMP/angle_table_omp.cpp index a991b4932e..465f4370fc 100644 --- a/src/USER-OMP/angle_table_omp.cpp +++ b/src/USER-OMP/angle_table_omp.cpp @@ -96,6 +96,7 @@ void AngleTableOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int4_t * _noalias const anglelist = (int4_t *) neighbor->anglelist[0]; const int nlocal = atom->nlocal; + eangle = 0.0; for (n = nfrom; n < nto; n++) { i1 = anglelist[n].a; diff --git a/src/USER-OMP/bond_class2_omp.cpp b/src/USER-OMP/bond_class2_omp.cpp index 2568e58eb6..69decfb32a 100644 --- a/src/USER-OMP/bond_class2_omp.cpp +++ b/src/USER-OMP/bond_class2_omp.cpp @@ -90,6 +90,7 @@ void BondClass2OMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int3_t * _noalias const bondlist = (int3_t *) neighbor->bondlist[0]; const int nlocal = atom->nlocal; + ebond = 0.0; for (n = nfrom; n < nto; n++) { i1 = bondlist[n].a; diff --git a/src/USER-OMP/bond_fene_expand_omp.cpp b/src/USER-OMP/bond_fene_expand_omp.cpp index 7587b93c7e..37cb8b403e 100644 --- a/src/USER-OMP/bond_fene_expand_omp.cpp +++ b/src/USER-OMP/bond_fene_expand_omp.cpp @@ -93,6 +93,7 @@ void BondFENEExpandOMP::eval(int nfrom, int nto, ThrData * const thr) const int3_t * _noalias const bondlist = (int3_t *) neighbor->bondlist[0]; const int nlocal = atom->nlocal; const int tid = thr->get_tid(); + ebond = 0.0; for (n = nfrom; n < nto; n++) { i1 = bondlist[n].a; diff --git a/src/USER-OMP/bond_fene_omp.cpp b/src/USER-OMP/bond_fene_omp.cpp index 085fceefdf..e92dae999c 100644 --- a/src/USER-OMP/bond_fene_omp.cpp +++ b/src/USER-OMP/bond_fene_omp.cpp @@ -92,6 +92,7 @@ void BondFENEOMP::eval(int nfrom, int nto, ThrData * const thr) const int3_t * _noalias const bondlist = (int3_t *) neighbor->bondlist[0]; const int nlocal = atom->nlocal; const int tid = thr->get_tid(); + ebond = 0.0; for (n = nfrom; n < nto; n++) { i1 = bondlist[n].a; diff --git a/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp b/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp index be312113e6..db2518e9a9 100644 --- a/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp +++ b/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp @@ -89,6 +89,7 @@ void BondHarmonicShiftCutOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int3_t * _noalias const bondlist = (int3_t *) neighbor->bondlist[0]; const int nlocal = atom->nlocal; + ebond = 0.0; for (n = nfrom; n < nto; n++) { i1 = bondlist[n].a; diff --git a/src/USER-OMP/bond_morse_omp.cpp b/src/USER-OMP/bond_morse_omp.cpp index cb99202c81..d03783920b 100644 --- a/src/USER-OMP/bond_morse_omp.cpp +++ b/src/USER-OMP/bond_morse_omp.cpp @@ -89,6 +89,7 @@ void BondMorseOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int3_t * _noalias const bondlist = (int3_t *) neighbor->bondlist[0]; const int nlocal = atom->nlocal; + ebond = 0.0; for (n = nfrom; n < nto; n++) { i1 = bondlist[n].a; diff --git a/src/USER-OMP/bond_table_omp.cpp b/src/USER-OMP/bond_table_omp.cpp index fceaf4581a..53226df4f7 100644 --- a/src/USER-OMP/bond_table_omp.cpp +++ b/src/USER-OMP/bond_table_omp.cpp @@ -90,6 +90,7 @@ void BondTableOMP::eval(int nfrom, int nto, ThrData * const thr) dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; const int3_t * _noalias const bondlist = (int3_t *) neighbor->bondlist[0]; const int nlocal = atom->nlocal; + ebond = 0.0; for (n = nfrom; n < nto; n++) { i1 = bondlist[n].a; diff --git a/src/USER-OMP/neigh_respa_omp.cpp b/src/USER-OMP/neigh_respa_omp.cpp index 6ac70cf9d7..74aae867d7 100644 --- a/src/USER-OMP/neigh_respa_omp.cpp +++ b/src/USER-OMP/neigh_respa_omp.cpp @@ -143,7 +143,7 @@ void Neighbor::respa_nsq_no_newton_omp(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -328,7 +328,7 @@ void Neighbor::respa_nsq_newton_omp(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -506,7 +506,7 @@ void Neighbor::respa_bin_no_newton_omp(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -688,7 +688,7 @@ void Neighbor::respa_bin_newton_omp(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -732,7 +732,7 @@ void Neighbor::respa_bin_newton_omp(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; @@ -919,7 +919,7 @@ void Neighbor::respa_bin_newton_tri_omp(NeighList *list) tag[j]-tagprev); else which = 0; if (which == 0) neighptr[n++] = j; - else if (minchange = domain->minimum_image_check(delx,dely,delz)) + else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; diff --git a/src/atom_vec_sphere.h b/src/atom_vec_sphere.h index 8891cd0d0d..28b1198d59 100644 --- a/src/atom_vec_sphere.h +++ b/src/atom_vec_sphere.h @@ -73,7 +73,7 @@ class AtomVecSphere : public AtomVec { int *type,*mask; imageint *image; double **x,**v,**f; - double *radius,*density,*rmass; + double *radius,*rmass; double **omega,**torque; int radvary; }; diff --git a/src/balance.cpp b/src/balance.cpp index 6fbad34811..6073b25b64 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -11,6 +11,8 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +//#define BALANCE_DEBUG 1 + #include "lmptype.h" #include "mpi.h" #include "math.h" @@ -31,8 +33,6 @@ using namespace LAMMPS_NS; enum{NONE,UNIFORM,USER,DYNAMIC}; enum{X,Y,Z}; -//#define BALANCE_DEBUG 1 - /* ---------------------------------------------------------------------- */ Balance::Balance(LAMMPS *lmp) : Pointers(lmp) @@ -434,7 +434,7 @@ void Balance::static_setup(char *str) ndim = strlen(str); bdim = new int[ndim]; - for (int i = 0; i < strlen(str); i++) { + for (int i = 0; i < ndim; i++) { if (str[i] == 'x') bdim[i] = X; if (str[i] == 'y') bdim[i] = Y; if (str[i] == 'z') bdim[i] = Z; @@ -867,11 +867,11 @@ void Balance::dumpout(bigint tstep, FILE *bfp) debug output for Idim and count only called by proc 0 ------------------------------------------------------------------------- */ - +#ifdef BALANCE_DEBUG void Balance::debug_output(int idim, int m, int np, double *split) { int i; - const char *dim; + const char *dim = NULL; double *boxlo = domain->boxlo; double *prd = domain->prd; @@ -879,41 +879,42 @@ void Balance::debug_output(int idim, int m, int np, double *split) if (bdim[idim] == X) dim = "X"; else if (bdim[idim] == Y) dim = "Y"; else if (bdim[idim] == Z) dim = "Z"; - printf("Dimension %s, Iteration %d\n",dim,m); + fprintf(stderr,"Dimension %s, Iteration %d\n",dim,m); - printf(" Count:"); - for (i = 0; i < np; i++) printf(" " BIGINT_FORMAT,count[i]); - printf("\n"); - printf(" Sum:"); - for (i = 0; i <= np; i++) printf(" " BIGINT_FORMAT,sum[i]); - printf("\n"); - printf(" Target:"); - for (i = 0; i <= np; i++) printf(" " BIGINT_FORMAT,target[i]); - printf("\n"); - printf(" Actual cut:"); + fprintf(stderr," Count:"); + for (i = 0; i < np; i++) fprintf(stderr," " BIGINT_FORMAT,count[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Sum:"); + for (i = 0; i <= np; i++) fprintf(stderr," " BIGINT_FORMAT,sum[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Target:"); + for (i = 0; i <= np; i++) fprintf(stderr," " BIGINT_FORMAT,target[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Actual cut:"); for (i = 0; i <= np; i++) - printf(" %g",boxlo[bdim[idim]] + split[i]*prd[bdim[idim]]); - printf("\n"); - printf(" Split:"); - for (i = 0; i <= np; i++) printf(" %g",split[i]); - printf("\n"); - printf(" Low:"); - for (i = 0; i <= np; i++) printf(" %g",lo[i]); - printf("\n"); - printf(" Low-sum:"); - for (i = 0; i <= np; i++) printf(" " BIGINT_FORMAT,losum[i]); - printf("\n"); - printf(" Hi:"); - for (i = 0; i <= np; i++) printf(" %g",hi[i]); - printf("\n"); - printf(" Hi-sum:"); - for (i = 0; i <= np; i++) printf(" " BIGINT_FORMAT,hisum[i]); - printf("\n"); - printf(" Delta:"); - for (i = 0; i < np; i++) printf(" %g",split[i+1]-split[i]); - printf("\n"); + fprintf(stderr," %g",boxlo[bdim[idim]] + split[i]*prd[bdim[idim]]); + fprintf(stderr,"\n"); + fprintf(stderr," Split:"); + for (i = 0; i <= np; i++) fprintf(stderr," %g",split[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Low:"); + for (i = 0; i <= np; i++) fprintf(stderr," %g",lo[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Low-sum:"); + for (i = 0; i <= np; i++) fprintf(stderr," " BIGINT_FORMAT,losum[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Hi:"); + for (i = 0; i <= np; i++) fprintf(stderr," %g",hi[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Hi-sum:"); + for (i = 0; i <= np; i++) fprintf(stderr," " BIGINT_FORMAT,hisum[i]); + fprintf(stderr,"\n"); + fprintf(stderr," Delta:"); + for (i = 0; i < np; i++) fprintf(stderr," %g",split[i+1]-split[i]); + fprintf(stderr,"\n"); bigint max = 0; for (i = 0; i < np; i++) max = MAX(max,count[i]); - printf(" Imbalance factor: %g\n",1.0*max*np/target[np]); + fprintf(stderr," Imbalance factor: %g\n",1.0*max*np/target[np]); } +#endif diff --git a/src/balance.h b/src/balance.h index ee1d171546..013ed2189f 100644 --- a/src/balance.h +++ b/src/balance.h @@ -69,7 +69,9 @@ class Balance : protected Pointers { void tally(int, int, double *); int adjust(int, double *); int binary(double, int, double *); +#ifdef BALANCE_DEBUG void debug_output(int, int, int, double *); +#endif }; } diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index 9f87fcd09b..a0ee7ec01b 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -45,7 +45,7 @@ enum{PERATOM,LOCAL}; ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { - int iarg; + int iarg = 0; if (strcmp(style,"reduce") == 0) { if (narg < 5) error->all(FLERR,"Illegal compute reduce command"); idregion = NULL; @@ -59,7 +59,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : idregion = new char[n]; strcpy(idregion,arg[3]); iarg = 4; - } + } else error->all(FLERR,"Unkown derived compute reduce style"); if (strcmp(arg[iarg],"sum") == 0) mode = SUM; else if (strcmp(arg[iarg],"min") == 0) mode = MINN; diff --git a/src/compute_temp_ramp.h b/src/compute_temp_ramp.h index 7aacfb80ed..a669bc48a5 100644 --- a/src/compute_temp_ramp.h +++ b/src/compute_temp_ramp.h @@ -43,7 +43,7 @@ class ComputeTempRamp : public Compute { private: int coord_dim; - double coord_lo,coord_hi,inv_coord_delta; + double coord_lo,coord_hi; int v_dim; double v_lo,v_hi; int scaleflag,fix_dof; diff --git a/src/delete_bonds.cpp b/src/delete_bonds.cpp index e8a5809fe7..6b139b29f9 100644 --- a/src/delete_bonds.cpp +++ b/src/delete_bonds.cpp @@ -63,7 +63,7 @@ void DeleteBonds::command(int narg, char **arg) // set style and which = type value - int style; + int style = -1; if (strcmp(arg[1],"multi") == 0) style = MULTI; else if (strcmp(arg[1],"atom") == 0) style = ATOM; else if (strcmp(arg[1],"bond") == 0) style = BOND; diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp index 5701a04393..4a62647395 100644 --- a/src/displace_atoms.cpp +++ b/src/displace_atoms.cpp @@ -58,7 +58,7 @@ void DisplaceAtoms::command(int narg, char **arg) if (igroup == -1) error->all(FLERR,"Could not find displace_atoms group ID"); int groupbit = group->bitmask[igroup]; - int style; + int style=-1; if (strcmp(arg[1],"move") == 0) style = MOVE; else if (strcmp(arg[1],"ramp") == 0) style = RAMP; else if (strcmp(arg[1],"random") == 0) style = RANDOM; diff --git a/src/fix_ave_spatial.cpp b/src/fix_ave_spatial.cpp index 000ae48c35..c9defd4078 100644 --- a/src/fix_ave_spatial.cpp +++ b/src/fix_ave_spatial.cpp @@ -730,10 +730,12 @@ void FixAveSpatial::end_of_step() MPI_DOUBLE,MPI_SUM,world); for (m = 0; m < nbins; m++) { if (count_sum[m] > 0.0) - for (j = 0; j < nvalues; j++) + for (j = 0; j < nvalues; j++) { if (which[j] == DENSITY_NUMBER) values_sum[m][j] /= repeat; - else if (which[j] == DENSITY_MASS) values_sum[m][j] *= mv2d/repeat; - else values_sum[m][j] /= count_sum[m]; + else if (which[j] == DENSITY_MASS) { + values_sum[m][j] *= mv2d/repeat; + } else values_sum[m][j] /= count_sum[m]; + } count_sum[m] /= repeat; } } else { diff --git a/src/fix_balance.cpp b/src/fix_balance.cpp index 316140be3c..cf24cb9014 100644 --- a/src/fix_balance.cpp +++ b/src/fix_balance.cpp @@ -55,12 +55,13 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) : if (nevery < 0 || nitermax <= 0 || thresh < 1.0) error->all(FLERR,"Illegal fix balance command"); - for (int i = 0; i < strlen(bstr); i++) { + int blen = strlen(bstr); + for (int i = 0; i < blen; i++) { if (bstr[i] != 'x' && bstr[i] != 'y' && bstr[i] != 'z') error->all(FLERR,"Fix balance string is invalid"); if (bstr[i] == 'z' && dimension == 2) error->all(FLERR,"Fix balance string is invalid for 2d simulation"); - for (int j = i+1; j < strlen(bstr); j++) + for (int j = i+1; j < blen; j++) if (bstr[i] == bstr[j]) error->all(FLERR,"Fix balance string is invalid"); } diff --git a/src/fix_vector.h b/src/fix_vector.h index 0d3511d695..819668afba 100644 --- a/src/fix_vector.h +++ b/src/fix_vector.h @@ -37,7 +37,7 @@ class FixVector : public Fix { private: int nvalues; - int *which,*argindex,*value2index,*offcol; + int *which,*argindex,*value2index; char **ids; int ncount; // # of values currently in growing vector or array diff --git a/src/group.cpp b/src/group.cpp index 2e93562b1a..4144108f24 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -187,7 +187,7 @@ void Group::assign(int narg, char **arg) strcmp(arg[2],"<=") == 0 || strcmp(arg[2],">=") == 0 || strcmp(arg[2],"<>") == 0)) { - int condition; + int condition = -1; if (strcmp(arg[2],"<") == 0) condition = LT; else if (strcmp(arg[2],"<=") == 0) condition = LE; else if (strcmp(arg[2],">") == 0) condition = GT; diff --git a/src/input.cpp b/src/input.cpp index ddc864e6e2..4e9bebc77f 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -895,7 +895,7 @@ void Input::partition() { if (narg < 3) error->all(FLERR,"Illegal partition command"); - int yesflag; + int yesflag=-1; if (strcmp(arg[0],"yes") == 0) yesflag = 1; else if (strcmp(arg[0],"no") == 0) yesflag = 0; else error->all(FLERR,"Illegal partition command"); @@ -1349,7 +1349,7 @@ void Input::neighbor_command() void Input::newton() { - int newton_pair,newton_bond; + int newton_pair=1,newton_bond=1; if (narg == 1) { if (strcmp(arg[0],"off") == 0) newton_pair = newton_bond = 0; @@ -1366,15 +1366,9 @@ void Input::newton() force->newton_pair = newton_pair; - if (newton_bond == 0) { - if (domain->box_exist && force->newton_bond == 1) - error->all(FLERR,"Newton bond change after simulation box is defined"); - force->newton_bond = 0; - } else { - if (domain->box_exist && force->newton_bond == 0) - error->all(FLERR,"Newton bond change after simulation box is defined"); - force->newton_bond = 1; - } + if (domain->box_exist && (newton_bond != force->newton_bond)) + error->all(FLERR,"Newton bond change after simulation box is defined"); + force->newton_bond = newton_bond; if (newton_pair || newton_bond) force->newton = 1; else force->newton = 0; diff --git a/src/lattice.cpp b/src/lattice.cpp index dfd9252385..d613b9e245 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -153,12 +153,12 @@ Lattice::Lattice(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) } else if (strcmp(arg[iarg],"orient") == 0) { if (iarg+5 > narg) error->all(FLERR,"Illegal lattice command"); - int dim; + int dim = -1; if (strcmp(arg[iarg+1],"x") == 0) dim = 0; else if (strcmp(arg[iarg+1],"y") == 0) dim = 1; else if (strcmp(arg[iarg+1],"z") == 0) dim = 2; else error->all(FLERR,"Illegal lattice command"); - int *orient; + int *orient = NULL; if (dim == 0) orient = orientx; else if (dim == 1) orient = orienty; else if (dim == 2) orient = orientz;