From c041727e4fedb49faa9facc5c83cd9fa11eee5c5 Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Mon, 27 Mar 2017 14:28:50 -0400
Subject: [PATCH] remove dead code and reduce trivial compiler warnings
 (clang++)

---
 src/GRANULAR/fix_wall_gran_region.cpp      |  3 +-
 src/MC/fix_gcmc.cpp                        |  2 +-
 src/MOLECULE/fix_cmap.cpp                  | 32 +++++++++++-----------
 src/OPT/pair_eam_opt.cpp                   |  5 ----
 src/QEQ/fix_qeq_dynamic.cpp                |  2 +-
 src/USER-DPD/fix_rx.cpp                    |  1 -
 src/USER-DPD/npair_half_bin_newton_ssa.cpp |  1 -
 src/USER-DRUDE/pair_lj_cut_thole_long.cpp  |  2 ++
 src/USER-NC-DUMP/dump_nc.cpp               |  5 +---
 src/USER-OMP/fix_nh_asphere_omp.cpp        |  1 -
 src/USER-OMP/fix_nh_omp.cpp                |  2 --
 src/USER-OMP/fix_nh_sphere_omp.cpp         |  1 -
 src/USER-OMP/fix_nvt_sllod_omp.cpp         |  2 +-
 src/USER-OMP/pair_airebo_omp.cpp           | 14 ++++------
 src/USER-SMTBQ/pair_smtbq.cpp              |  2 +-
 src/comm_tiled.cpp                         |  2 +-
 src/compute_property_local.cpp             |  2 +-
 src/neighbor.cpp                           |  4 +--
 18 files changed, 34 insertions(+), 49 deletions(-)

diff --git a/src/GRANULAR/fix_wall_gran_region.cpp b/src/GRANULAR/fix_wall_gran_region.cpp
index e9e27b90e6..a09b9dfa42 100644
--- a/src/GRANULAR/fix_wall_gran_region.cpp
+++ b/src/GRANULAR/fix_wall_gran_region.cpp
@@ -131,9 +131,8 @@ void FixWallGranRegion::init()
 void FixWallGranRegion::post_force(int vflag)
 {
   int i,m,nc,iwall;
-  double rinv,fx,fy,fz,tooclose;
   double dx,dy,dz,rsq,meff;
-  double xc[3],vwall[3];
+  double vwall[3];
 
   // do not update shear history during setup
 
diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp
index 780df25bdf..a7483a1d00 100644
--- a/src/MC/fix_gcmc.cpp
+++ b/src/MC/fix_gcmc.cpp
@@ -72,7 +72,7 @@ FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) :
   Fix(lmp, narg, arg),
   idregion(NULL), full_flag(0), ngroups(0), groupstrings(NULL), ngrouptypes(0), grouptypestrings(NULL),
   grouptypebits(NULL), grouptypes(NULL), local_gas_list(NULL), atom_coord(NULL), random_equal(NULL), random_unequal(NULL), 
-  coords(NULL), imageflags(NULL), idrigid(NULL), idshake(NULL), fixrigid(NULL), fixshake(NULL)
+  coords(NULL), imageflags(NULL), fixrigid(NULL), fixshake(NULL), idrigid(NULL), idshake(NULL)
 {
   if (narg < 11) error->all(FLERR,"Illegal fix gcmc command");
 
diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp
index 8534a8bf33..551e049238 100644
--- a/src/MOLECULE/fix_cmap.cpp
+++ b/src/MOLECULE/fix_cmap.cpp
@@ -964,22 +964,22 @@ void FixCMAP::bc_coeff(double *gs, double *d1gs, double *d2gs, double *d12gs)
   // calculate the bicubic interpolation coefficients c_ij
 
   static int wt[16][16] =
-    { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-      0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
-      -3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1, 0, 0, 0, 0,
-      2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
-      0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
-      0, 0, 0, 0,-3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1,
-      0, 0, 0, 0, 2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1,
-      -3, 3, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-      0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0,-2,-1, 0, 0,
-      9,-9, 9,-9, 6, 3,-3,-6, 6,-6,-3, 3, 4, 2, 1, 2,
-      -6, 6,-6, 6,-4,-2, 2, 4,-3, 3, 3,-3,-2,-1,-1,-2,
-      2,-2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-      0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 1, 1, 0, 0,
-      -6, 6,-6, 6,-3,-3, 3, 3,-4, 4, 2,-2,-2,-2,-1,-1,
-      4,-4, 4,-4, 2, 2,-2,-2, 2,-2,-2, 2, 1, 1, 1, 1
+    { {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+      {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
+      {-3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1, 0, 0, 0, 0},
+      {2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0},
+      {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+      {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
+      {0, 0, 0, 0,-3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1},
+      {0, 0, 0, 0, 2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1},
+      {-3, 3, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+      {0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0,-2,-1, 0, 0},
+      {9,-9, 9,-9, 6, 3,-3,-6, 6,-6,-3, 3, 4, 2, 1, 2},
+      {-6, 6,-6, 6,-4,-2, 2, 4,-3, 3, 3,-3,-2,-1,-1,-2},
+      {2,-2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+      {0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 1, 1, 0, 0},
+      {-6, 6,-6, 6,-3,-3, 3, 3,-4, 4, 2,-2,-2,-2,-1,-1},
+      {4,-4, 4,-4, 2, 2,-2,-2, 2,-2,-2, 2, 1, 1, 1, 1}
     };
 
   int i, j, k, in;
diff --git a/src/OPT/pair_eam_opt.cpp b/src/OPT/pair_eam_opt.cpp
index e970f90ae8..3afec5644a 100644
--- a/src/OPT/pair_eam_opt.cpp
+++ b/src/OPT/pair_eam_opt.cpp
@@ -67,11 +67,6 @@ void PairEAMOpt::eval()
     double rhor0j,rhor1j,rhor2j,rhor3j;
   } fast_alpha_t;
 
-  typedef struct {
-    double frho0,frho1,frho2,frho3,frho4,frho5,frho6;
-    double _pad[1];
-  } fast_beta_t;
-
   typedef struct {
     double rhor4i,rhor5i,rhor6i;
     double rhor4j,rhor5j,rhor6j;
diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp
index 8e8247e121..5408db650b 100644
--- a/src/QEQ/fix_qeq_dynamic.cpp
+++ b/src/QEQ/fix_qeq_dynamic.cpp
@@ -249,7 +249,7 @@ double FixQEqDynamic::compute_eneg()
 int FixQEqDynamic::pack_forward_comm(int n, int *list, double *buf,
                           int pbc_flag, int *pbc)
 {
-  int m;
+  int m=0;
 
   if( pack_flag == 1 )
     for(m = 0; m < n; m++) buf[m] = atom->q[list[m]];
diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp
index 94c03705d6..82bb44a24d 100644
--- a/src/USER-DPD/fix_rx.cpp
+++ b/src/USER-DPD/fix_rx.cpp
@@ -666,7 +666,6 @@ void FixRX::setup_pre_force(int vflag)
   int *mask = atom->mask;
   int newton_pair = force->newton_pair;
   double tmp;
-  int ii;
 
   if(restartFlag){
     restartFlag = 0;
diff --git a/src/USER-DPD/npair_half_bin_newton_ssa.cpp b/src/USER-DPD/npair_half_bin_newton_ssa.cpp
index fd67b66e9b..59acbda301 100644
--- a/src/USER-DPD/npair_half_bin_newton_ssa.cpp
+++ b/src/USER-DPD/npair_half_bin_newton_ssa.cpp
@@ -64,7 +64,6 @@ void NPairHalfBinNewtonSSA::build(NeighList *list)
   tagint **special = atom->special;
   int **nspecial = atom->nspecial;
   int nlocal = atom->nlocal;
-  int nall = nlocal + atom->nghost;
   if (includegroup) nlocal = atom->nfirst;
   int *ssaAIR = atom->ssaAIR;
 
diff --git a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp
index 726baae240..671de7090b 100644
--- a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp
+++ b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp
@@ -640,10 +640,12 @@ double PairLJCutTholeLong::single(int i, int j, int itype, int jtype,
       if (j != di_closest){
         if (drudetype[i] == CORE_TYPE) dqi = -atom->q[di];
         else if (drudetype[i] == DRUDE_TYPE) dqi = atom->q[i];
+        else dqi = 0.0;
         if (drudetype[j] == CORE_TYPE) {
           dj = atom->map(drudeid[j]);
           dqj = -atom->q[dj];
         } else if (drudetype[j] == DRUDE_TYPE) dqj = atom->q[j];
+        else dqj = 0.0;
         asr = ascreen[itype][jtype] * r;
         exp_asr = exp(-asr);
         dcoul = force->qqrd2e * dqi * dqj / r;
diff --git a/src/USER-NC-DUMP/dump_nc.cpp b/src/USER-NC-DUMP/dump_nc.cpp
index 825526dde9..7a66eb0224 100644
--- a/src/USER-NC-DUMP/dump_nc.cpp
+++ b/src/USER-NC-DUMP/dump_nc.cpp
@@ -283,9 +283,6 @@ void DumpNC::openfile()
       // Fixme! Perform checks if dimensions and variables conform with
       // data structure standard.
 
-      size_t index[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
-      double d[1];
-
       if (singlefile_opened) return;
       singlefile_opened = 1;
 
@@ -924,7 +921,7 @@ int DumpNC::modify_param(int narg, char **arg)
 
     for (int i = 0; iarg < narg; iarg++, i++) {
       int n;
-      char *suffix;
+      char *suffix=NULL;
 
       if (!strcmp(arg[iarg],"step")) {
         perframe[i].type = THIS_IS_A_BIGINT;
diff --git a/src/USER-OMP/fix_nh_asphere_omp.cpp b/src/USER-OMP/fix_nh_asphere_omp.cpp
index d90e907d0e..f11b1f5e94 100644
--- a/src/USER-OMP/fix_nh_asphere_omp.cpp
+++ b/src/USER-OMP/fix_nh_asphere_omp.cpp
@@ -183,7 +183,6 @@ void FixNHAsphereOMP::nh_v_temp()
 #pragma omp parallel for default(none) private(i) schedule(static)
 #endif
     for (i = 0; i < nlocal; i++) {
-      double buf[3];
       if (mask[i] & groupbit) {
         temperature->remove_bias(i,&v[i].x);
         v[i].x *= factor_eta;
diff --git a/src/USER-OMP/fix_nh_omp.cpp b/src/USER-OMP/fix_nh_omp.cpp
index 591503d01e..e77f18304d 100644
--- a/src/USER-OMP/fix_nh_omp.cpp
+++ b/src/USER-OMP/fix_nh_omp.cpp
@@ -261,7 +261,6 @@ void FixNHOMP::nh_v_press()
 #pragma omp parallel for default(none) private(i) schedule(static)
 #endif
     for (i = 0; i < nlocal; i++) {
-      double buf[3];
       if (mask[i] & groupbit) {
         temperature->remove_bias(i,&v[i].x);
         v[i].x *= factor0;
@@ -374,7 +373,6 @@ void FixNHOMP::nh_v_temp()
 #pragma omp parallel for default(none) private(i) schedule(static)
 #endif
     for (i = 0; i < nlocal; i++) {
-      double buf[3];
       if (mask[i] & groupbit) {
         temperature->remove_bias(i,&v[i].x);
         v[i].x *= factor_eta;
diff --git a/src/USER-OMP/fix_nh_sphere_omp.cpp b/src/USER-OMP/fix_nh_sphere_omp.cpp
index 5e7890a513..cd06c581ca 100644
--- a/src/USER-OMP/fix_nh_sphere_omp.cpp
+++ b/src/USER-OMP/fix_nh_sphere_omp.cpp
@@ -137,7 +137,6 @@ void FixNHSphereOMP::nh_v_temp()
 #pragma omp parallel for default(none) private(i) schedule(static)
 #endif
     for (i = 0; i < nlocal; i++) {
-      double buf[3];
       if (mask[i] & groupbit) {
         temperature->remove_bias(i,&v[i].x);
         v[i].x *= factor_eta;
diff --git a/src/USER-OMP/fix_nvt_sllod_omp.cpp b/src/USER-OMP/fix_nvt_sllod_omp.cpp
index bd704148a5..f233dc459b 100644
--- a/src/USER-OMP/fix_nvt_sllod_omp.cpp
+++ b/src/USER-OMP/fix_nvt_sllod_omp.cpp
@@ -121,7 +121,7 @@ void FixNVTSllodOMP::nh_v_temp()
 #pragma omp parallel for default(none) private(i) shared(h_two) schedule(static)
 #endif
   for (i = 0; i < nlocal; i++) {
-    double vdelu0,vdelu1,vdelu2,buf[3];
+    double vdelu0,vdelu1,vdelu2;
     if (mask[i] & groupbit) {
       vdelu0 = h_two[0]*v[i].x + h_two[5]*v[i].y + h_two[4]*v[i].z;
       vdelu1 = h_two[1]*v[i].y + h_two[3]*v[i].z;
diff --git a/src/USER-OMP/pair_airebo_omp.cpp b/src/USER-OMP/pair_airebo_omp.cpp
index fb1308990f..84821f1c8c 100644
--- a/src/USER-OMP/pair_airebo_omp.cpp
+++ b/src/USER-OMP/pair_airebo_omp.cpp
@@ -1852,9 +1852,7 @@ double PairAIREBOOMP::bondorderLJ_thr(int i, int j, double rij[3], double rijmag
   double rikmag,rjlmag,cosjik,cosijl,g,tmp2,tmp3;
   double Etmp,pij,tmp,wij,dwij,NconjtmpI,NconjtmpJ;
   double Nki,Nlj,dS,lamdajik,lamdaijl,dgdc,dgdN,pji,Nijconj,piRC;
-  double dcosjikdri[3],dcosijldri[3],dcosjikdrk[3];
-  double dN2[2],dN3[3];
-  double dcosijldrj[3],dcosijldrl[3],dcosjikdrj[3],dwjl;
+  double dN2[2],dN3[3],dwjl;
   double Tij,crosskij[3],crosskijmag;
   double crossijl[3],crossijlmag,omkijl;
   double tmppij,tmppji,dN2PIJ[2],dN2PJI[2],dN3piRC[3],dN3Tij[3];
@@ -1864,16 +1862,16 @@ double PairAIREBOOMP::bondorderLJ_thr(int i, int j, double rij[3], double rijmag
   double rlnmag,dwln,r23[3],r23mag,r21[3],r21mag;
   double w21,dw21,r34[3],r34mag,cos234,w34,dw34;
   double cross321[3],cross234[3],prefactor,SpN;
-  double fcijpc,fcikpc,fcjlpc,fcjkpc,fcilpc;
-  double dt2dik[3],dt2djl[3],dt2dij[3],aa,aaa1,aaa2,at2,cw,cwnum,cwnom;
+  double fcikpc,fcjlpc,fcjkpc,fcilpc;
+  double dt2dik[3],dt2djl[3],aa,aaa1,aaa2,at2,cw,cwnum,cwnom;
   double sin321,sin234,rr,rijrik,rijrjl,rjk2,rik2,ril2,rjl2;
-  double dctik,dctjk,dctjl,dctij,dctji,dctil,rik2i,rjl2i,sink2i,sinl2i;
-  double rjk[3],ril[3],dt1dik,dt1djk,dt1djl,dt1dil,dt1dij;
+  double dctik,dctjk,dctjl,dctil,rik2i,rjl2i,sink2i,sinl2i;
+  double rjk[3],ril[3],dt1dik,dt1djk,dt1djl,dt1dil;
   double dNlj;
   double PijS,PjiS;
   double rij2,tspjik,dtsjik,tspijl,dtsijl,costmp;
   int *REBO_neighs,*REBO_neighs_i,*REBO_neighs_j,*REBO_neighs_k,*REBO_neighs_l;
-  double F12[3],F23[3],F34[3],F31[3],F24[3];
+  double F12[3],F34[3],F31[3],F24[3];
   double fi[3],fj[3],fk[3],fl[3],f1[3],f2[3],f3[3],f4[4];
   double rji[3],rki[3],rlj[3],r13[3],r43[3];
   double realrij[3], realrijmag;
diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp
index 5e24ced35c..937b9e5117 100644
--- a/src/USER-SMTBQ/pair_smtbq.cpp
+++ b/src/USER-SMTBQ/pair_smtbq.cpp
@@ -3561,7 +3561,7 @@ int PairSMTBQ::Tokenize( char* s, char*** tok )
 
 void PairSMTBQ::CheckEnergyVSForce()
 {
-  double drL,iq,jq,rsq,evdwlCoul,fpairCoul,eflag,ErepR,frepR,fpair,evdwl;
+  double drL,iq,jq,rsq,evdwlCoul,fpairCoul,eflag=0,ErepR,frepR,fpair,evdwl;
   int i,j,iiiMax,iii,iCoord;
   int itype,jtype,l,m;
   double r,t1,t2,sds,xi,engSurf,fforceSurf;
diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp
index 2bdcd05030..23b098a705 100644
--- a/src/comm_tiled.cpp
+++ b/src/comm_tiled.cpp
@@ -1449,7 +1449,7 @@ void CommTiled::box_drop_brick(int idim, double *lo, double *hi, int &indexme)
   // NOTE: these error messages are internal sanity checks
   //       should not occur, can be removed at some point
 
-  int index,dir;
+  int index=-1,dir;
   if (hi[idim] == sublo[idim]) {
     index = myloc[idim] - 1;
     dir = -1;
diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp
index 7814b6cb6b..90faa88921 100644
--- a/src/compute_property_local.cpp
+++ b/src/compute_property_local.cpp
@@ -35,7 +35,7 @@ enum{TYPE,RADIUS};
 
 ComputePropertyLocal::ComputePropertyLocal(LAMMPS *lmp, int narg, char **arg) :
   Compute(lmp, narg, arg),
-  indices(NULL), pack_choice(NULL), vlocal(NULL), alocal(NULL)
+  vlocal(NULL), alocal(NULL), indices(NULL), pack_choice(NULL)
 {
   if (narg < 4) error->all(FLERR,"Illegal compute property/local command");
 
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 8da6c1b9d2..4cd99b41d7 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -954,7 +954,7 @@ void Neighbor::morph_skip()
   int i,j,inewton,jnewton;
   NeighRequest *irq,*jrq,*nrq;
 
-  for (int i = 0; i < nrequest; i++) {
+  for (i = 0; i < nrequest; i++) {
     irq = requests[i];
 
     // only processing skip lists
@@ -1053,7 +1053,7 @@ void Neighbor::morph_skip()
 void Neighbor::morph_granular()
 {
   int i,j;
-  NeighRequest *irq,*jrq,*nrq;
+  NeighRequest *irq,*jrq;
 
   for (i = 0; i < nrequest; i++) {
     irq = requests[i];
-- 
GitLab