#include #include #include "mpi.h" int main ( int argc, char* argv[] ) { int rank, size, c; MPI_Comm* comms; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); comms = malloc( size * sizeof(MPI_Comm) ); for ( c = 0; c < size; c++ ) { int color = MPI_UNDEFINED; if ( c == rank ) color = 0; MPI_Comm_split( MPI_COMM_WORLD, color, 0, &comms[c] ); } MPI_Finalize(); free( comms ); return 0; }