From 136901c5ad86426d1a19efd6b8d79eaaa63d6fa4 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Tue, 5 Oct 2021 10:22:52 +0200 Subject: [PATCH] mpi: Patch neighborhood construction --- devito/mpi/distributed.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devito/mpi/distributed.py b/devito/mpi/distributed.py index e5e1475fbc..5d488d35b7 100644 --- a/devito/mpi/distributed.py +++ b/devito/mpi/distributed.py @@ -367,11 +367,11 @@ def neighborhood(self): # Set up diagonal neighbours for i in product([LEFT, CENTER, RIGHT], repeat=self.ndim): neighbor = [c + s.val for c, s in zip(self.mycoords, i)] - try: - ret[i] = self.comm.Get_cart_rank(neighbor) - except: - # Fallback for MPI ranks at the grid boundary + + if any(c < 0 or c >= s for c, s in zip(neighbor, self.topology)): ret[i] = MPI.PROC_NULL + else: + ret[i] = self.comm.Get_cart_rank(neighbor) return ret