Unfortunately, they're erroneous because the MPI spec says that
they're erroneous. MPI-2.1, p250:
"For dimension i with periods(i) = true, if the coordinate, coords(i),
is out of range, that is, coords(i) < 0 or coords(i) â¥ dims(i), it
is shifted back to the interval 0 â¤ coords(i) < dims(i)
automatically. Out-of-range coordinates are erroneous for non-periodic
Therefore, we invoke an MPI exception if you ask for something with
That being said, you have [at least] 2 alternatives:
1. Keep meta data around to know the dimensions of your communicator
and ensure that you never call CART_RANK with out-of-range coordinates.
2. Reset the error handler on the communicator in question to
MPI_ERRORS_RETURN (or your own handler). Then when you call CART_RANK
with out-of-range coordinates, you'll just get an error back rather
than the job aborting.
On Jan 7, 2009, at 3:08 AM, Atle Rudshaug wrote:
> I am trying to find the neighbor ranks in a 3D cartesian
> communicator. I use MPI_Cart_shift for 6 of them, but for the 12
> diagonals I tried to use MPI_Cart_rank. However, only x-direction is
> periodic and my program crashed because of out-of-range coordinates.
> Then I found something strange in some MPICH documentation:
> "Out-of-range coordinates are erroneous for non-periodic
> dimensions . Versions of MPICH before 1.2.2 returned MPI_PROC_NULL
> for the rank in this case."
> Why doesn't it anymore? Is this the same for OpenMPI? I expected it
> to return MPI_PROC_NULL which would make things much easier.
> - Atle
> users mailing list