1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2001 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
10 int main(int argc, char *argv[])
13 int position, pack_size, i;
14 int dis[2], blklens[2];
18 int pack_buffer[1000];
20 MTest_Init(&argc, &argv);
22 /* Initialize data in the buffers */
23 for (i = 0; i < 60; i++) {
29 /* Create an indexed type with an empty first block */
36 MPI_Type_indexed(2, blklens, dis, MPI_INT, &type);
37 MPI_Type_commit(&type);
40 MPI_Pack(send_buffer, 1, type, pack_buffer, sizeof(pack_buffer), &position, MPI_COMM_WORLD);
43 MPI_Unpack(pack_buffer, pack_size, &position, recv_buffer, 1, type, MPI_COMM_WORLD);
45 /* Check that the last 40 entries of the recv_buffer have the corresponding
46 * elements from the send buffer */
47 for (i = 0; i < 20; i++) {
48 if (recv_buffer[i] != -1) {
50 fprintf(stderr, "recv_buffer[%d] = %d, should = -1\n", i, recv_buffer[i]);
53 for (i = 20; i < 60; i++) {
54 if (recv_buffer[i] != i) {
56 fprintf(stderr, "recv_buffer[%d] = %d, should = %d\n", i, recv_buffer[i], i);