diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp
index 381290609c2bf4200de22c4257868f13fe7ba90d..4e927b2579d2dbc0d2b4fabd256dd3192baada73 100644
--- a/src/GRANULAR/fix_wall_gran.cpp
+++ b/src/GRANULAR/fix_wall_gran.cpp
@@ -187,9 +187,11 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
 
   // initialize as if particle is not touching wall
 
-  int nlocal = atom->nlocal;
-  for (int i = 0; i < nlocal; i++)
-    shear[i][0] = shear[i][1] = shear[i][2] = 0.0;
+  if (history) {
+    int nlocal = atom->nlocal;
+    for (int i = 0; i < nlocal; i++)
+      shear[i][0] = shear[i][1] = shear[i][2] = 0.0;
+  }
 
   time_origin = update->ntimestep;
 }