MPI_Cart_coords

MPI_Cart_coords

MPI_Cart_coords finds the corresponding cartesian coordinates of a rank in a cartesian communicator.

Fortran Syntax

Subroutine MPI_Cart_coords(comm, rank, maxdims, coords, ierr)

C Syntax

int MPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int *coords)


Example in Fortran


      call MPI_Cart_create(old_comm,ndims,dim_size,
     &       periods,reorder,new_comm,ierr)  ! creates communicator

      if(Iam .eq. root) then    !! only want to do this on one process
        do rank=0,p-1
          call MPI_Cart_coords(new_comm, rank, coords, ierr)
          write(*,*)rank, coords
        enddo
      endif

In the above example, a cartesian communicator is created first. Repeated applications of MPI_Cart_coords for all process ranks (input) produce a correlation table of process ranks and their corresponding cartesian coordinates (output).

Figure a. Cartesian Grid
0,0 (0) 0,1 (1)
1,0 (2) 1,1 (3)
2,0 (4) 2,1 (5)

Here is the fortran code used to generate
the above table.


Note that: