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),
41 &position, MPI_COMM_WORLD );
44 MPI_Unpack( pack_buffer, pack_size, &position, recv_buffer, 1, type,
47 /* Check that the last 40 entries of the recv_buffer have the corresponding
48 elements from the send buffer */
49 for (i=0; i<20; i++) {
50 if (recv_buffer[i] != -1) {
52 fprintf( stderr, "recv_buffer[%d] = %d, should = -1\n", i,
56 for (i=20; i<60; i++) {
57 if (recv_buffer[i] != i) {
59 fprintf( stderr, "recv_buffer[%d] = %d, should = %d\n", i,
63 MPI_Type_free( &type );
65 MTest_Finalize( errs );