@@ -417,8 +417,6 @@ def setHeader(self, nVar, coords):
417
417
coords = self .setupCoords (* coords )
418
418
self .header = {"nVar" : int (nVar ), "coords" : coords }
419
419
self .nItems = nVar * self .nDoF
420
- if self .MPI_ON :
421
- self .MPI_SETUP ()
422
420
423
421
@property
424
422
def hInfos (self ):
@@ -440,8 +438,6 @@ def readHeader(self, f):
440
438
gridSizes = np .fromfile (f , dtype = np .int32 , count = dim )
441
439
coords = [np .fromfile (f , dtype = np .float64 , count = n ) for n in gridSizes ]
442
440
self .setHeader (nVar , coords )
443
- if self .MPI_ON :
444
- self .MPI_SETUP ()
445
441
446
442
def reshape (self , fields : np .ndarray ):
447
443
"""Reshape the fields to a N-d array (inplace operation)"""
@@ -539,7 +535,7 @@ def MPI_ROOT(self):
539
535
return True
540
536
return self .comm .Get_rank () == 0
541
537
542
- def MPI_SETUP (self ):
538
+ def MPI_SETUP_FILETYPE (self ):
543
539
"""Setup subarray masks for each processes"""
544
540
self .mpiType = MPI_DTYPE (self .dtype )
545
541
self .mpiFileType = self .mpiType .Create_subarray (
@@ -556,6 +552,8 @@ def MPI_FILE_OPEN(self, mode):
556
552
"a" : MPI .MODE_WRONLY | MPI .MODE_APPEND ,
557
553
}[mode ]
558
554
self .mpiFile = MPI .File .Open (self .comm , self .fileName , amode )
555
+ if self .mpiType is None :
556
+ self .MPI_SETUP_FILETYPE ()
559
557
560
558
def MPI_WRITE (self , data ):
561
559
"""Write data (np.ndarray) in the binary file in MPI mode, at the current file cursor position."""
0 commit comments