4 int main( int argc, char **argv)
7 MPI_Datatype tmptype, newtype, oldtypes[2];
8 MPI_Aint offsets[2], extent, lb, ub;
10 MPI_Init(&argc, &argv);
14 oldtypes[0] = MPI_BYTE;
15 blockcnt[1] = 1; /* set upper bound to avoid padding */
18 MPI_Type_struct(2, blockcnt, offsets, oldtypes, &tmptype);
19 MPI_Type_commit(&tmptype);
21 MPI_Type_size(tmptype, &size);
22 MPI_Type_lb(tmptype, &lb);
23 MPI_Type_ub(tmptype, &ub);
24 MPI_Type_extent(tmptype, &extent);
26 printf("tmptype: size: %d lb: %ld ub: %ld ex: %ld\n", size, lb, ub,
32 oldtypes[0] = tmptype;
33 MPI_Type_struct(1, blockcnt, offsets, oldtypes, &newtype);
34 MPI_Type_commit(&newtype);
36 MPI_Type_size(newtype, &size);
37 MPI_Type_lb(newtype, &lb);
38 MPI_Type_ub(newtype, &ub);
39 MPI_Type_extent(newtype, &extent);
41 printf("newtype: size: %ld lb: %ld ub: %ld ex: %d\n", size, lb, ub,
44 if (size != 1 || lb != 2 || ub != 3 || extent != 1) {
45 printf ("lb = %ld (should be 2), ub = %ld (should be 3) extent = %ld should be 1, size = %d (should be 1)\n", lb, ub, extent, size) ;
48 printf( " No Errors\n" );
50 MPI_Type_free(&tmptype);
51 MPI_Type_free(&newtype);