@@ -417,8 +417,6 @@ def setHeader(self, nVar, coords):
417417 coords = self .setupCoords (* coords )
418418 self .header = {"nVar" : int (nVar ), "coords" : coords }
419419 self .nItems = nVar * self .nDoF
420- if self .MPI_ON :
421- self .MPI_SETUP ()
422420
423421 @property
424422 def hInfos (self ):
@@ -440,8 +438,6 @@ def readHeader(self, f):
440438 gridSizes = np .fromfile (f , dtype = np .int32 , count = dim )
441439 coords = [np .fromfile (f , dtype = np .float64 , count = n ) for n in gridSizes ]
442440 self .setHeader (nVar , coords )
443- if self .MPI_ON :
444- self .MPI_SETUP ()
445441
446442 def reshape (self , fields : np .ndarray ):
447443 """Reshape the fields to a N-d array (inplace operation)"""
@@ -539,7 +535,7 @@ def MPI_ROOT(self):
539535 return True
540536 return self .comm .Get_rank () == 0
541537
542- def MPI_SETUP (self ):
538+ def MPI_SETUP_FILETYPE (self ):
543539 """Setup subarray masks for each processes"""
544540 self .mpiType = MPI_DTYPE (self .dtype )
545541 self .mpiFileType = self .mpiType .Create_subarray (
@@ -556,6 +552,8 @@ def MPI_FILE_OPEN(self, mode):
556552 "a" : MPI .MODE_WRONLY | MPI .MODE_APPEND ,
557553 }[mode ]
558554 self .mpiFile = MPI .File .Open (self .comm , self .fileName , amode )
555+ if self .mpiType is None :
556+ self .MPI_SETUP_FILETYPE ()
559557
560558 def MPI_WRITE (self , data ):
561559 """Write data (np.ndarray) in the binary file in MPI mode, at the current file cursor position."""
0 commit comments