1 /* Copyright (c) 2012-2014. 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[])
13 MPI_Datatype type, type2;
14 int blocklen[3] = { 2, 3, 1 };
15 int displacement[3] = { 0, 3, 8 };
19 MPI_Init(&argc, &argv);
20 MPI_Comm_size(MPI_COMM_WORLD, &size);
22 printf("Please run with 2 processes.\n");
26 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
28 MPI_Type_contiguous(3, MPI_INT, &type2);
29 MPI_Type_commit(&type2);
30 MPI_Type_indexed(3, blocklen, displacement, type2, &type);
31 MPI_Type_commit(&type);
36 MPI_Send(buffer, 1, type, 1, 123, MPI_COMM_WORLD);
42 MPI_Recv(buffer, 1, type, 0, 123, MPI_COMM_WORLD, &status);
44 printf("buffer[%d] = %d\n", i, buffer[i]);
49 MPI_Type_free(&type2);