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.
11 #include "mpitestconf.h"
16 static int verbose = 0;
18 int parse_args(int argc, char **argv);
20 int main(int argc, char *argv[])
22 /* Variable declarations */
23 int a[100][100], b[100][100];
24 MPI_Datatype row, xpose;
27 int /* err, */ errs = 0;
28 int bufsize, position = 0;
33 /* Initialize a to some known values. */
34 for(i = 0; i < 100; i++) {
35 for(j = 0; j < 100; j++) {
42 MPI_Init(&argc, &argv);
43 parse_args(argc, argv);
45 MPI_Type_extent(MPI_INT, &sizeofint);
47 /* Create datatypes. */
48 MPI_Type_vector(100, 1, 100, MPI_INT, &row);
49 MPI_Type_hvector(100, 1, sizeofint, row, &xpose);
50 MPI_Type_commit(&xpose);
53 MPI_Pack_size(1, xpose, MPI_COMM_WORLD, &bufsize);
54 buffer = (char *) malloc((unsigned) bufsize);
56 /* To improve reporting of problems about operations, we
57 change the error handler to errors return */
58 MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
60 /* err = */ MPI_Pack(a,
68 /* Unpack the buffer into b. */
70 /* err = */ MPI_Unpack(buffer,
78 for (i = 0; i < 100; i++) {
79 for (j = 0; j < 100; j++) {
80 if(b[i][j] != a[j][i]) {
82 if (verbose) fprintf(stderr, "b[%d][%d] = %d, should be %d\n",
83 i, j, b[i][j], a[j][i]);
88 MPI_Type_free(&xpose);
91 /* print message and exit */
93 fprintf(stderr, "Found %d errors\n", errs);
96 printf(" No Errors\n");
103 int parse_args(int argc, char **argv)
108 while ((ret = getopt(argc, argv, "v")) >= 0)
117 if (argc > 1 && strcmp(argv[1], "-v") == 0)