MPI_Cart_coords or Who am I?
Given the rank of the process returned by MPI_Comm_rank in a variable myrank, this routine gives a two element (for two dimensional topology) array (coords in example below) with the (i, j) coordinates of this process in the new cartesian communicator.
ierr = MPI_Cart_coords (MPI_COMM_WORLD,
coords[0] and coords[1] will be the i and j coordinates.