MPI_Cartdim_get
int MPI_Cartdim_get(MPI_Comm, int *);
Retrieves the number of Cartesian dimensions from a communicator.