bugfix: statistics communication for derived fields

This commit is contained in:
Michael Krayer 2021-02-12 02:11:15 +01:00
parent 43a3ab56f6
commit 2e2f987f7f
1 changed files with 6 additions and 3 deletions

View File

@ -1306,7 +1306,8 @@ class ibmppp:
if not key in self.spatialMean or self.spatialMean[key] is None: if not key in self.spatialMean or self.spatialMean[key] is None:
raise ValueError('Statistics not available') raise ValueError('Statistics not available')
# Broadcast statistics # Broadcast statistics
self.spatialMean[key] = self.__comm.bcast(self.spatialMean[key],root=0) sendbuf = self.spatialMean[key] if self.__rank==0 else None
self.spatialMean[key] = self.__comm.bcast(sendbuf,root=0)
# Get dimensions # Get dimensions
dims = self.spatialMean[key].shape dims = self.spatialMean[key].shape
# Slice statistics for each processor # Slice statistics for each processor
@ -1330,8 +1331,10 @@ class ibmppp:
not key in self.spatialMsqr or self.spatialMsqr[key] is None): not key in self.spatialMsqr or self.spatialMsqr[key] is None):
raise ValueError('Statistics not available') raise ValueError('Statistics not available')
# Broadcast statistics # Broadcast statistics
self.spatialMean[key] = self.__comm.bcast(self.spatialMean[key],root=0) sendbuf = self.spatialMean[key] if self.__rank==0 else None
self.spatialMsqr[key] = self.__comm.bcast(self.spatialMsqr[key],root=0) self.spatialMean[key] = self.__comm.bcast(sendbuf,root=0)
sendbuf = self.spatialMsqr[key] if self.__rank==0 else None
self.spatialMsqr[key] = self.__comm.bcast(sendbuf,root=0)
# Compute standard deviation # Compute standard deviation
assert(self.spatialMean[key].shape==self.spatialMsqr[key].shape) assert(self.spatialMean[key].shape==self.spatialMsqr[key].shape)
spatialStdDev = np.sqrt(self.spatialMsqr[key]-np.square(self.spatialMean[key])) spatialStdDev = np.sqrt(self.spatialMsqr[key]-np.square(self.spatialMean[key]))