#include #include "mpi.h" int main( argc, argv ) int argc; char **argv; { int rank, size; MPI_Comm new_comm; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_split( MPI_COMM_WORLD, rank == 0, 0, &new_comm ); if (rank == 0) master_io( MPI_COMM_WORLD, new_comm ); else slave_io( MPI_COMM_WORLD, new_comm ); MPI_Finalize( ); return 0; } /* This is the master */ int master_io( master_comm, comm ) MPI_Comm comm; { int i,j, size; char buf[256]; MPI_Status status; MPI_Comm_size( master_comm, &size ); for (j=1; j<=2; j++) { for (i=1; i