#include "mpi.h" #include int main(int argc, char *argv[]) { int rank, size, i, n=18; int blocklen[3] = { 2, 5, 3 }; int disp[3] = { 0, 5, 15 }; MPI_Datatype type1, type2, type3; //int buffer[n], buffer1[n], buffer2[n], buffer3[n]; MPI_Status status; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); if (size < 2) { printf("Please run with 2 processes.\n"); MPI_Finalize(); return 1; } MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Type_contiguous(n, MPI_INT, &type1); MPI_Type_commit(&type1); MPI_Type_vector(3, 4, 7, MPI_INT, &type2); MPI_Type_commit(&type2); MPI_Type_indexed(3, blocklen, disp, MPI_INT, &type3); MPI_Type_commit(&type3); if (rank == 0) { int buffer[n]; for (i=0; i