The easiest way to create communicators with new groups is with MPI_COMM_SPLIT.
For example, to form groups of rows of processes
use
MPI_Comm_split( oldcomm, row, 0, &newcomm );To maintain the order by rank, use
MPI_Comm_rank( oldcomm, &rank ); MPI_Comm_split( oldcomm, row, rank, &newcomm );