From 252d554dc64ab6e538e22bf03a1d89f982aaef01 Mon Sep 17 00:00:00 2001 From: degomme Date: Tue, 19 Apr 2016 02:04:58 +0200 Subject: [PATCH] sometimes, maxdims is too much --- src/smpi/smpi_topo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/smpi/smpi_topo.cpp b/src/smpi/smpi_topo.cpp index 1e5f55d56f..2f22566b87 100644 --- a/src/smpi/smpi_topo.cpp +++ b/src/smpi/smpi_topo.cpp @@ -203,8 +203,8 @@ int smpi_mpi_cart_coords(MPI_Comm comm, int rank, int maxdims, int coords[]) { int smpi_mpi_cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) { MPI_Topology topo = smpi_comm_topo(comm); - - for(int i = 0 ; i < maxdims ; i++) { + int ndims=topo->topo.cart->ndims < maxdims ? topo->topo.cart->ndims : maxdims; + for(int i = 0 ; i < ndims ; i++) { dims[i] = topo->topo.cart->dims[i]; periods[i] = topo->topo.cart->periodic[i]; coords[i] = topo->topo.cart->position[i]; -- 2.20.1