1 /* Copyright (c) 2012-2021. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
10 int main(int argc, char *argv[])
16 int blocklen[3] = {2, 3, 1};
17 int displacement[3] = {0, 3, 8};
21 MPI_Init(&argc, &argv);
22 MPI_Comm_size(MPI_COMM_WORLD, &size);
24 printf("Please run with 2 processes.\n");
28 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
30 MPI_Type_contiguous(3, MPI_INT, &type2);
31 MPI_Type_commit(&type2);
32 MPI_Type_indexed(3, blocklen, displacement, type2, &type);
33 MPI_Type_commit(&type);
36 for (int i = 0; i < 27; i++)
38 MPI_Send(buffer, 1, type, 1, 123, MPI_COMM_WORLD);
42 for (int i = 0; i < 27; i++)
44 MPI_Recv(buffer, 1, type, 0, 123, MPI_COMM_WORLD, &status);
45 for (int i = 0; i < 27; i++)
46 printf("buffer[%d] = %d\n", i, buffer[i]);
51 MPI_Type_free(&type2);