diff --git a/pyop2/types/dat.py b/pyop2/types/dat.py index ed2e6f66c..bb65db77e 100644 --- a/pyop2/types/dat.py +++ b/pyop2/types/dat.py @@ -1015,12 +1015,13 @@ def vec_context(self, access): # values if access is not Access.WRITE: offset = 0 - array = self._vec.array - for d in self: - with d.vec_ro as v: - size = v.local_size - array[offset:offset+size] = v.array_r[:] - offset += size + with self._vec as array: + for d in self: + with d.vec_ro as v: + size = v.local_size + array[offset:offset+size] = v.array_r[:] + offset += size + yield self._vec if access is not Access.READ: # Reverse scatter to get the values back to their original locations