4 int main(int argc, char *argv[])
7 MPI_Datatype type, type2;
8 int blocklen[3] = { 2, 3, 1 };
9 int displacement[3] = { 0, 3, 8 };
13 MPI_Init(&argc, &argv);
14 MPI_Comm_size(MPI_COMM_WORLD, &size);
17 printf("Please run with 2 processes.\n");
21 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
23 MPI_Type_contiguous(3, MPI_INT, &type2);
24 MPI_Type_commit(&type2);
25 MPI_Type_indexed(3, blocklen, displacement, type2, &type);
26 MPI_Type_commit(&type);
32 MPI_Send(buffer, 1, type, 1, 123, MPI_COMM_WORLD);
39 MPI_Recv(buffer, 1, type, 0, 123, MPI_COMM_WORLD, &status);
41 printf("buffer[%d] = %d\n", i, buffer[i]);