From 7d43f349e6d8ba4d856bb39af788b81f02929990 Mon Sep 17 00:00:00 2001
From: Anders Hafreager <andershaf@gmail.com>
Date: Wed, 24 Aug 2016 17:06:58 +0200
Subject: [PATCH] Fixed initialization of arrays in computes

---
 src/compute.cpp              |  2 +-
 src/compute_stress_atom.cpp  |  4 ++--
 src/compute_temp_chunk.cpp   | 11 ++++-------
 src/compute_temp_profile.cpp |  4 ++--
 src/compute_temp_region.cpp  |  3 ++-
 src/compute_temp_sphere.cpp  |  4 ++--
 src/compute_torque_chunk.cpp |  6 ++----
 src/compute_vacf.cpp         |  3 ++-
 src/compute_vcm_chunk.cpp    |  5 ++---
 9 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/src/compute.cpp b/src/compute.cpp
index 20cb88ad8a..96bf6ceb54 100644
--- a/src/compute.cpp
+++ b/src/compute.cpp
@@ -41,7 +41,7 @@ int Compute::instance_total = 0;
 Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp),
   id(NULL), style(NULL),
   vector(NULL), array(NULL), vector_atom(NULL), array_atom(NULL), vector_local(NULL), array_local(NULL),
-  tlist(NULL)
+  tlist(NULL), vbiasall(NULL)
 {
   instance_me = instance_total++;
   
diff --git a/src/compute_stress_atom.cpp b/src/compute_stress_atom.cpp
index 3455d9eb08..46ee2ec3c5 100644
--- a/src/compute_stress_atom.cpp
+++ b/src/compute_stress_atom.cpp
@@ -36,7 +36,8 @@ enum{NOBIAS,BIAS};
 /* ---------------------------------------------------------------------- */
 
 ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  id_temp(NULL), stress(NULL)
 {
   if (narg < 4) error->all(FLERR,"Illegal compute stress/atom command");
 
@@ -98,7 +99,6 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
   }
 
   nmax = 0;
-  stress = NULL;
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp
index 87d6e11864..8daaeb0621 100644
--- a/src/compute_temp_chunk.cpp
+++ b/src/compute_temp_chunk.cpp
@@ -29,7 +29,9 @@ enum{TEMP,KECOM,INTERNAL};
 /* ---------------------------------------------------------------------- */
 
 ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  which(NULL), idchunk(NULL), id_bias(NULL), sum(NULL), sumall(NULL), count(NULL), 
+  countall(NULL), massproc(NULL), masstotal(NULL), vcm(NULL), vcmall(NULL)
 {
   if (narg < 4) error->all(FLERR,"Illegal compute temp/chunk command");
 
@@ -129,12 +131,7 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) :
 
   nchunk = 1;
   maxchunk = 0;
-  sum = sumall = NULL;
-  count = countall = NULL;
-  massproc = masstotal = NULL;
-  vcm = vcmall = NULL;
-  array = NULL;
-
+  
   if (nvalues)  {
     array_flag = 1;
     size_array_cols = nvalues;
diff --git a/src/compute_temp_profile.cpp b/src/compute_temp_profile.cpp
index 654bea7ebe..1c6e56359d 100644
--- a/src/compute_temp_profile.cpp
+++ b/src/compute_temp_profile.cpp
@@ -31,7 +31,8 @@ enum{TENSOR,BIN};
 /* ---------------------------------------------------------------------- */
 
 ComputeTempProfile::ComputeTempProfile(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  bin(NULL), vbin(NULL), binave(NULL), tbin(NULL), tbinall(NULL)
 {
   if (narg < 7) error->all(FLERR,"Illegal compute temp/profile command");
 
@@ -138,7 +139,6 @@ ComputeTempProfile::ComputeTempProfile(LAMMPS *lmp, int narg, char **arg) :
   }
 
   maxatom = 0;
-  bin = NULL;
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp
index 33e07bfb1e..e636669344 100644
--- a/src/compute_temp_region.cpp
+++ b/src/compute_temp_region.cpp
@@ -28,7 +28,8 @@ using namespace LAMMPS_NS;
 /* ---------------------------------------------------------------------- */
 
 ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  idregion(NULL)
 {
   if (narg != 4) error->all(FLERR,"Illegal compute temp/region command");
 
diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp
index 64b23308e2..50995dfa84 100644
--- a/src/compute_temp_sphere.cpp
+++ b/src/compute_temp_sphere.cpp
@@ -33,7 +33,8 @@ enum{ROTATE,ALL};
 /* ---------------------------------------------------------------------- */
 
 ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  id_bias(NULL)
 {
   if (narg < 3) error->all(FLERR,"Illegal compute temp/sphere command");
 
@@ -44,7 +45,6 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) :
   tempflag = 1;
 
   tempbias = 0;
-  id_bias = NULL;
   mode = ALL;
 
   int iarg = 3;
diff --git a/src/compute_torque_chunk.cpp b/src/compute_torque_chunk.cpp
index 5462debcfc..25386ad40d 100644
--- a/src/compute_torque_chunk.cpp
+++ b/src/compute_torque_chunk.cpp
@@ -26,7 +26,8 @@ using namespace LAMMPS_NS;
 /* ---------------------------------------------------------------------- */
 
 ComputeTorqueChunk::ComputeTorqueChunk(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  idchunk(NULL), massproc(NULL), masstotal(NULL), com(NULL), comall(NULL), torque(NULL), torqueall(NULL)
 {
   if (narg != 4) error->all(FLERR,"Illegal compute torque/chunk command");
 
@@ -48,9 +49,6 @@ ComputeTorqueChunk::ComputeTorqueChunk(LAMMPS *lmp, int narg, char **arg) :
 
   nchunk = 1;
   maxchunk = 0;
-  massproc = masstotal = NULL;
-  com = comall = NULL;
-  torque = torqueall = NULL;
   allocate();
 }
 
diff --git a/src/compute_vacf.cpp b/src/compute_vacf.cpp
index c06113a770..6ba272e579 100755
--- a/src/compute_vacf.cpp
+++ b/src/compute_vacf.cpp
@@ -25,7 +25,8 @@ using namespace LAMMPS_NS;
 /* ---------------------------------------------------------------------- */
 
 ComputeVACF::ComputeVACF(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  id_fix(NULL)
 {
   if (narg < 3) error->all(FLERR,"Illegal compute vacf command");
 
diff --git a/src/compute_vcm_chunk.cpp b/src/compute_vcm_chunk.cpp
index cd864b2aa8..0661bf4457 100644
--- a/src/compute_vcm_chunk.cpp
+++ b/src/compute_vcm_chunk.cpp
@@ -28,7 +28,8 @@ enum{ONCE,NFREQ,EVERY};
 /* ---------------------------------------------------------------------- */
 
 ComputeVCMChunk::ComputeVCMChunk(LAMMPS *lmp, int narg, char **arg) :
-  Compute(lmp, narg, arg)
+  Compute(lmp, narg, arg),
+  idchunk(NULL), massproc(NULL), masstotal(NULL), vcm(NULL), vcmall(NULL)
 {
   if (narg != 4) error->all(FLERR,"Illegal compute vcm/chunk command");
 
@@ -50,8 +51,6 @@ ComputeVCMChunk::ComputeVCMChunk(LAMMPS *lmp, int narg, char **arg) :
 
   nchunk = 1;
   maxchunk = 0;
-  massproc = masstotal = NULL;
-  vcm = vcmall = NULL;
   allocate();
 
   firstflag = massneed = 1;
-- 
GitLab