diff --git a/gprMax/contexts.py b/gprMax/contexts.py index 11668d56..8a764218 100644 --- a/gprMax/contexts.py +++ b/gprMax/contexts.py @@ -166,13 +166,12 @@ class MPIContext(Context): self.comm = MPI.COMM_WORLD self.rank = self.comm.rank - requested_mpi_size = np.product(config.sim_config.mpi) + requested_mpi_size = np.prod(config.sim_config.mpi) if self.comm.size < requested_mpi_size: - logger.error( + raise ValueError( f"MPI_COMM_WORLD size of {self.comm.size} is too small for requested dimensions of" f" {config.sim_config.mpi}. {requested_mpi_size} ranks are required." ) - raise ValueError if self.rank >= requested_mpi_size: logger.warning( @@ -186,7 +185,10 @@ class MPIContext(Context): return MPIModel() def run(self) -> Dict: - return super().run() + try: + return super().run() + except: + self.comm.Abort() def _run_model(self, model_num: int) -> None: """Process for running a single model.