/* This program demonstrate the use of MPI_Type_contiguous. Create a data type representing a row of an array and distribute a different row to all processes. */ /* Compile : mpicc -o type_contiguous type_contiguous.c */ /* Run : mpirun -np 4 type_contiguous */ #include "mpi.h" #include #define SIZE 4 int main(int argc,char *argv[]) { int pid, np, source=0, dest, tag=1, i; double a[SIZE][SIZE] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0}; double b[SIZE]; MPI_Status stat; MPI_Datatype rowtype; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &pid); MPI_Comm_size(MPI_COMM_WORLD, &np); MPI_Type_contiguous(SIZE, MPI_DOUBLE, &rowtype); MPI_Type_commit(&rowtype); if (np == SIZE) { if (pid == 0) { for (i=0; i