# HG changeset patch
# User Cyrille Bonamy <cyrille.bonamy@legi.cnrs.fr>
# Date 1540411014 -7200
#      Wed Oct 24 21:56:54 2018 +0200
# Node ID f14adef105642f5f490d67c82c84f23f3b206203
# Parent  9033a36088518cf43cee8797565bda713b6409cb
debug parallel h5py write

diff --git a/fluidsim/base/output/phys_fields.py b/fluidsim/base/output/phys_fields.py
--- a/fluidsim/base/output/phys_fields.py
+++ b/fluidsim/base/output/phys_fields.py
@@ -205,7 +205,10 @@
                     _create_variable(group_state_phys, k, field_seq)
         else:
             h5file.atomic = False
-            xstart, ystart = self.oper.seq_indices_first_X
+            if len(self.oper.shapeX_loc) == 2:
+                xstart, ystart = self.oper.seq_indices_first_X
+            if len(self.oper.shapeX_loc) == 3:
+                xstart, ystart, zstart = self.oper.seq_indices_first_X
             xend = xstart + self.oper.shapeX_loc[0]
             yend = ystart + self.oper.shapeX_loc[1]
             for k in state_phys.keys:
@@ -224,7 +227,7 @@
                         )
             h5file.close()
             if mpi.rank == 0:
-                h5file = h5pack.File(path_file, "w")
+                h5file = h5pack.File(path_file, "r+")
 
         if mpi.rank == 0:
             h5file.attrs["date saving"] = str(datetime.datetime.now()).encode()