MPI_Cartdim_get determines the number of dimensions of a subgrid communicator.
On occasions, a subgrid communicator may be created in one routine and is subsequently used in another routine. If the dimensions of the subgrid is not available, it can be determined by this routine.
Subroutine MPI_Cartdim_get(subgrid_comm, ndims, ierr)
int MPI_Cartdim_get(MPI_Comm subgrid_comm, int* ndims)
Example in Fortran
We have just demonstrated the use of
MPI_Cartdim_get to divide a cartesian grid into subgrids of lower dimensions. It is important to note that subgrids are treated as entities. Let say that you want to send a row or a column of a 2D matrix, set up as a subgrid, to a process. The
count input parameter, required by the
MPI_Send to indicate the buffer size, is 1 (one), not the number of elements in the row or column. On occasions, the information regarding a subgrid may not be available, as in the case where the subgrid communicator was created in one routine and is used in another. In such a situation,
MPI_Cartdim_get may be called to find out the dimensions of the subgrid. Armed with this information, additional information may be obtained by calling
MPI_Cart_get. We will discuss this routine next.