9 struct { int a;int c; double b;int tab[2][3];} value;
10 MPI_Datatype mystruct;
13 MPI_Datatype old_types[3], type2;
16 MPI_Init( &argc, &argv );
18 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
20 int tab[2][3]={{1*rank,2*rank,3*rank},{7*rank,8*rank,9*rank}};
21 MPI_Type_contiguous(3, MPI_INT, &type2);
22 MPI_Type_commit(&type2);
24 /* One value of each type, and two for the contiguous one */
29 old_types[0] = MPI_INT;
30 old_types[1] = MPI_DOUBLE;
32 /* The locations of each element */
33 MPI_Address( &value.a, &indices[0] );
34 MPI_Address( &value.b, &indices[1] );
35 MPI_Address( &tab, &indices[2] );
37 indices[2] = indices[2] - indices[0];
38 indices[1] = indices[1] - indices[0];
41 MPI_Type_struct( 3, blocklens, indices, old_types, &mystruct );
42 MPI_Type_commit( &mystruct );
52 MPI_Bcast( &value, 1, mystruct, 0, MPI_COMM_WORLD );
54 printf( "Process %d got %d (-2?) and %f (8.0?), tab (should be all 0): ", rank, value.a, value.b );
58 printf("%d ", tab[j][i]);
63 /* Clean up the type */
64 MPI_Type_free( &mystruct );
65 MPI_Type_free( &type2 );