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 main(int argc, char *argv[]);
19 int parse_args(int argc, char **argv);
21 int main(int argc, char *argv[])
23 /* Variable declarations */
24 int a[100][100], b[100][100];
25 MPI_Datatype row, xpose;
29 int bufsize, position = 0;
34 /* Initialize a to some known values. */
35 for(i = 0; i < 100; i++) {
36 for(j = 0; j < 100; j++) {
43 MPI_Init(&argc, &argv);
44 parse_args(argc, argv);
46 MPI_Type_extent(MPI_INT, &sizeofint);
48 /* Create datatypes. */
49 MPI_Type_vector(100, 1, 100, MPI_INT, &row);
50 MPI_Type_hvector(100, 1, sizeofint, row, &xpose);
51 MPI_Type_commit(&xpose);
54 MPI_Pack_size(1, xpose, MPI_COMM_WORLD, &bufsize);
55 buffer = (char *) malloc((unsigned) bufsize);
57 /* To improve reporting of problems about operations, we
58 change the error handler to errors return */
59 MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
69 /* Unpack the buffer into b. */
71 err = MPI_Unpack(buffer,
79 for (i = 0; i < 100; i++) {
80 for (j = 0; j < 100; j++) {
81 if(b[i][j] != a[j][i]) {
83 if (verbose) fprintf(stderr, "b[%d][%d] = %d, should be %d\n",
84 i, j, b[i][j], a[j][i]);
89 MPI_Type_free(&xpose);
92 /* print message and exit */
94 fprintf(stderr, "Found %d errors\n", errs);
97 printf(" No Errors\n");
104 int parse_args(int argc, char **argv)
109 while ((ret = getopt(argc, argv, "v")) >= 0)
118 if (argc > 1 && strcmp(argv[1], "-v") == 0)