Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] try to understand heat equation 2D mpi version
From: christophe petit (christophe.petit09_at_[hidden])
Date: 2010-10-21 20:17:54


Hello,

i'm studying the parallelized version of a solving 2D heat equation code in
order to understand cartesian topology and the famous "MPI_CART_SHIFT".
Here's my problem at this part of the code :

-------------------------------------------------------------------------------------------------------------------------------------------
call MPI_INIT(infompi)
      comm = MPI_COMM_WORLD
      call MPI_COMM_SIZE(comm,nproc,infompi)
      call MPI_COMM_RANK(comm,me,infompi)
!

......

! Create 2D cartesian grid
      periods(:) = .false.

      ndims = 2
      dims(1)=x_domains
      dims(2)=y_domains
      CALL MPI_CART_CREATE(MPI_COMM_WORLD, ndims, dims, periods, &
        reorganisation,comm2d,infompi)
!
! Identify neighbors
!
      NeighBor(:) = MPI_PROC_NULL
! Left/West and right/Est neigbors
      CALL MPI_CART_SHIFT(comm2d,0,1,NeighBor(W),NeighBor(E),infompi)

      print *,'rank=', me
      print *, 'here first mpi_cart_shift : neighbor(w)=',NeighBor(W)
      print *, 'here first mpi_cart_shift : neighbor(e)=',NeighBor(E)

...

-------------------------------------------------------------------------------------------------------------------------------------------

with x_domains=y_domains=2

and i get at the execution :" mpirun -np 4 ./explicitPar"

 rank= 0
here first mpi_cart_shift : neighbor(w)= -1
 here first mpi_cart_shift : neighbor(e)= 2
rank= 3
 here first mpi_cart_shift : neighbor(w)= 1
 here first mpi_cart_shift : neighbor(e)= -1
 rank= 2
 here first mpi_cart_shift : neighbor(w)= 0
 here first mpi_cart_shift : neighbor(e)= -1
 rank= 1
 here first mpi_cart_shift : neighbor(w)= -1
 here first mpi_cart_shift : neighbor(e)= 3

I saw that if the rank is out of the topology and wihtout periodicity, the
rank should be equal to MPI_UNDEFINED whis is assigned to -32766 in "mpif.h"
. So, why have i got the value "-1" ?
On my Macbook pro, i get the value "-2".

Thanks in advance.