Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update datatype mpich tests
authordegomme <augustin.degomme@unibas.ch>
Sat, 11 Feb 2017 19:21:30 +0000 (20:21 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Sun, 12 Feb 2017 01:08:28 +0000 (02:08 +0100)
67 files changed:
teshsuite/smpi/mpich3-test/datatype/CMakeLists.txt
teshsuite/smpi/mpich3-test/datatype/blockindexed-misc.c
teshsuite/smpi/mpich3-test/datatype/blockindexed-zero-count.c
teshsuite/smpi/mpich3-test/datatype/contents.c
teshsuite/smpi/mpich3-test/datatype/contig-zero-count.c
teshsuite/smpi/mpich3-test/datatype/contigstruct.c
teshsuite/smpi/mpich3-test/datatype/darray-cyclic.c
teshsuite/smpi/mpich3-test/datatype/darray-pack.c
teshsuite/smpi/mpich3-test/datatype/dataalign.c
teshsuite/smpi/mpich3-test/datatype/gaddress.c
teshsuite/smpi/mpich3-test/datatype/get-elements-pairtype.c
teshsuite/smpi/mpich3-test/datatype/get-elements.c
teshsuite/smpi/mpich3-test/datatype/get-struct.c [deleted file]
teshsuite/smpi/mpich3-test/datatype/getpartelm.c
teshsuite/smpi/mpich3-test/datatype/hindexed-zeros.c
teshsuite/smpi/mpich3-test/datatype/hindexed_block.c
teshsuite/smpi/mpich3-test/datatype/hindexed_block_contents.c
teshsuite/smpi/mpich3-test/datatype/hvecblklen.c
teshsuite/smpi/mpich3-test/datatype/indexed-misc.c
teshsuite/smpi/mpich3-test/datatype/large-count.c
teshsuite/smpi/mpich3-test/datatype/large_type.c
teshsuite/smpi/mpich3-test/datatype/large_type_sendrec.c
teshsuite/smpi/mpich3-test/datatype/large_vec.c [new file with mode: 0644]
teshsuite/smpi/mpich3-test/datatype/lbub.c
teshsuite/smpi/mpich3-test/datatype/localpack.c
teshsuite/smpi/mpich3-test/datatype/longdouble.c
teshsuite/smpi/mpich3-test/datatype/lots-of-types.c
teshsuite/smpi/mpich3-test/datatype/pairtype-pack.c
teshsuite/smpi/mpich3-test/datatype/pairtype-size-extent.c
teshsuite/smpi/mpich3-test/datatype/segtest.c
teshsuite/smpi/mpich3-test/datatype/sendrecvt2.c
teshsuite/smpi/mpich3-test/datatype/sendrecvt4.c
teshsuite/smpi/mpich3-test/datatype/simple-commit.c
teshsuite/smpi/mpich3-test/datatype/simple-pack-external.c
teshsuite/smpi/mpich3-test/datatype/simple-pack-external2.c [new file with mode: 0644]
teshsuite/smpi/mpich3-test/datatype/simple-pack.c
teshsuite/smpi/mpich3-test/datatype/simple-resized.c
teshsuite/smpi/mpich3-test/datatype/simple-size-extent.c
teshsuite/smpi/mpich3-test/datatype/sizedtypes.c
teshsuite/smpi/mpich3-test/datatype/slice-pack-external.c
teshsuite/smpi/mpich3-test/datatype/slice-pack.c
teshsuite/smpi/mpich3-test/datatype/struct-derived-zeros.c
teshsuite/smpi/mpich3-test/datatype/struct-empty-el.c
teshsuite/smpi/mpich3-test/datatype/struct-ezhov.c
teshsuite/smpi/mpich3-test/datatype/struct-no-real-types.c
teshsuite/smpi/mpich3-test/datatype/struct-pack.c
teshsuite/smpi/mpich3-test/datatype/struct-verydeep.c
teshsuite/smpi/mpich3-test/datatype/struct-zero-count.c
teshsuite/smpi/mpich3-test/datatype/structpack2.c
teshsuite/smpi/mpich3-test/datatype/subarray-pack.c
teshsuite/smpi/mpich3-test/datatype/subarray.c
teshsuite/smpi/mpich3-test/datatype/testlist
teshsuite/smpi/mpich3-test/datatype/tfree.c
teshsuite/smpi/mpich3-test/datatype/tmatchsize.c
teshsuite/smpi/mpich3-test/datatype/transpose-pack.c
teshsuite/smpi/mpich3-test/datatype/tresized.c
teshsuite/smpi/mpich3-test/datatype/tresized2.c
teshsuite/smpi/mpich3-test/datatype/triangular-pack.c
teshsuite/smpi/mpich3-test/datatype/typecommit.c
teshsuite/smpi/mpich3-test/datatype/typefree.c
teshsuite/smpi/mpich3-test/datatype/typelb.c
teshsuite/smpi/mpich3-test/datatype/unpack.c
teshsuite/smpi/mpich3-test/datatype/unusual-noncontigs.c
teshsuite/smpi/mpich3-test/datatype/vecblklen.c
teshsuite/smpi/mpich3-test/datatype/zero-blklen-vector.c
teshsuite/smpi/mpich3-test/datatype/zeroblks.c
teshsuite/smpi/mpich3-test/datatype/zeroparms.c

index 600a2fb..4f8814c 100644 (file)
@@ -10,13 +10,13 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
 
   foreach(file blockindexed-zero-count contigstruct contig-zero-count cxx-types dataalign gaddress hindexed_block
-          hindexed_block_contents localpack longdouble simple-commit simple-pack simple-resized simple-size-extent
+          hindexed_block_contents large_vec localpack longdouble simple-commit simple-pack simple-resized simple-size-extent
           struct-derived-zeros struct-ezhov struct-pack struct-verydeep struct-zero-count tfree transpose-pack tresized2
           tresized typecommit typefree typelb typename unpack zeroblks zeroparms)
     # not compiled files
     # blockindexed-misc contents darray-cyclic darray-pack get-elements get-elements-pairtype getpartelm get-struct
     # hindexed-zeros hvecblklen indexed-misc large-count large_type large_type_sendrec lbub lots-of-type pairtype-pack
-    # pairtype-size-extent segtest simple-pack-external sizedtypes slice-pack slice-pack-external struct-empty-el
+    # pairtype-size-extent segtest simple-pack-external simple-pack-external2 sizedtypes slice-pack slice-pack-external struct-empty-el
     # struct-no-real-type structpack2 subarray subarray-pack tmatchsize triangular-pack unusual-noncontigs vecblklen
     # zero-blklen-vector
     add_executable(${file} ${file}.c)
@@ -27,6 +27,9 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   add_executable(sendrecvt4 ${CMAKE_CURRENT_SOURCE_DIR}/../util/dtypes.c sendrecvt4.c)
   target_link_libraries(sendrecvt2 simgrid mtest_c)
   target_link_libraries(sendrecvt4 simgrid mtest_c)
+  set_target_properties(hindexed_block PROPERTIES COMPILE_FLAGS "-DTEST_HINDEXED_BLOCK" LINK_FLAGS "-DTEST_HINDEXED_BLOCK")
+
+
 endif()
 
 if (enable_smpi_MPICH3_testsuite AND HAVE_RAW_CONTEXTS)
@@ -35,11 +38,11 @@ if (enable_smpi_MPICH3_testsuite AND HAVE_RAW_CONTEXTS)
 endif()
 
 foreach(file blockindexed-misc blockindexed-zero-count contents contigstruct contig-zero-count cxx-types darray-cyclic 
-        darray-pack dataalign gaddress get-elements get-elements-pairtype getpartelm get-struct hindexed_block
+        darray-pack dataalign gaddress get-elements get-elements-pairtype getpartelm hindexed_block
         hindexed_block_contents hindexed-zeros hvecblklen indexed-misc large-count large_type large_type_sendrec lbub
         localpack longdouble lots-of-types pairtype-pack pairtype-size-extent segtest sendrecvt2 sendrecvt4 
-        simple-commit simple-pack simple-pack-external simple-resized simple-size-extent sizedtypes slice-pack 
-        slice-pack-external struct-derived-zeros struct-empty-el struct-ezhov struct-no-real-types struct-pack 
+        simple-commit simple-pack simple-pack-external simple-pack-external2 simple-resized simple-size-extent sizedtypes slice-pack 
+        slice-pack-external large_vec struct-derived-zeros struct-empty-el struct-ezhov struct-no-real-types struct-pack 
         structpack2 struct-verydeep struct-zero-count subarray subarray-pack tfree tmatchsize transpose-pack tresized2
         tresized triangular-pack typecommit typefree typelb typename unpack unusual-noncontigs vecblklen 
         zero-blklen-vector zeroblks zeroparms)
index c3c59dc..d267205 100644 (file)
@@ -19,39 +19,36 @@ int blockindexed_vector_test(void);
 
 /* helper functions */
 int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
 
 int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = blockindexed_contig_test();
-    if (err && verbose) fprintf(stderr, "%d errors in blockindexed test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in blockindexed test.\n", err);
     errs += err;
 
     err = blockindexed_vector_test();
-    if (err && verbose) fprintf(stderr, "%d errors in blockindexed vector test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in blockindexed vector test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -59,14 +56,14 @@ int main(int argc, char **argv)
 
 /* blockindexed_contig_test()
  *
- * Tests behavior with a blockindexed that can be converted to a 
+ * Tests behavior with a blockindexed that can be converted to a
  * contig easily.  This is specifically for coverage.
  *
  * Returns the number of errors encountered.
  */
 int blockindexed_contig_test(void)
 {
-    int buf[4] = {7, -1, -2, -3};
+    int buf[4] = { 7, -1, -2, -3 };
     int err, errs = 0;
 
     int i, count = 1;
@@ -76,85 +73,75 @@ int blockindexed_contig_test(void)
     int size, int_size;
     MPI_Aint extent;
 
-    err = MPI_Type_create_indexed_block(count,
-                                       1,
-                                       &disp,
-                                       MPI_INT,
-                                       &newtype);
+    err = MPI_Type_create_indexed_block(count, 1, &disp, MPI_INT, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating struct type in blockindexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating struct type in blockindexed_contig_test()\n");
+        }
+        errs++;
     }
 
     MPI_Type_size(MPI_INT, &int_size);
 
     err = MPI_Type_size(newtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in blockindexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in blockindexed_contig_test()\n");
+        }
+        errs++;
     }
-    
+
     if (size != int_size) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != int_size in blockindexed_contig_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: size != int_size in blockindexed_contig_test()\n");
+        }
+        errs++;
+    }
 
     err = MPI_Type_extent(newtype, &extent);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type extent in blockindexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type extent in blockindexed_contig_test()\n");
+        }
+        errs++;
     }
-    
+
     if (extent != int_size) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: extent != int_size in blockindexed_contig_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: extent != int_size in blockindexed_contig_test()\n");
+        }
+        errs++;
+    }
 
     MPI_Type_commit(&newtype);
 
     err = pack_and_unpack((char *) buf, 1, newtype, 4 * sizeof(int));
     if (err != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error packing/unpacking in blockindexed_contig_test()\n");
-       }
-       errs += err;
+        if (verbose) {
+            fprintf(stderr, "error packing/unpacking in blockindexed_contig_test()\n");
+        }
+        errs += err;
     }
 
-    for (i=0; i < 4; i++) {
-       int goodval;
-
-       switch(i) {
-           case 0:
-               goodval = 7;
-               break;
-           default:
-               goodval = 0; /* pack_and_unpack() zeros before unpack */
-               break;
-       }
-       if (buf[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "buf[%d] = %d; should be %d\n",
-                                i, buf[i], goodval);
-       }
+    for (i = 0; i < 4; i++) {
+        int goodval;
+
+        switch (i) {
+        case 0:
+            goodval = 7;
+            break;
+        default:
+            goodval = 0;        /* pack_and_unpack() zeros before unpack */
+            break;
+        }
+        if (buf[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], goodval);
+        }
     }
-    
-    MPI_Type_free( &newtype );
+
+    MPI_Type_free(&newtype);
 
     return errs;
 }
@@ -170,22 +157,24 @@ int blockindexed_vector_test(void)
 {
 #define NELT (18)
     int buf[NELT] = { -1, -1, -1,
-                       1, -2,  2,
-                      -3, -3, -3,
-                      -4, -4, -4,
-                       3, -5,  4,
-                       5, -6,  6 };
+        1, -2, 2,
+        -3, -3, -3,
+        -4, -4, -4,
+        3, -5, 4,
+        5, -6, 6
+    };
     int expected[NELT] = {
-                       0,  0,  0,
-                       1,  0,  2,
-                       0,  0,  0,
-                       0,  0,  0,
-                       3,  0,  4,
-                       5,  0,  6 };
+        0, 0, 0,
+        1, 0, 2,
+        0, 0, 0,
+        0, 0, 0,
+        3, 0, 4,
+        5, 0, 6
+    };
     int err, errs = 0;
 
     int i, count = 3;
-    int disp[] = {1, 4, 5};
+    int disp[] = { 1, 4, 5 };
     MPI_Datatype vectype, newtype;
 
     int size, int_size;
@@ -193,66 +182,57 @@ int blockindexed_vector_test(void)
     /* create a vector type of 2 ints, skipping one in between */
     err = MPI_Type_vector(2, 1, 2, MPI_INT, &vectype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating vector type in blockindexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating vector type in blockindexed_contig_test()\n");
+        }
+        errs++;
     }
 
-    err = MPI_Type_create_indexed_block(count,
-                                       1,
-                                       disp,
-                                       vectype,
-                                       &newtype);
+    err = MPI_Type_create_indexed_block(count, 1, disp, vectype, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating blockindexed type in blockindexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating blockindexed type in blockindexed_contig_test()\n");
+        }
+        errs++;
     }
 
     MPI_Type_size(MPI_INT, &int_size);
 
     err = MPI_Type_size(newtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in blockindexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in blockindexed_contig_test()\n");
+        }
+        errs++;
     }
-    
+
     if (size != 6 * int_size) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != 6 * int_size in blockindexed_contig_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: size != 6 * int_size in blockindexed_contig_test()\n");
+        }
+        errs++;
+    }
 
     MPI_Type_commit(&newtype);
 
     err = pack_and_unpack((char *) buf, 1, newtype, NELT * sizeof(int));
     if (err != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error packing/unpacking in blockindexed_vector_test()\n");
-       }
-       errs += err;
+        if (verbose) {
+            fprintf(stderr, "error packing/unpacking in blockindexed_vector_test()\n");
+        }
+        errs += err;
     }
 
-    for (i=0; i < NELT; i++) {
-       if (buf[i] != expected[i]) {
-           errs++;
-           if (verbose) fprintf(stderr, "buf[%d] = %d; should be %d\n",
-                                i, buf[i], expected[i]);
-       }
+    for (i = 0; i < NELT; i++) {
+        if (buf[i] != expected[i]) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], expected[i]);
+        }
     }
 
-    MPI_Type_free( &vectype );
-    MPI_Type_free( &newtype );
+    MPI_Type_free(&vectype);
+    MPI_Type_free(&newtype);
     return errs;
 }
 
@@ -272,87 +252,64 @@ int blockindexed_vector_test(void)
  *             between the pack and unpack steps
  *
  */
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
 {
     char *packbuf;
     int err, errs = 0, pack_size, type_size, position;
 
     err = MPI_Type_size(datatype, &type_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     type_size *= count;
 
     err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Pack_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     packbuf = (char *) malloc(pack_size);
     if (packbuf == NULL) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in malloc call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     position = 0;
-    err = MPI_Pack(typebuf,
-                  count,
-                  datatype,
-                  packbuf,
-                  type_size,
-                  &position,
-                  MPI_COMM_SELF);
+    err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
     }
 
     memset(typebuf, 0, typebufsz);
     position = 0;
-    err = MPI_Unpack(packbuf,
-                    type_size,
-                    &position,
-                    typebuf,
-                    count,
-                    datatype,
-                    MPI_COMM_SELF);
+    err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Unpack call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     free(packbuf);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
     }
 
     return errs;
@@ -361,19 +318,18 @@ static int pack_and_unpack(char *typebuf,
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index f7d14b0..88a2d5f 100644 (file)
@@ -23,25 +23,25 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = blockindexed_test();
-    if (err && verbose) fprintf(stderr, "%d errors in blockindexed test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in blockindexed test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -63,54 +63,45 @@ int blockindexed_test(void)
     int size;
     MPI_Aint extent;
 
-    err = MPI_Type_create_indexed_block(count,
-                                       0,
-                                       (int *) 0,
-                                       MPI_INT,
-                                       &newtype);
+    err = MPI_Type_create_indexed_block(count, 0, (int *) 0, MPI_INT, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating struct type in blockindexed_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating struct type in blockindexed_test()\n");
+        }
+        errs++;
     }
 
     err = MPI_Type_size(newtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in blockindexed_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in blockindexed_test()\n");
+        }
+        errs++;
     }
-    
+
     if (size != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != 0 in blockindexed_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: size != 0 in blockindexed_test()\n");
+        }
+        errs++;
+    }
 
     err = MPI_Type_extent(newtype, &extent);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type extent in blockindexed_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type extent in blockindexed_test()\n");
+        }
+        errs++;
     }
-    
+
     if (extent != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: extent != 0 in blockindexed_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: extent != 0 in blockindexed_test()\n");
+        }
+        errs++;
+    }
 
-    MPI_Type_free( &newtype );
+    MPI_Type_free(&newtype);
 
     return errs;
 }
@@ -119,19 +110,18 @@ int blockindexed_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index 61ee87a..53d2a90 100644 (file)
@@ -5,7 +5,7 @@
  */
 #include "mpi.h"
 #include "mpitestconf.h"
-#if HAVE_UNISTD_H
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <stdio.h>
@@ -29,42 +29,42 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = builtin_float_test();
     errs += err;
     if (err) {
-       fprintf(stderr, "Found %d errors in builtin float test.\n", err);
+        fprintf(stderr, "Found %d errors in builtin float test.\n", err);
     }
 
     err = vector_of_vectors_test();
     errs += err;
     if (err) {
-       fprintf(stderr, "Found %d errors in vector of vectors test.\n", err);
+        fprintf(stderr, "Found %d errors in vector of vectors test.\n", err);
     }
 
     err = optimizable_vector_of_basics_test();
     errs += err;
     if (err) {
-       fprintf(stderr, "Found %d errors in vector of basics test.\n", err);
+        fprintf(stderr, "Found %d errors in vector of basics test.\n", err);
     }
 
     err = indexed_of_basics_test();
     errs += err;
     if (err) {
-       fprintf(stderr, "Found %d errors in indexed of basics test.\n", err);
+        fprintf(stderr, "Found %d errors in indexed of basics test.\n", err);
     }
 
     err = indexed_of_vectors_test();
     errs += err;
     if (err) {
-       fprintf(stderr, "Found %d errors in indexed of vectors test.\n", err);
+        fprintf(stderr, "Found %d errors in indexed of vectors test.\n", err);
     }
 
 #ifdef HAVE_MPI_TYPE_CREATE_STRUCT
@@ -74,10 +74,10 @@ int main(int argc, char **argv)
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -93,18 +93,14 @@ int builtin_float_test(void)
 {
     int nints, nadds, ntypes, combiner;
 
-    int /* err, */ errs = 0;
+    int err, errs = 0;
+
+    err = MPI_Type_get_envelope(MPI_FLOAT, &nints, &nadds, &ntypes, &combiner);
 
-    /* err = */ MPI_Type_get_envelope(MPI_FLOAT,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
-    
-    if (combiner != MPI_COMBINER_NAMED) errs++;
+    if (combiner != MPI_COMBINER_NAMED)
+        errs++;
     if (verbose && combiner != MPI_COMBINER_NAMED)
-       fprintf(stderr, "combiner = %s; should be named\n", 
-               combiner_to_string(combiner));
+        fprintf(stderr, "combiner = %s; should be named\n", combiner_to_string(combiner));
 
     /* Note: it is erroneous to call MPI_Type_get_contents() on a basic. */
     return errs;
@@ -112,8 +108,8 @@ int builtin_float_test(void)
 
 /* vector_of_vectors_test()
  *
- * Builds a vector of a vector of ints.  Assuming an int array of size 9 
- * integers, and treating the array as a 3x3 2D array, this will grab the 
+ * Builds a vector of a vector of ints.  Assuming an int array of size 9
+ * integers, and treating the array as a 3x3 2D array, this will grab the
  * corners.
  *
  * Returns the number of errors encountered.
@@ -130,180 +126,159 @@ int vector_of_vectors_test(void)
     int err, errs = 0;
 
     /* set up type */
-    err = MPI_Type_vector(2,
-                         1,
-                         2,
-                         MPI_INT,
-                         &inner_vector);
+    err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
-    err = MPI_Type_vector(2,
-                         1,
-                         2,
-                         inner_vector,
-                         &outer_vector);
+    err = MPI_Type_vector(2, 1, 2, inner_vector, &outer_vector);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
     /* decode outer vector (get envelope, then contents) */
-    err = MPI_Type_get_envelope(outer_vector,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
+    err = MPI_Type_get_envelope(outer_vector, &nints, &nadds, &ntypes, &combiner);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
-    if (nints != 3) errs++;
-    if (nadds != 0) errs++;
-    if (ntypes != 1) errs++;
-    if (combiner != MPI_COMBINER_VECTOR) errs++;
+    if (nints != 3)
+        errs++;
+    if (nadds != 0)
+        errs++;
+    if (ntypes != 1)
+        errs++;
+    if (combiner != MPI_COMBINER_VECTOR)
+        errs++;
 
     if (verbose) {
-       if (nints != 3) fprintf(stderr, 
-                               "outer vector nints = %d; should be 3\n",
-                               nints);
-       if (nadds != 0) fprintf(stderr, 
-                               "outer vector nadds = %d; should be 0\n",
-                               nadds);
-       if (ntypes != 1) fprintf(stderr, 
-                                "outer vector ntypes = %d; should be 1\n",
-                                ntypes);
-       if (combiner != MPI_COMBINER_VECTOR)
-           fprintf(stderr, "outer vector combiner = %s; should be vector\n",
-                   combiner_to_string(combiner));
+        if (nints != 3)
+            fprintf(stderr, "outer vector nints = %d; should be 3\n", nints);
+        if (nadds != 0)
+            fprintf(stderr, "outer vector nadds = %d; should be 0\n", nadds);
+        if (ntypes != 1)
+            fprintf(stderr, "outer vector ntypes = %d; should be 1\n", ntypes);
+        if (combiner != MPI_COMBINER_VECTOR)
+            fprintf(stderr, "outer vector combiner = %s; should be vector\n",
+                    combiner_to_string(combiner));
     }
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     ints = malloc(nints * sizeof(*ints));
-    if (nadds) adds = malloc(nadds * sizeof(*adds));
+    if (nadds)
+        adds = malloc(nadds * sizeof(*adds));
     types = malloc(ntypes * sizeof(*types));
 
     /* get contents of outer vector */
-    err = MPI_Type_get_contents(outer_vector,
-                               nints,
-                               nadds,
-                               ntypes,
-                               ints,
-                               adds,
-                               types);
-
-    if (ints[0] != 2) errs++;
-    if (ints[1] != 1) errs++;
-    if (ints[2] != 2) errs++;
+    err = MPI_Type_get_contents(outer_vector, nints, nadds, ntypes, ints, adds, types);
+
+    if (ints[0] != 2)
+        errs++;
+    if (ints[1] != 1)
+        errs++;
+    if (ints[2] != 2)
+        errs++;
 
     if (verbose) {
-       if (ints[0] != 2) fprintf(stderr, 
-                                 "outer vector count = %d; should be 2\n",
-                                 ints[0]);
-       if (ints[1] != 1) fprintf(stderr,
-                                 "outer vector blocklength = %d; should be 1\n",
-                                 ints[1]);
-       if (ints[2] != 2) fprintf(stderr, "outer vector stride = %d; should be 2\n",
-                                 ints[2]);
+        if (ints[0] != 2)
+            fprintf(stderr, "outer vector count = %d; should be 2\n", ints[0]);
+        if (ints[1] != 1)
+            fprintf(stderr, "outer vector blocklength = %d; should be 1\n", ints[1]);
+        if (ints[2] != 2)
+            fprintf(stderr, "outer vector stride = %d; should be 2\n", ints[2]);
     }
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     inner_vector_copy = types[0];
     free(ints);
-    if (nadds) free(adds);
+    if (nadds)
+        free(adds);
     free(types);
 
     /* decode inner vector */
-    err = MPI_Type_get_envelope(inner_vector_copy,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
+    err = MPI_Type_get_envelope(inner_vector_copy, &nints, &nadds, &ntypes, &combiner);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
-    if (nints != 3) errs++;
-    if (nadds != 0) errs++;
-    if (ntypes != 1) errs++;
-    if (combiner != MPI_COMBINER_VECTOR) errs++;
+    if (nints != 3)
+        errs++;
+    if (nadds != 0)
+        errs++;
+    if (ntypes != 1)
+        errs++;
+    if (combiner != MPI_COMBINER_VECTOR)
+        errs++;
 
     if (verbose) {
-       if (nints != 3) fprintf(stderr, 
-                               "inner vector nints = %d; should be 3\n",
-                               nints);
-       if (nadds != 0) fprintf(stderr, 
-                               "inner vector nadds = %d; should be 0\n",
-                               nadds);
-       if (ntypes != 1) fprintf(stderr, 
-                                "inner vector ntypes = %d; should be 1\n",
-                                ntypes);
-       if (combiner != MPI_COMBINER_VECTOR)
-           fprintf(stderr, "inner vector combiner = %s; should be vector\n",
-                   combiner_to_string(combiner));
+        if (nints != 3)
+            fprintf(stderr, "inner vector nints = %d; should be 3\n", nints);
+        if (nadds != 0)
+            fprintf(stderr, "inner vector nadds = %d; should be 0\n", nadds);
+        if (ntypes != 1)
+            fprintf(stderr, "inner vector ntypes = %d; should be 1\n", ntypes);
+        if (combiner != MPI_COMBINER_VECTOR)
+            fprintf(stderr, "inner vector combiner = %s; should be vector\n",
+                    combiner_to_string(combiner));
     }
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     ints = malloc(nints * sizeof(*ints));
-    if (nadds) adds = malloc(nadds * sizeof(*adds));
+    if (nadds)
+        adds = malloc(nadds * sizeof(*adds));
     types = malloc(ntypes * sizeof(*types));
 
-    err = MPI_Type_get_contents(inner_vector_copy,
-                               nints,
-                               nadds,
-                               ntypes,
-                               ints,
-                               adds,
-                               types);
+    err = MPI_Type_get_contents(inner_vector_copy, nints, nadds, ntypes, ints, adds, types);
 
-    if (ints[0] != 2) errs++;
-    if (ints[1] != 1) errs++;
-    if (ints[2] != 2) errs++;
+    if (ints[0] != 2)
+        errs++;
+    if (ints[1] != 1)
+        errs++;
+    if (ints[2] != 2)
+        errs++;
 
     if (verbose) {
-       if (ints[0] != 2) fprintf(stderr, 
-                                 "inner vector count = %d; should be 2\n",
-                                 ints[0]);
-       if (ints[1] != 1) fprintf(stderr,
-                                 "inner vector blocklength = %d; should be 1\n",
-                                 ints[1]);
-       if (ints[2] != 2) fprintf(stderr, 
-                                 "inner vector stride = %d; should be 2\n",
-                                 ints[2]);
+        if (ints[0] != 2)
+            fprintf(stderr, "inner vector count = %d; should be 2\n", ints[0]);
+        if (ints[1] != 1)
+            fprintf(stderr, "inner vector blocklength = %d; should be 1\n", ints[1]);
+        if (ints[2] != 2)
+            fprintf(stderr, "inner vector stride = %d; should be 2\n", ints[2]);
     }
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     free(ints);
-    if (nadds) free(adds);
+    if (nadds)
+        free(adds);
     free(types);
 
-    MPI_Type_free( &inner_vector_copy );
-    MPI_Type_free( &inner_vector );
-    MPI_Type_free( &outer_vector );
+    MPI_Type_free(&inner_vector_copy);
+    MPI_Type_free(&inner_vector);
+    MPI_Type_free(&outer_vector);
 
     return 0;
 }
@@ -324,68 +299,67 @@ int optimizable_vector_of_basics_test(void)
     MPI_Aint *adds = NULL;
     MPI_Datatype *types;
 
-    int /* err, */ errs = 0;
+    int err, errs = 0;
 
     /* set up type */
-    /* err = */ MPI_Type_vector(10,
-                         2,
-                         2,
-                         MPI_INT,
-                         &parent_type);
+    err = MPI_Type_vector(10, 2, 2, MPI_INT, &parent_type);
 
     /* decode */
-    /* err = */ MPI_Type_get_envelope(parent_type,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
+    err = MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
 
-    if (nints != 3) errs++;
-    if (nadds != 0) errs++;
-    if (ntypes != 1) errs++;
-    if (combiner != MPI_COMBINER_VECTOR) errs++;
+    if (nints != 3)
+        errs++;
+    if (nadds != 0)
+        errs++;
+    if (ntypes != 1)
+        errs++;
+    if (combiner != MPI_COMBINER_VECTOR)
+        errs++;
 
     if (verbose) {
-        if (nints != 3) fprintf(stderr, "nints = %d; should be 3\n", nints);
-       if (nadds != 0) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
-       if (ntypes != 1) fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
-       if (combiner != MPI_COMBINER_VECTOR)
-           fprintf(stderr, "combiner = %s; should be vector\n",
-                   combiner_to_string(combiner));
+        if (nints != 3)
+            fprintf(stderr, "nints = %d; should be 3\n", nints);
+        if (nadds != 0)
+            fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+        if (ntypes != 1)
+            fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
+        if (combiner != MPI_COMBINER_VECTOR)
+            fprintf(stderr, "combiner = %s; should be vector\n", combiner_to_string(combiner));
     }
 
     ints = malloc(nints * sizeof(*ints));
-    if (nadds) adds = malloc(nadds * sizeof(*adds));
-    types = malloc(ntypes *sizeof(*types));
-
-    /* err = */ MPI_Type_get_contents(parent_type,
-                               nints,
-                               nadds,
-                               ntypes,
-                               ints,
-                               adds,
-                               types);
-
-    if (ints[0] != 10) errs++;
-    if (ints[1] != 2) errs++;
-    if (ints[2] != 2) errs++;
-    if (types[0] != MPI_INT) errs++;
+    if (nadds)
+        adds = malloc(nadds * sizeof(*adds));
+    types = malloc(ntypes * sizeof(*types));
+
+    err = MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
+
+    if (ints[0] != 10)
+        errs++;
+    if (ints[1] != 2)
+        errs++;
+    if (ints[2] != 2)
+        errs++;
+    if (types[0] != MPI_INT)
+        errs++;
 
     if (verbose) {
-       if (ints[0] != 10) fprintf(stderr, "count = %d; should be 10\n",
-                                  ints[0]);
-       if (ints[1] != 2) fprintf(stderr, "blocklength = %d; should be 2\n",
-                                 ints[1]);
-       if (ints[2] != 2) fprintf(stderr, "stride = %d; should be 2\n",
-                                 ints[2]);
-       if (types[0] != MPI_INT) fprintf(stderr, "type is not MPI_INT\n");
+        if (ints[0] != 10)
+            fprintf(stderr, "count = %d; should be 10\n", ints[0]);
+        if (ints[1] != 2)
+            fprintf(stderr, "blocklength = %d; should be 2\n", ints[1]);
+        if (ints[2] != 2)
+            fprintf(stderr, "stride = %d; should be 2\n", ints[2]);
+        if (types[0] != MPI_INT)
+            fprintf(stderr, "type is not MPI_INT\n");
     }
 
     free(ints);
-    if (nadds) free(adds);
+    if (nadds)
+        free(adds);
     free(types);
 
-    MPI_Type_free( &parent_type );
+    MPI_Type_free(&parent_type);
 
     return errs;
 }
@@ -407,80 +381,83 @@ int indexed_of_basics_test(void)
     MPI_Aint *adds = NULL;
     MPI_Datatype *types;
 
-    int /* err, */ errs = 0;
+    int err, errs = 0;
 
     /* set up type */
-    /* err = */ MPI_Type_indexed(s_count,
-                          s_blocklengths,
-                          s_displacements,
-                          MPI_INT,
-                          &parent_type);
+    err = MPI_Type_indexed(s_count, s_blocklengths, s_displacements, MPI_INT, &parent_type);
 
     /* decode */
-    /* err = */ MPI_Type_get_envelope(parent_type,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
+    err = MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
 
-    if (nints != 7) errs++;
-    if (nadds != 0) errs++;
-    if (ntypes != 1) errs++;
-    if (combiner != MPI_COMBINER_INDEXED) errs++;
+    if (nints != 7)
+        errs++;
+    if (nadds != 0)
+        errs++;
+    if (ntypes != 1)
+        errs++;
+    if (combiner != MPI_COMBINER_INDEXED)
+        errs++;
 
     if (verbose) {
-        if (nints != 7) fprintf(stderr, "nints = %d; should be 7\n", nints);
-       if (nadds != 0) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
-       if (ntypes != 1) fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
-       if (combiner != MPI_COMBINER_INDEXED)
-           fprintf(stderr, "combiner = %s; should be indexed\n",
-                   combiner_to_string(combiner));
+        if (nints != 7)
+            fprintf(stderr, "nints = %d; should be 7\n", nints);
+        if (nadds != 0)
+            fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+        if (ntypes != 1)
+            fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
+        if (combiner != MPI_COMBINER_INDEXED)
+            fprintf(stderr, "combiner = %s; should be indexed\n", combiner_to_string(combiner));
     }
 
     ints = malloc(nints * sizeof(*ints));
-    if (nadds) adds = malloc(nadds * sizeof(*adds));
-    types = malloc(ntypes *sizeof(*types));
-
-    /* err = */ MPI_Type_get_contents(parent_type,
-                               nints,
-                               nadds,
-                               ntypes,
-                               ints,
-                               adds,
-                               types);
-
-    if (ints[0] != s_count) errs++;
-    if (ints[1] != s_blocklengths[0]) errs++;
-    if (ints[2] != s_blocklengths[1]) errs++;
-    if (ints[3] != s_blocklengths[2]) errs++;
-    if (ints[4] != s_displacements[0]) errs++;
-    if (ints[5] != s_displacements[1]) errs++;
-    if (ints[6] != s_displacements[2]) errs++;
-    if (types[0] != MPI_INT) errs++;
+    if (nadds)
+        adds = malloc(nadds * sizeof(*adds));
+    types = malloc(ntypes * sizeof(*types));
+
+    err = MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
+
+    if (ints[0] != s_count)
+        errs++;
+    if (ints[1] != s_blocklengths[0])
+        errs++;
+    if (ints[2] != s_blocklengths[1])
+        errs++;
+    if (ints[3] != s_blocklengths[2])
+        errs++;
+    if (ints[4] != s_displacements[0])
+        errs++;
+    if (ints[5] != s_displacements[1])
+        errs++;
+    if (ints[6] != s_displacements[2])
+        errs++;
+    if (types[0] != MPI_INT)
+        errs++;
 
     if (verbose) {
-       if (ints[0] != s_count) 
-           fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
-       if (ints[1] != s_blocklengths[0]) 
-           fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
-       if (ints[2] != s_blocklengths[1]) 
-           fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
-       if (ints[3] != s_blocklengths[2]) 
-           fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
-       if (ints[4] != s_displacements[0]) 
-           fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], s_displacements[0]);
-       if (ints[5] != s_displacements[1]) 
-           fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], s_displacements[1]);
-       if (ints[6] != s_displacements[2]) 
-           fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], s_displacements[2]);
-       if (types[0] != MPI_INT) fprintf(stderr, "type[0] does not match\n");
+        if (ints[0] != s_count)
+            fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
+        if (ints[1] != s_blocklengths[0])
+            fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
+        if (ints[2] != s_blocklengths[1])
+            fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
+        if (ints[3] != s_blocklengths[2])
+            fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
+        if (ints[4] != s_displacements[0])
+            fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], s_displacements[0]);
+        if (ints[5] != s_displacements[1])
+            fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], s_displacements[1]);
+        if (ints[6] != s_displacements[2])
+            fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], s_displacements[2]);
+        if (types[0] != MPI_INT)
+            fprintf(stderr, "type[0] does not match\n");
     }
 
     free(ints);
-    if (nadds) free(adds);
+    if (nadds)
+        free(adds);
     free(types);
 
-    MPI_Type_free( &parent_type );
+    MPI_Type_free(&parent_type);
     return errs;
 }
 
@@ -494,7 +471,7 @@ int indexed_of_vectors_test(void)
 {
     MPI_Datatype inner_vector, inner_vector_copy;
     MPI_Datatype outer_indexed;
-    
+
     int i_count = 3, i_blocklengths[3] = { 3, 2, 1 };
     int i_displacements[3] = { 10, 20, 30 };
 
@@ -505,186 +482,176 @@ int indexed_of_vectors_test(void)
     int err, errs = 0;
 
     /* set up type */
-    err = MPI_Type_vector(2,
-                         1,
-                         2,
-                         MPI_INT,
-                         &inner_vector);
+    err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
-    err = MPI_Type_indexed(i_count,
-                          i_blocklengths,
-                          i_displacements,
-                          inner_vector,
-                          &outer_indexed);
+    err = MPI_Type_indexed(i_count, i_blocklengths, i_displacements, inner_vector, &outer_indexed);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
     /* decode outer vector (get envelope, then contents) */
-    err = MPI_Type_get_envelope(outer_indexed,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
+    err = MPI_Type_get_envelope(outer_indexed, &nints, &nadds, &ntypes, &combiner);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
-    if (nints != 7) errs++;
-    if (nadds != 0) errs++;
-    if (ntypes != 1) errs++;
-    if (combiner != MPI_COMBINER_INDEXED) errs++;
+    if (nints != 7)
+        errs++;
+    if (nadds != 0)
+        errs++;
+    if (ntypes != 1)
+        errs++;
+    if (combiner != MPI_COMBINER_INDEXED)
+        errs++;
 
     if (verbose) {
-        if (nints != 7) fprintf(stderr, "nints = %d; should be 7\n", nints);
-       if (nadds != 0) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
-       if (ntypes != 1) fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
-       if (combiner != MPI_COMBINER_INDEXED)
-           fprintf(stderr, "combiner = %s; should be indexed\n",
-                   combiner_to_string(combiner));
+        if (nints != 7)
+            fprintf(stderr, "nints = %d; should be 7\n", nints);
+        if (nadds != 0)
+            fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+        if (ntypes != 1)
+            fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
+        if (combiner != MPI_COMBINER_INDEXED)
+            fprintf(stderr, "combiner = %s; should be indexed\n", combiner_to_string(combiner));
     }
 
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     ints = malloc(nints * sizeof(*ints));
-    if (nadds) adds = malloc(nadds * sizeof(*adds));
+    if (nadds)
+        adds = malloc(nadds * sizeof(*adds));
     types = malloc(ntypes * sizeof(*types));
 
     /* get contents of outer vector */
-    err = MPI_Type_get_contents(outer_indexed,
-                               nints,
-                               nadds,
-                               ntypes,
-                               ints,
-                               adds,
-                               types);
-
-    if (ints[0] != i_count) errs++;
-    if (ints[1] != i_blocklengths[0]) errs++;
-    if (ints[2] != i_blocklengths[1]) errs++;
-    if (ints[3] != i_blocklengths[2]) errs++;
-    if (ints[4] != i_displacements[0]) errs++;
-    if (ints[5] != i_displacements[1]) errs++;
-    if (ints[6] != i_displacements[2]) errs++;
+    err = MPI_Type_get_contents(outer_indexed, nints, nadds, ntypes, ints, adds, types);
+
+    if (ints[0] != i_count)
+        errs++;
+    if (ints[1] != i_blocklengths[0])
+        errs++;
+    if (ints[2] != i_blocklengths[1])
+        errs++;
+    if (ints[3] != i_blocklengths[2])
+        errs++;
+    if (ints[4] != i_displacements[0])
+        errs++;
+    if (ints[5] != i_displacements[1])
+        errs++;
+    if (ints[6] != i_displacements[2])
+        errs++;
 
     if (verbose) {
-       if (ints[0] != i_count) 
-           fprintf(stderr, "count = %d; should be %d\n", ints[0], i_count);
-       if (ints[1] != i_blocklengths[0]) 
-           fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], i_blocklengths[0]);
-       if (ints[2] != i_blocklengths[1]) 
-           fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], i_blocklengths[1]);
-       if (ints[3] != i_blocklengths[2]) 
-           fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], i_blocklengths[2]);
-       if (ints[4] != i_displacements[0]) 
-           fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], i_displacements[0]);
-       if (ints[5] != i_displacements[1]) 
-           fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], i_displacements[1]);
-       if (ints[6] != i_displacements[2]) 
-           fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], i_displacements[2]);
+        if (ints[0] != i_count)
+            fprintf(stderr, "count = %d; should be %d\n", ints[0], i_count);
+        if (ints[1] != i_blocklengths[0])
+            fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], i_blocklengths[0]);
+        if (ints[2] != i_blocklengths[1])
+            fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], i_blocklengths[1]);
+        if (ints[3] != i_blocklengths[2])
+            fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], i_blocklengths[2]);
+        if (ints[4] != i_displacements[0])
+            fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], i_displacements[0]);
+        if (ints[5] != i_displacements[1])
+            fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], i_displacements[1]);
+        if (ints[6] != i_displacements[2])
+            fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], i_displacements[2]);
     }
 
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     inner_vector_copy = types[0];
     free(ints);
-    if (nadds) free(adds);
+    if (nadds)
+        free(adds);
     free(types);
 
     /* decode inner vector */
-    err = MPI_Type_get_envelope(inner_vector_copy,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
+    err = MPI_Type_get_envelope(inner_vector_copy, &nints, &nadds, &ntypes, &combiner);
     if (err != MPI_SUCCESS) {
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs+1;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs + 1;
     }
 
-    if (nints != 3) errs++;
-    if (nadds != 0) errs++;
-    if (ntypes != 1) errs++;
-    if (combiner != MPI_COMBINER_VECTOR) errs++;
+    if (nints != 3)
+        errs++;
+    if (nadds != 0)
+        errs++;
+    if (ntypes != 1)
+        errs++;
+    if (combiner != MPI_COMBINER_VECTOR)
+        errs++;
 
     if (verbose) {
-       if (nints != 3) fprintf(stderr, 
-                               "inner vector nints = %d; should be 3\n",
-                               nints);
-       if (nadds != 0) fprintf(stderr, 
-                               "inner vector nadds = %d; should be 0\n",
-                               nadds);
-       if (ntypes != 1) fprintf(stderr, 
-                                "inner vector ntypes = %d; should be 1\n",
-                                ntypes);
-       if (combiner != MPI_COMBINER_VECTOR)
-           fprintf(stderr, "inner vector combiner = %s; should be vector\n",
-                   combiner_to_string(combiner));
+        if (nints != 3)
+            fprintf(stderr, "inner vector nints = %d; should be 3\n", nints);
+        if (nadds != 0)
+            fprintf(stderr, "inner vector nadds = %d; should be 0\n", nadds);
+        if (ntypes != 1)
+            fprintf(stderr, "inner vector ntypes = %d; should be 1\n", ntypes);
+        if (combiner != MPI_COMBINER_VECTOR)
+            fprintf(stderr, "inner vector combiner = %s; should be vector\n",
+                    combiner_to_string(combiner));
     }
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     ints = malloc(nints * sizeof(*ints));
-    if (nadds) adds = malloc(nadds * sizeof(*adds));
+    if (nadds)
+        adds = malloc(nadds * sizeof(*adds));
     types = malloc(ntypes * sizeof(*types));
 
-    err = MPI_Type_get_contents(inner_vector_copy,
-                               nints,
-                               nadds,
-                               ntypes,
-                               ints,
-                               adds,
-                               types);
+    err = MPI_Type_get_contents(inner_vector_copy, nints, nadds, ntypes, ints, adds, types);
 
-    if (ints[0] != 2) errs++;
-    if (ints[1] != 1) errs++;
-    if (ints[2] != 2) errs++;
+    if (ints[0] != 2)
+        errs++;
+    if (ints[1] != 1)
+        errs++;
+    if (ints[2] != 2)
+        errs++;
 
     if (verbose) {
-       if (ints[0] != 2) fprintf(stderr, 
-                                 "inner vector count = %d; should be 2\n",
-                                 ints[0]);
-       if (ints[1] != 1) fprintf(stderr,
-                                 "inner vector blocklength = %d; should be 1\n",
-                                 ints[1]);
-       if (ints[2] != 2) fprintf(stderr, 
-                                 "inner vector stride = %d; should be 2\n",
-                                 ints[2]);
+        if (ints[0] != 2)
+            fprintf(stderr, "inner vector count = %d; should be 2\n", ints[0]);
+        if (ints[1] != 1)
+            fprintf(stderr, "inner vector blocklength = %d; should be 1\n", ints[1]);
+        if (ints[2] != 2)
+            fprintf(stderr, "inner vector stride = %d; should be 2\n", ints[2]);
     }
     if (errs) {
-       if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
-       return errs;
+        if (verbose)
+            fprintf(stderr, "aborting after %d errors\n", errs);
+        return errs;
     }
 
     free(ints);
-    if (nadds) free(adds);
+    if (nadds)
+        free(adds);
     free(types);
 
-    MPI_Type_free( &inner_vector_copy );
-    MPI_Type_free( &inner_vector );
-    MPI_Type_free( &outer_indexed );
+    MPI_Type_free(&inner_vector_copy);
+    MPI_Type_free(&inner_vector);
+    MPI_Type_free(&outer_indexed);
 
     return 0;
 }
@@ -713,84 +680,86 @@ int struct_of_basics_test(void)
     int err, errs = 0;
 
     /* set up type */
-    err = MPI_Type_create_struct(s_count,
-                                s_blocklengths,
-                                s_displacements,
-                                s_types,
-                                &parent_type);
+    err = MPI_Type_create_struct(s_count, s_blocklengths, s_displacements, s_types, &parent_type);
 
     /* decode */
-    err = MPI_Type_get_envelope(parent_type,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
+    err = MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
 
-    if (nints != 4) errs++;
-    if (nadds != 3) errs++;
-    if (ntypes != 3) errs++;
-    if (combiner != MPI_COMBINER_STRUCT) errs++;
+    if (nints != 4)
+        errs++;
+    if (nadds != 3)
+        errs++;
+    if (ntypes != 3)
+        errs++;
+    if (combiner != MPI_COMBINER_STRUCT)
+        errs++;
 
     if (verbose) {
-        if (nints != 4) fprintf(stderr, "nints = %d; should be 3\n", nints);
-       if (nadds != 3) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
-       if (ntypes != 3) fprintf(stderr, "ntypes = %d; should be 3\n", ntypes);
-       if (combiner != MPI_COMBINER_STRUCT)
-           fprintf(stderr, "combiner = %s; should be struct\n",
-                   combiner_to_string(combiner));
+        if (nints != 4)
+            fprintf(stderr, "nints = %d; should be 3\n", nints);
+        if (nadds != 3)
+            fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+        if (ntypes != 3)
+            fprintf(stderr, "ntypes = %d; should be 3\n", ntypes);
+        if (combiner != MPI_COMBINER_STRUCT)
+            fprintf(stderr, "combiner = %s; should be struct\n", combiner_to_string(combiner));
     }
 
     ints = malloc(nints * sizeof(*ints));
     adds = malloc(nadds * sizeof(*adds));
-    types = malloc(ntypes *sizeof(*types));
-
-    err = MPI_Type_get_contents(parent_type,
-                               nints,
-                               nadds,
-                               ntypes,
-                               ints,
-                               adds,
-                               types);
-
-    if (ints[0] != s_count) errs++;
-    if (ints[1] != s_blocklengths[0]) errs++;
-    if (ints[2] != s_blocklengths[1]) errs++;
-    if (ints[3] != s_blocklengths[2]) errs++;
-    if (adds[0] != s_displacements[0]) errs++;
-    if (adds[1] != s_displacements[1]) errs++;
-    if (adds[2] != s_displacements[2]) errs++;
-    if (types[0] != s_types[0]) errs++;
-    if (types[1] != s_types[1]) errs++;
-    if (types[2] != s_types[2]) errs++;
+    types = malloc(ntypes * sizeof(*types));
+
+    err = MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
+
+    if (ints[0] != s_count)
+        errs++;
+    if (ints[1] != s_blocklengths[0])
+        errs++;
+    if (ints[2] != s_blocklengths[1])
+        errs++;
+    if (ints[3] != s_blocklengths[2])
+        errs++;
+    if (adds[0] != s_displacements[0])
+        errs++;
+    if (adds[1] != s_displacements[1])
+        errs++;
+    if (adds[2] != s_displacements[2])
+        errs++;
+    if (types[0] != s_types[0])
+        errs++;
+    if (types[1] != s_types[1])
+        errs++;
+    if (types[2] != s_types[2])
+        errs++;
 
     if (verbose) {
-       if (ints[0] != s_count) 
-           fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
-       if (ints[1] != s_blocklengths[0])
-           fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
-       if (ints[2] != s_blocklengths[1]) 
-           fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
-       if (ints[3] != s_blocklengths[2]) 
-           fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
-       if (adds[0] != s_displacements[0]) 
-           fprintf(stderr, "displacement[0] = %d; should be %d\n", adds[0], s_displacements[0]);
-       if (adds[1] != s_displacements[1]) 
-           fprintf(stderr, "displacement[1] = %d; should be %d\n", adds[1], s_displacements[1]);
-       if (adds[2] != s_displacements[2]) 
-           fprintf(stderr, "displacement[2] = %d; should be %d\n", adds[2], s_displacements[2]);
-       if (types[0] != s_types[0]) 
-           fprintf(stderr, "type[0] does not match\n");
-       if (types[1] != s_types[1]) 
-           fprintf(stderr, "type[1] does not match\n");
-       if (types[2] != s_types[2]) 
-           fprintf(stderr, "type[2] does not match\n");
+        if (ints[0] != s_count)
+            fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
+        if (ints[1] != s_blocklengths[0])
+            fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
+        if (ints[2] != s_blocklengths[1])
+            fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
+        if (ints[3] != s_blocklengths[2])
+            fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
+        if (adds[0] != s_displacements[0])
+            fprintf(stderr, "displacement[0] = %d; should be %d\n", adds[0], s_displacements[0]);
+        if (adds[1] != s_displacements[1])
+            fprintf(stderr, "displacement[1] = %d; should be %d\n", adds[1], s_displacements[1]);
+        if (adds[2] != s_displacements[2])
+            fprintf(stderr, "displacement[2] = %d; should be %d\n", adds[2], s_displacements[2]);
+        if (types[0] != s_types[0])
+            fprintf(stderr, "type[0] does not match\n");
+        if (types[1] != s_types[1])
+            fprintf(stderr, "type[1] does not match\n");
+        if (types[2] != s_types[2])
+            fprintf(stderr, "type[2] does not match\n");
     }
 
     free(ints);
     free(adds);
     free(types);
 
-    MPI_Type_free( &parent_type );
+    MPI_Type_free(&parent_type);
 
     return errs;
 }
@@ -802,48 +771,66 @@ int struct_of_basics_test(void)
  */
 char *combiner_to_string(int combiner)
 {
-    static char c_named[]    = "named";
-    static char c_contig[]   = "contig";
-    static char c_vector[]   = "vector";
-    static char c_hvector[]  = "hvector";
-    static char c_indexed[]  = "indexed";
+    static char c_named[] = "named";
+    static char c_contig[] = "contig";
+    static char c_vector[] = "vector";
+    static char c_hvector[] = "hvector";
+    static char c_indexed[] = "indexed";
     static char c_hindexed[] = "hindexed";
-    static char c_struct[]   = "struct";
+    static char c_struct[] = "struct";
 #ifdef HAVE_MPI2_COMBINERS
-    static char c_dup[]              = "dup";
-    static char c_hvector_integer[]  = "hvector_integer";
+    static char c_dup[] = "dup";
+    static char c_hvector_integer[] = "hvector_integer";
     static char c_hindexed_integer[] = "hindexed_integer";
-    static char c_indexed_block[]    = "indexed_block";
-    static char c_struct_integer[]   = "struct_integer";
-    static char c_subarray[]         = "subarray";
-    static char c_darray[]           = "darray";
-    static char c_f90_real[]         = "f90_real";
-    static char c_f90_complex[]      = "f90_complex";
-    static char c_f90_integer[]      = "f90_integer";
-    static char c_resized[]          = "resized";
+    static char c_indexed_block[] = "indexed_block";
+    static char c_struct_integer[] = "struct_integer";
+    static char c_subarray[] = "subarray";
+    static char c_darray[] = "darray";
+    static char c_f90_real[] = "f90_real";
+    static char c_f90_complex[] = "f90_complex";
+    static char c_f90_integer[] = "f90_integer";
+    static char c_resized[] = "resized";
 #endif
 
-    if (combiner == MPI_COMBINER_NAMED)      return c_named;
-    if (combiner == MPI_COMBINER_CONTIGUOUS) return c_contig;
-    if (combiner == MPI_COMBINER_VECTOR)     return c_vector;
-    if (combiner == MPI_COMBINER_HVECTOR)    return c_hvector;
-    if (combiner == MPI_COMBINER_INDEXED)    return c_indexed;
-    if (combiner == MPI_COMBINER_HINDEXED)   return c_hindexed;
-    if (combiner == MPI_COMBINER_STRUCT)     return c_struct;
+    if (combiner == MPI_COMBINER_NAMED)
+        return c_named;
+    if (combiner == MPI_COMBINER_CONTIGUOUS)
+        return c_contig;
+    if (combiner == MPI_COMBINER_VECTOR)
+        return c_vector;
+    if (combiner == MPI_COMBINER_HVECTOR)
+        return c_hvector;
+    if (combiner == MPI_COMBINER_INDEXED)
+        return c_indexed;
+    if (combiner == MPI_COMBINER_HINDEXED)
+        return c_hindexed;
+    if (combiner == MPI_COMBINER_STRUCT)
+        return c_struct;
 #ifdef HAVE_MPI2_COMBINERS
-    if (combiner == MPI_COMBINER_DUP)              return c_dup;
-    if (combiner == MPI_COMBINER_HVECTOR_INTEGER)  return c_hvector_integer;
-    if (combiner == MPI_COMBINER_HINDEXED_INTEGER) return c_hindexed_integer;
-    if (combiner == MPI_COMBINER_INDEXED_BLOCK)    return c_indexed_block;
-    if (combiner == MPI_COMBINER_STRUCT_INTEGER)   return c_struct_integer;
-    if (combiner == MPI_COMBINER_SUBARRAY)         return c_subarray;
-    if (combiner == MPI_COMBINER_DARRAY)           return c_darray;
-    if (combiner == MPI_COMBINER_F90_REAL)         return c_f90_real;
-    if (combiner == MPI_COMBINER_F90_COMPLEX)      return c_f90_complex;
-    if (combiner == MPI_COMBINER_F90_INTEGER)      return c_f90_integer;
-    if (combiner == MPI_COMBINER_RESIZED)          return c_resized;
+    if (combiner == MPI_COMBINER_DUP)
+        return c_dup;
+    if (combiner == MPI_COMBINER_HVECTOR_INTEGER)
+        return c_hvector_integer;
+    if (combiner == MPI_COMBINER_HINDEXED_INTEGER)
+        return c_hindexed_integer;
+    if (combiner == MPI_COMBINER_INDEXED_BLOCK)
+        return c_indexed_block;
+    if (combiner == MPI_COMBINER_STRUCT_INTEGER)
+        return c_struct_integer;
+    if (combiner == MPI_COMBINER_SUBARRAY)
+        return c_subarray;
+    if (combiner == MPI_COMBINER_DARRAY)
+        return c_darray;
+    if (combiner == MPI_COMBINER_F90_REAL)
+        return c_f90_real;
+    if (combiner == MPI_COMBINER_F90_COMPLEX)
+        return c_f90_complex;
+    if (combiner == MPI_COMBINER_F90_INTEGER)
+        return c_f90_integer;
+    if (combiner == MPI_COMBINER_RESIZED)
+        return c_resized;
 #endif
-    
+
     return NULL;
 }
 
@@ -852,16 +839,14 @@ int parse_args(int argc, char **argv)
 #ifdef HAVE_GET_OPT
     int ret;
 
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
+    while ((ret = getopt(argc, argv, "v")) >= 0) {
+        switch (ret) {
+        case 'v':
+            verbose = 1;
+            break;
+        }
     }
 #else
 #endif
     return 0;
 }
-
index 6236173..a6b9cd9 100644 (file)
@@ -23,25 +23,25 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = contig_test();
-    if (err && verbose) fprintf(stderr, "%d errors in contig test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in contig test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -63,52 +63,45 @@ int contig_test(void)
     int size;
     MPI_Aint extent;
 
-    err = MPI_Type_contiguous(count,
-                            MPI_INT,
-                            &newtype);
+    err = MPI_Type_contiguous(count, MPI_INT, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating type in contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating type in contig_test()\n");
+        }
+        errs++;
     }
 
     err = MPI_Type_size(newtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in contig_test()\n");
+        }
+        errs++;
     }
-    
+
     if (size != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != 0 in contig_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: size != 0 in contig_test()\n");
+        }
+        errs++;
+    }
 
     err = MPI_Type_extent(newtype, &extent);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type extent in contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type extent in contig_test()\n");
+        }
+        errs++;
     }
-    
+
     if (extent != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: extent != 0 in contig_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: extent != 0 in contig_test()\n");
+        }
+        errs++;
+    }
 
-    MPI_Type_free( &newtype );
+    MPI_Type_free(&newtype);
 
     return errs;
 }
@@ -117,19 +110,18 @@ int contig_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index 657c8e0..2081559 100644 (file)
  * avoid any struct->contig optimizations.
  */
 
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
-    int           blocklens[8], psize, i, rank;
-    MPI_Aint      displs[8];
-    MPI_Datatype  oldtypes[8];
-    MPI_Datatype  ntype1, ntype2;
-
-    MPI_Init( &argc, &argv );
-    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-    
-    for (i=0; i<8; i++) {
-       blocklens[i] = 1;
-       displs[i]    = (7-i) * sizeof(long);
-       oldtypes[i]  = MPI_LONG;
+    int blocklens[8], psize, i, rank;
+    MPI_Aint displs[8];
+    MPI_Datatype oldtypes[8];
+    MPI_Datatype ntype1, ntype2;
+
+    MPI_Init(&argc, &argv);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+    for (i = 0; i < 8; i++) {
+        blocklens[i] = 1;
+        displs[i] = (7 - i) * sizeof(long);
+        oldtypes[i] = MPI_LONG;
     }
-    MPI_Type_struct( 8, blocklens, displs, oldtypes, &ntype1 );
-    MPI_Type_contiguous( 65536, ntype1, &ntype2 );
-    MPI_Type_commit( &ntype2 );
+    MPI_Type_struct(8, blocklens, displs, oldtypes, &ntype1);
+    MPI_Type_contiguous(65536, ntype1, &ntype2);
+    MPI_Type_commit(&ntype2);
 
-    MPI_Pack_size( 2, ntype2, MPI_COMM_WORLD, &psize );
+    MPI_Pack_size(2, ntype2, MPI_COMM_WORLD, &psize);
 
-    MPI_Type_free( &ntype2 );
-       MPI_Type_free( &ntype1 );
+    MPI_Type_free(&ntype2);
+    MPI_Type_free(&ntype1);
 
     /* The only failure mode has been SEGV or aborts within the datatype
-       routines */
+     * routines */
     if (rank == 0) {
-       printf( " No Errors\n" );
+        printf(" No Errors\n");
     }
 
     MPI_Finalize();
index 9de2c59..8e1e1b2 100644 (file)
 #include <stdlib.h>
 #include "mpitest.h"
 
-int AllocateGrid( int nx, int ny, int **srcArray, int **destArray );
-int PackUnpack( MPI_Datatype, const int [], int[], int );
+int AllocateGrid(int nx, int ny, int **srcArray, int **destArray);
+int PackUnpack(MPI_Datatype, const int[], int[], int);
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     int wrank, wsize;
     int gsizes[3], distribs[3], dargs[3], psizes[3];
     int px, py, nx, ny, rx, ry, bx, by;
-    int *srcArray=NULL, *destArray=NULL;
+    int *srcArray, *destArray;
     int i, j, ii, jj, loc;
     MPI_Datatype darraytype;
 
-    MTest_Init( 0, 0 );
-    MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
-    MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+    MTest_Init(0, 0);
+    MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+    MPI_Comm_size(MPI_COMM_WORLD, &wsize);
 
     /* Test 1: Simple, 1-D cyclic decomposition */
-    if (AllocateGrid( 1, 3*wsize, &srcArray, &destArray ) ) {
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+    if (AllocateGrid(1, 3 * wsize, &srcArray, &destArray)) {
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
     /* Simple cyclic with 1-dim global array */
-    gsizes[0]   = 3*wsize;
+    gsizes[0] = 3 * wsize;
     distribs[0] = MPI_DISTRIBUTE_CYCLIC;
-    dargs[0]    = 1;
-    psizes[0]   = wsize;
-    MPI_Type_create_darray( wsize, wrank, 1, 
-                           gsizes, distribs, dargs, psizes, 
-                           MPI_ORDER_C, MPI_INT, &darraytype );
+    dargs[0] = 1;
+    psizes[0] = wsize;
+    MPI_Type_create_darray(wsize, wrank, 1,
+                           gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
 
     /* Check the created datatype.  Because cyclic, should represent
-       a strided type */
-    if (PackUnpack( darraytype, srcArray, destArray, 3 )) {
-       fprintf( stderr, "Error in pack/unpack check\n" );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+     * a strided type */
+    if (PackUnpack(darraytype, srcArray, destArray, 3)) {
+        fprintf(stderr, "Error in pack/unpack check\n");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
     /* Now, check for correct data */
-    for (i=0; i<3; i++) {
-       if (destArray[i] != wrank + i * wsize) {
-           fprintf( stderr, "1D: %d: Expected %d but saw %d\n", 
-                    i, wrank + i * wsize, destArray[i] );
-           errs++;
-       }
+    for (i = 0; i < 3; i++) {
+        if (destArray[i] != wrank + i * wsize) {
+            fprintf(stderr, "1D: %d: Expected %d but saw %d\n", i, wrank + i * wsize, destArray[i]);
+            errs++;
+        }
     }
 
-    free( destArray );
-    free( srcArray );
-    MPI_Type_free( &darraytype );
+    free(destArray);
+    free(srcArray);
+    MPI_Type_free(&darraytype);
 
     /* Test 2: Simple, 1-D cyclic decomposition, with block size=2 */
-    if (AllocateGrid( 1, 4*wsize, &srcArray, &destArray ) ) {
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+    if (AllocateGrid(1, 4 * wsize, &srcArray, &destArray)) {
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
     /* Simple cyclic with 1-dim global array */
-    gsizes[0]   = 4*wsize;
+    gsizes[0] = 4 * wsize;
     distribs[0] = MPI_DISTRIBUTE_CYCLIC;
-    dargs[0]    = 2;
-    psizes[0]   = wsize;
-    MPI_Type_create_darray( wsize, wrank, 1, 
-                           gsizes, distribs, dargs, psizes, 
-                           MPI_ORDER_C, MPI_INT, &darraytype );
+    dargs[0] = 2;
+    psizes[0] = wsize;
+    MPI_Type_create_darray(wsize, wrank, 1,
+                           gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
 
     /* Check the created datatype.  Because cyclic, should represent
-       a strided type */
-    if (PackUnpack( darraytype, srcArray, destArray, 4 )) {
-       fprintf( stderr, "Error in pack/unpack check\n" );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+     * a strided type */
+    if (PackUnpack(darraytype, srcArray, destArray, 4)) {
+        fprintf(stderr, "Error in pack/unpack check\n");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
     loc = 0;
     /* for each cyclic element */
-    for (i=0; i<2; i++) {
-       /* For each element in block */
-       for (j=0; j<2; j++) {
-           if (destArray[loc] != 2*wrank + i * 2*wsize + j) {
-               fprintf( stderr, "1D(2): %d: Expected %d but saw %d\n", 
-                        i, 2*wrank + i * 2*wsize+j, destArray[loc] );
-               errs++;
-           }
-           loc++;
-       }
-    }
-
-    free( destArray );
-    free( srcArray );
-    MPI_Type_free( &darraytype );
+    for (i = 0; i < 2; i++) {
+        /* For each element in block */
+        for (j = 0; j < 2; j++) {
+            if (destArray[loc] != 2 * wrank + i * 2 * wsize + j) {
+                fprintf(stderr, "1D(2): %d: Expected %d but saw %d\n",
+                        i, 2 * wrank + i * 2 * wsize + j, destArray[loc]);
+                errs++;
+            }
+            loc++;
+        }
+    }
+
+    free(destArray);
+    free(srcArray);
+    MPI_Type_free(&darraytype);
 
     /* 2D: Create some 2-D decompositions */
-    px = wsize/2;
+    px = wsize / 2;
     py = 2;
     rx = wrank % px;
     ry = wrank / px;
 
     if (px * py != wsize) {
-       fprintf( stderr, "An even number of processes is required\n" );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+        fprintf(stderr, "An even number of processes is required\n");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
     /* Cyclic/Cyclic */
-    if (AllocateGrid( 5*px, 7*py, &srcArray, &destArray )) {
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+    if (AllocateGrid(5 * px, 7 * py, &srcArray, &destArray)) {
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
-    /* Simple cyclic/cyclic. Note in C order, the [1] index varies most 
-       rapidly */
-    gsizes[0]   = ny = 7*py;
-    gsizes[1]   = nx = 5*px;
+    /* Simple cyclic/cyclic. Note in C order, the [1] index varies most
+     * rapidly */
+    gsizes[0] = ny = 7 * py;
+    gsizes[1] = nx = 5 * px;
     distribs[0] = MPI_DISTRIBUTE_CYCLIC;
     distribs[1] = MPI_DISTRIBUTE_CYCLIC;
-    dargs[0]    = 1;
-    dargs[1]    = 1;
-    psizes[0]   = py;
-    psizes[1]   = px;
-    MPI_Type_create_darray( wsize, wrank, 2, 
-                           gsizes, distribs, dargs, psizes, 
-                           MPI_ORDER_C, MPI_INT, &darraytype );
+    dargs[0] = 1;
+    dargs[1] = 1;
+    psizes[0] = py;
+    psizes[1] = px;
+    MPI_Type_create_darray(wsize, wrank, 2,
+                           gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
 
     /* Check the created datatype.  Because cyclic, should represent
-       a strided type */
-    if (PackUnpack( darraytype, srcArray, destArray, 5*7 )) {
-       fprintf( stderr, "Error in pack/unpack check\n" );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+     * a strided type */
+    if (PackUnpack(darraytype, srcArray, destArray, 5 * 7)) {
+        fprintf(stderr, "Error in pack/unpack check\n");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
     loc = 0;
-    for (j=0; j<7; j++) {
-       for (i=0; i<5; i++) {
-           int expected = rx + ry * nx + i * px + j * nx * py;
-           if (destArray[loc] != expected) {
-               errs++;
-               fprintf( stderr, "2D(cc): [%d,%d] = %d, expected %d\n", 
-                        i, j, destArray[loc], expected );
-           }
-           loc++;
-       }
-    }
-
-    free( srcArray );
-    free( destArray );
-    MPI_Type_free( &darraytype );
+    for (j = 0; j < 7; j++) {
+        for (i = 0; i < 5; i++) {
+            int expected = rx + ry * nx + i * px + j * nx * py;
+            if (destArray[loc] != expected) {
+                errs++;
+                fprintf(stderr, "2D(cc): [%d,%d] = %d, expected %d\n",
+                        i, j, destArray[loc], expected);
+            }
+            loc++;
+        }
+    }
+
+    free(srcArray);
+    free(destArray);
+    MPI_Type_free(&darraytype);
 
     /* Cyclic(2)/Cyclic(3) */
-    if (AllocateGrid( 6*px, 4*py, &srcArray, &destArray )) {
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+    if (AllocateGrid(6 * px, 4 * py, &srcArray, &destArray)) {
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
-    /* Block cyclic/cyclic. Note in C order, the [1] index varies most 
-       rapidly */
-    gsizes[0]   = ny = 4*py;
-    gsizes[1]   = nx = 6*px;
+    /* Block cyclic/cyclic. Note in C order, the [1] index varies most
+     * rapidly */
+    gsizes[0] = ny = 4 * py;
+    gsizes[1] = nx = 6 * px;
     distribs[0] = MPI_DISTRIBUTE_CYCLIC;
     distribs[1] = MPI_DISTRIBUTE_CYCLIC;
-    dargs[0]    = by = 2;
-    dargs[1]    = bx = 3;
-    psizes[0]   = py;
-    psizes[1]   = px;
-    MPI_Type_create_darray( wsize, wrank, 2, 
-                           gsizes, distribs, dargs, psizes, 
-                           MPI_ORDER_C, MPI_INT, &darraytype );
+    dargs[0] = by = 2;
+    dargs[1] = bx = 3;
+    psizes[0] = py;
+    psizes[1] = px;
+    MPI_Type_create_darray(wsize, wrank, 2,
+                           gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
 
     /* Check the created datatype.  Because cyclic, should represent
-       a strided type */
-    if (PackUnpack( darraytype, srcArray, destArray, 4*6 )) {
-       fprintf( stderr, "Error in pack/unpack check\n" );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+     * a strided type */
+    if (PackUnpack(darraytype, srcArray, destArray, 4 * 6)) {
+        fprintf(stderr, "Error in pack/unpack check\n");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
     loc = 0;
-    for (j=0; j<4/by; j++) {
-       for (jj=0; jj<by; jj++) {
-           for (i=0; i<6/bx; i++) {
-               for (ii=0; ii<bx; ii++) {
-                   int expected = rx * bx + ry * by * nx + i * bx * px + ii +
-                       (j * by * py + jj) * nx;
-                   if (destArray[loc] != expected) {
-                       errs++;
-                   fprintf( stderr, "2D(c(2)c(3)): [%d,%d] = %d, expected %d\n", 
-                            i*bx+ii, j*by+jj, destArray[loc], expected );
-                   }
-                   loc++;
-               }
-           }
-       }
-    }
-
-    free( srcArray );
-    free( destArray );
-    MPI_Type_free( &darraytype );
-
-    MTest_Finalize( errs );
+    for (j = 0; j < 4 / by; j++) {
+        for (jj = 0; jj < by; jj++) {
+            for (i = 0; i < 6 / bx; i++) {
+                for (ii = 0; ii < bx; ii++) {
+                    int expected = rx * bx + ry * by * nx + i * bx * px + ii +
+                        (j * by * py + jj) * nx;
+                    if (destArray[loc] != expected) {
+                        errs++;
+                        fprintf(stderr, "2D(c(2)c(3)): [%d,%d] = %d, expected %d\n",
+                                i * bx + ii, j * by + jj, destArray[loc], expected);
+                    }
+                    loc++;
+                }
+            }
+        }
+    }
+
+    free(srcArray);
+    free(destArray);
+    MPI_Type_free(&darraytype);
+
+    MTest_Finalize(errs);
     MPI_Finalize();
-    
+
     return 0;
 }
 
-int AllocateGrid( int nx, int ny, int **srcArray, int **destArray )
+int AllocateGrid(int nx, int ny, int **srcArray, int **destArray)
 {
     int *src, *dest;
-    int i;
-    src = (int *)malloc( nx*ny*sizeof(int) );
-    dest = (int *)malloc( nx*ny*sizeof(int) );
+    int i, j;
+    src = (int *) malloc(nx * ny * sizeof(int));
+    dest = (int *) malloc(nx * ny * sizeof(int));
     if (!src || !dest) {
-       fprintf( stderr, "Unable to allocate test arrays of size (%d x %d)\n",
-                nx, ny );
-       return 1;
+        fprintf(stderr, "Unable to allocate test arrays of size (%d x %d)\n", nx, ny);
+        return 1;
     }
-    for (i=0; i<nx*ny; i++) {
-       src[i] = i;
-       dest[i] = -i-1;
+    for (i = 0; i < nx * ny; i++) {
+        src[i] = i;
+        dest[i] = -i - 1;
     }
-    *srcArray  = src;
+    *srcArray = src;
     *destArray = dest;
     return 0;
 }
 
 /* Extract the source array into the dest array using the DARRAY datatype.
    "count" integers are returned in destArray */
-int PackUnpack( MPI_Datatype darraytype, const int srcArray[], int destArray[],
-               int count )
+int PackUnpack(MPI_Datatype darraytype, const int srcArray[], int destArray[], int count)
 {
     int packsize, position;
     int *packArray;
 
-    MPI_Type_commit( &darraytype );
-    MPI_Pack_size( 1, darraytype, MPI_COMM_SELF, &packsize );
-    packArray = (int *)malloc( packsize );
+    MPI_Type_commit(&darraytype);
+    MPI_Pack_size(1, darraytype, MPI_COMM_SELF, &packsize);
+    packArray = (int *) malloc(packsize);
     if (!packArray) {
-       fprintf( stderr, "Unable to allocate pack array of size %d\n", 
-                packsize );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+        fprintf(stderr, "Unable to allocate pack array of size %d\n", packsize);
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
     position = 0;
-    MPI_Pack( (int*)srcArray, 1, darraytype, packArray, packsize, &position, 
-             MPI_COMM_SELF );
+    MPI_Pack((int *) srcArray, 1, darraytype, packArray, packsize, &position, MPI_COMM_SELF);
     packsize = position;
     position = 0;
-    MPI_Unpack( packArray, packsize, &position, destArray, count, MPI_INT, 
-               MPI_COMM_SELF );
-    free( packArray );
+    MPI_Unpack(packArray, packsize, &position, destArray, count, MPI_INT, MPI_COMM_SELF);
+    free(packArray);
     return 0;
 }
index e2104e7..25b37fb 100644 (file)
@@ -9,7 +9,7 @@
 #include <string.h>
 #include "mpitest.h"
 
-/* 
+/*
    The default behavior of the test routines should be to briefly indicate
    the cause of any errors - in this test, that means that verbose needs
    to be set. Verbose should turn on output that is independent of error
@@ -23,39 +23,36 @@ int darray_4d_c_test1(void);
 
 /* helper functions */
 static int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
 
 int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = darray_2d_c_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 2d darray c test 1.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 2d darray c test 1.\n", err);
     errs += err;
 
     err = darray_4d_c_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 4d darray c test 1.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 4d darray c test 1.\n", err);
     errs += err;
 
     /* print message and exit */
     /* Allow the use of more than one process - some MPI implementations
-       (including IBM's) check that the number of processes given to 
-       Type_create_darray is no larger than MPI_COMM_WORLD */
+     * (including IBM's) check that the number of processes given to
+     * Type_create_darray is no larger than MPI_COMM_WORLD */
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
@@ -71,69 +68,65 @@ int main(int argc, char **argv)
 int darray_2d_c_test1(void)
 {
     MPI_Datatype darray;
-    int array[9]; /* initialized below */
-    int array_size[2] = {3, 3};
-    int array_distrib[2] = {MPI_DISTRIBUTE_BLOCK, MPI_DISTRIBUTE_BLOCK};
-    int array_dargs[2] = {MPI_DISTRIBUTE_DFLT_DARG, MPI_DISTRIBUTE_DFLT_DARG};
-    int array_psizes[2] = {3, 3};
+    int array[9];               /* initialized below */
+    int array_size[2] = { 3, 3 };
+    int array_distrib[2] = { MPI_DISTRIBUTE_BLOCK, MPI_DISTRIBUTE_BLOCK };
+    int array_dargs[2] = { MPI_DISTRIBUTE_DFLT_DARG, MPI_DISTRIBUTE_DFLT_DARG };
+    int array_psizes[2] = { 3, 3 };
 
     int i, rank, err, errs = 0, sizeoftype;
 
     /* pretend we are each rank, one at a time */
-    for (rank=0; rank < 9; rank++) {
-       /* set up buffer */
-       for (i=0; i < 9; i++) {
-           array[i] = i;
-       }
-
-       /* set up type */
-       err = MPI_Type_create_darray(9, /* size */
-                                    rank,
-                                    2, /* dims */
-                                    array_size,
-                                    array_distrib,
-                                    array_dargs,
-                                    array_psizes,
-                                    MPI_ORDER_C,
-                                    MPI_INT,
-                                    &darray);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr,
-                       "error in MPI_Type_create_darray call; aborting after %d errors\n",
-                       errs);
-           }
-           MTestPrintError( err );
-           return errs;
-       }
-       
-       MPI_Type_commit(&darray);
-
-       MPI_Type_size(darray, &sizeoftype);
-       if (sizeoftype != sizeof(int)) {
-           errs++;
-           if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                                sizeoftype, (int) sizeof(int));
-           return errs;
-       }
-       
-       err = pack_and_unpack((char *) array, 1, darray, 9*sizeof(int));
-       
-       for (i=0; i < 9; i++) {
-
-           if ((i == rank) && (array[i] != rank)) {
-               errs++;
-               if (verbose) fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
-                                    rank, i, array[i], rank);
-           }
-           else if ((i != rank) && (array[i] != 0)) {
-               errs++;
-               if (verbose) fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
-                                    rank, i, array[i], 0);
-           }
-       }
-       MPI_Type_free(&darray);
+    for (rank = 0; rank < 9; rank++) {
+        /* set up buffer */
+        for (i = 0; i < 9; i++) {
+            array[i] = i;
+        }
+
+        /* set up type */
+        err = MPI_Type_create_darray(9, /* size */
+                                     rank, 2,   /* dims */
+                                     array_size,
+                                     array_distrib,
+                                     array_dargs, array_psizes, MPI_ORDER_C, MPI_INT, &darray);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr,
+                        "error in MPI_Type_create_darray call; aborting after %d errors\n", errs);
+            }
+            MTestPrintError(err);
+            return errs;
+        }
+
+        MPI_Type_commit(&darray);
+
+        MPI_Type_size(darray, &sizeoftype);
+        if (sizeoftype != sizeof(int)) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "size of type = %d; should be %d\n", sizeoftype, (int) sizeof(int));
+            return errs;
+        }
+
+        err = pack_and_unpack((char *) array, 1, darray, 9 * sizeof(int));
+
+        for (i = 0; i < 9; i++) {
+
+            if ((i == rank) && (array[i] != rank)) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
+                            rank, i, array[i], rank);
+            }
+            else if ((i != rank) && (array[i] != 0)) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
+                            rank, i, array[i], 0);
+            }
+        }
+        MPI_Type_free(&darray);
     }
 
     return errs;
@@ -147,85 +140,85 @@ int darray_4d_c_test1(void)
 {
     MPI_Datatype darray;
     int array[72];
-    int array_size[4] = {6, 3, 2, 2};
+    int array_size[4] = { 6, 3, 2, 2 };
     int array_distrib[4] = { MPI_DISTRIBUTE_BLOCK,
-                            MPI_DISTRIBUTE_BLOCK,
-                            MPI_DISTRIBUTE_NONE,
-                            MPI_DISTRIBUTE_NONE };
+        MPI_DISTRIBUTE_BLOCK,
+        MPI_DISTRIBUTE_NONE,
+        MPI_DISTRIBUTE_NONE
+    };
     int array_dargs[4] = { MPI_DISTRIBUTE_DFLT_DARG,
-                          MPI_DISTRIBUTE_DFLT_DARG,
-                          MPI_DISTRIBUTE_DFLT_DARG,
-                          MPI_DISTRIBUTE_DFLT_DARG };
-    int array_psizes[4] = {6, 3, 1, 1};
+        MPI_DISTRIBUTE_DFLT_DARG,
+        MPI_DISTRIBUTE_DFLT_DARG,
+        MPI_DISTRIBUTE_DFLT_DARG
+    };
+    int array_psizes[4] = { 6, 3, 1, 1 };
 
     int i, rank, err, errs = 0, sizeoftype;
 
-    for (rank=0; rank < 18; rank++) {
-       /* set up array */
-       for (i=0; i < 72; i++) {
-           array[i] = i;
-       }
-
-       /* set up type */
-       err = MPI_Type_create_darray(18, /* size */
-                                    rank,
-                                    4, /* dims */
-                                    array_size,
-                                    array_distrib,
-                                    array_dargs,
-                                    array_psizes,
-                                    MPI_ORDER_C,
-                                    MPI_INT,
-                                    &darray);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr,
-                       "error in MPI_Type_create_darray call; aborting after %d errors\n",
-                       errs);
-           }
-           MTestPrintError( err );
-           return errs;
-       }
-
-       MPI_Type_commit(&darray);
-
-       /* verify the size of the type */
-       MPI_Type_size(darray, &sizeoftype);
-       if (sizeoftype != 4*sizeof(int)) {
-           errs++;
-           if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                                sizeoftype, (int) (4*sizeof(int)));
-           return errs;
-       }
-
-       /* pack and unpack the type, zero'ing out all other values */
-       err = pack_and_unpack((char *) array, 1, darray, 72*sizeof(int));
-
-       for (i=0; i < 4*rank; i++) {
-           if (array[i] != 0) {
-               errs++;
-               if (verbose) fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
-                                    rank, i, array[i], 0);
-           }
-       }
-
-       for (i=4*rank; i < 4*rank + 4; i++) {
-           if (array[i] != i) {
-               errs++;
-               if (verbose) fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
-                                    rank, i, array[i], i);
-           }
-       }
-       for (i=4*rank+4; i < 72; i++) {
-           if (array[i] != 0) {
-               errs++;
-               if (verbose) fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
-                                    rank, i, array[i], 0);
-           }
-       }
-
-       MPI_Type_free(&darray);
+    for (rank = 0; rank < 18; rank++) {
+        /* set up array */
+        for (i = 0; i < 72; i++) {
+            array[i] = i;
+        }
+
+        /* set up type */
+        err = MPI_Type_create_darray(18,        /* size */
+                                     rank, 4,   /* dims */
+                                     array_size,
+                                     array_distrib,
+                                     array_dargs, array_psizes, MPI_ORDER_C, MPI_INT, &darray);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr,
+                        "error in MPI_Type_create_darray call; aborting after %d errors\n", errs);
+            }
+            MTestPrintError(err);
+            return errs;
+        }
+
+        MPI_Type_commit(&darray);
+
+        /* verify the size of the type */
+        MPI_Type_size(darray, &sizeoftype);
+        if (sizeoftype != 4 * sizeof(int)) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "size of type = %d; should be %d\n",
+                        sizeoftype, (int) (4 * sizeof(int)));
+            return errs;
+        }
+
+        /* pack and unpack the type, zero'ing out all other values */
+        err = pack_and_unpack((char *) array, 1, darray, 72 * sizeof(int));
+
+        for (i = 0; i < 4 * rank; i++) {
+            if (array[i] != 0) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
+                            rank, i, array[i], 0);
+            }
+        }
+
+        for (i = 4 * rank; i < 4 * rank + 4; i++) {
+            if (array[i] != i) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
+                            rank, i, array[i], i);
+            }
+        }
+        for (i = 4 * rank + 4; i < 72; i++) {
+            if (array[i] != 0) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
+                            rank, i, array[i], 0);
+            }
+        }
+
+        MPI_Type_free(&darray);
     }
     return errs;
 }
@@ -247,93 +240,70 @@ int darray_4d_c_test1(void)
  *             between the pack and unpack steps
  *
  */
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
 {
     char *packbuf;
     int err, errs = 0, pack_size, type_size, position;
 
     err = MPI_Type_size(datatype, &type_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_size call; aborting after %d errors\n",
-                   errs);
-       }
-       MTestPrintError( err );
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+        }
+        MTestPrintError(err);
+        return errs;
     }
 
     type_size *= count;
 
     err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Pack_size call; aborting after %d errors\n",
-                   errs);
-       }
-       MTestPrintError( err );
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+        }
+        MTestPrintError(err);
+        return errs;
     }
     packbuf = (char *) malloc(pack_size);
     if (packbuf == NULL) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in malloc call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     /* FIXME: the pack size returned need not be the type_size - this will
-       only be true if the pack routine simply moves the bytes but does
-       no other transformations of the data */
+     * only be true if the pack routine simply moves the bytes but does
+     * no other transformations of the data */
     position = 0;
-    err = MPI_Pack(typebuf,
-                  count,
-                  datatype,
-                  packbuf,
-                  type_size,
-                  &position,
-                  MPI_COMM_SELF);
+    err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
     }
 
     memset(typebuf, 0, typebufsz);
     position = 0;
-    err = MPI_Unpack(packbuf,
-                    type_size,
-                    &position,
-                    typebuf,
-                    count,
-                    datatype,
-                    MPI_COMM_SELF);
+    err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Unpack call; aborting after %d errors\n",
-                   errs);
-       }
-       MTestPrintError( err );
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+        }
+        MTestPrintError(err);
+        return errs;
     }
     free(packbuf);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
     }
 
     return errs;
@@ -342,18 +312,18 @@ static int pack_and_unpack(char *typebuf,
 static int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index b152c80..9539b95 100644 (file)
@@ -9,97 +9,96 @@
 #include <ctype.h>
 #include "mpitest.h"
 
-int main( int argc, char *argv[])
+int main(int argc, char *argv[])
 {
-       struct a {      int     i;
-                       char    c;
-               } s[10], s1[10];
-       int j;
-       int errs = 0;
-       int rank, size, tsize;
-       MPI_Aint text;
-       int blens[2];
-       MPI_Aint disps[2];
-       MPI_Datatype bases[2];
-       MPI_Datatype str, con;
-       MPI_Status status;
+    struct a {
+        int i;
+        char c;
+    } s[10], s1[10];
+    int j;
+    int errs = 0;
+    int rank, size, tsize;
+    MPI_Aint text;
+    int blens[2];
+    MPI_Aint disps[2];
+    MPI_Datatype bases[2];
+    MPI_Datatype str, con;
+    MPI_Status status;
 
-       MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
-       MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-       MPI_Comm_size( MPI_COMM_WORLD, &size );
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
 
-       for( j = 0; j < 10; j ++ ) {
-               s[j].i = j + rank;
-               s[j].c = j + rank + 'a';
-       }
+    for (j = 0; j < 10; j++) {
+        s[j].i = j + rank;
+        s[j].c = j + rank + 'a';
+    }
 
-       blens[0] = blens[1] = 1;
-       disps[0] = 0; disps[1] = sizeof(int);
-       bases[0] = MPI_INT; bases[1] = MPI_CHAR;
-       MPI_Type_struct( 2, blens, disps, bases, &str );
-       MPI_Type_commit( &str );
-       MPI_Type_contiguous( 10, str, &con );
-       MPI_Type_commit( &con );
-       MPI_Type_size( con, &tsize );
-       MPI_Type_extent( con, &text );
+    blens[0] = blens[1] = 1;
+    disps[0] = 0;
+    disps[1] = sizeof(int);
+    bases[0] = MPI_INT;
+    bases[1] = MPI_CHAR;
+    MPI_Type_struct(2, blens, disps, bases, &str);
+    MPI_Type_commit(&str);
+    MPI_Type_contiguous(10, str, &con);
+    MPI_Type_commit(&con);
+    MPI_Type_size(con, &tsize);
+    MPI_Type_extent(con, &text);
 
-       MTestPrintfMsg( 0, "Size of MPI array is %d, extent is %d\n",
-                       tsize, text );
+    MTestPrintfMsg(0, "Size of MPI array is %d, extent is %d\n", tsize, text);
 
-       /* The following block of code is only for verbose-level output */
-        {
-       void * p1, *p2;
-       p1 = s;
-       p2 = &(s[10].i);  /* This statement may fail on some systems */
-       MTestPrintfMsg( 0,
-               "C array starts at %p and ends at %p for a length of %d\n",
-               s, &(s[9].c), (char *)p2-(char *)p1 );
-        }
+    /* The following block of code is only for verbose-level output */
+    {
+        void *p1, *p2;
+        p1 = s;
+        p2 = &(s[10].i);        /* This statement may fail on some systems */
+        MTestPrintfMsg(0,
+                       "C array starts at %p and ends at %p for a length of %d\n",
+                       s, &(s[9].c), (char *) p2 - (char *) p1);
+    }
 
-       MPI_Type_extent( str, &text );
-       MPI_Type_size( str, &tsize );
-       MTestPrintfMsg( 0, "Size of MPI struct is %d, extent is %d\n",
-                       tsize, (int)text );
-       MTestPrintfMsg( 0, "Size of C struct is %d\n", sizeof(struct a) );
-       if (text != sizeof(struct a)) {
-           fprintf( stderr,
-                    "Extent of struct a (%d) does not match sizeof (%d)\n",
-                    (int)text, (int)sizeof(struct a) );
-           errs++;
-       }
+    MPI_Type_extent(str, &text);
+    MPI_Type_size(str, &tsize);
+    MTestPrintfMsg(0, "Size of MPI struct is %d, extent is %d\n", tsize, (int) text);
+    MTestPrintfMsg(0, "Size of C struct is %d\n", sizeof(struct a));
+    if (text != sizeof(struct a)) {
+        fprintf(stderr,
+                "Extent of struct a (%d) does not match sizeof (%d)\n",
+                (int) text, (int) sizeof(struct a));
+        errs++;
+    }
 
-       MPI_Send( s, 1, con, rank ^ 1, 0, MPI_COMM_WORLD );
-       MPI_Recv( s1, 1, con, rank ^ 1, 0, MPI_COMM_WORLD, &status );
+    MPI_Send(s, 1, con, rank ^ 1, 0, MPI_COMM_WORLD);
+    MPI_Recv(s1, 1, con, rank ^ 1, 0, MPI_COMM_WORLD, &status);
 
-       for( j = 0; j < 10; j++ ) {
-           MTestPrintfMsg( 0, "%d Sent: %d %c, Got: %d %c\n", rank,
-                           s[j].i, s[j].c, s1[j].i, s1[j].c );
-           if ( s1[j].i != j + status.MPI_SOURCE ) {
-               errs++;
-               fprintf( stderr, "Got s[%d].i = %d; expected %d\n", j, s1[j].i,
-                       j + status.MPI_SOURCE );
-           }
-           if ( s1[j].c != 'a' + j + status.MPI_SOURCE ) {
-               errs++;
-               /* If the character is not a printing character,
-                  this can generate a file that diff, for example,
-                  believes is a binary file */
-               if (isprint( (int)(s1[j].c) )) {
-                   fprintf( stderr, "Got s[%d].c = %c; expected %c\n",
-                            j, s1[j].c, j + status.MPI_SOURCE + 'a');
-               }
-               else {
-                   fprintf( stderr, "Got s[%d].c = %x; expected %c\n",
-                            j, (int)s1[j].c, j + status.MPI_SOURCE + 'a');
-               }
-           }
-       }
+    for (j = 0; j < 10; j++) {
+        MTestPrintfMsg(0, "%d Sent: %d %c, Got: %d %c\n", rank, s[j].i, s[j].c, s1[j].i, s1[j].c);
+        if (s1[j].i != j + status.MPI_SOURCE) {
+            errs++;
+            fprintf(stderr, "Got s[%d].i = %d; expected %d\n", j, s1[j].i, j + status.MPI_SOURCE);
+        }
+        if (s1[j].c != 'a' + j + status.MPI_SOURCE) {
+            errs++;
+            /* If the character is not a printing character,
+             * this can generate a file that diff, for example,
+             * believes is a binary file */
+            if (isprint((int) (s1[j].c))) {
+                fprintf(stderr, "Got s[%d].c = %c; expected %c\n",
+                        j, s1[j].c, j + status.MPI_SOURCE + 'a');
+            }
+            else {
+                fprintf(stderr, "Got s[%d].c = %x; expected %c\n",
+                        j, (int) s1[j].c, j + status.MPI_SOURCE + 'a');
+            }
+        }
+    }
 
-       MPI_Type_free( &str );
-       MPI_Type_free( &con );
+    MPI_Type_free(&str);
+    MPI_Type_free(&con);
 
-       MTest_Finalize( errs );
-       MPI_Finalize();
-       return 0;
+    MTest_Finalize(errs);
+    MPI_Finalize();
+    return 0;
 }
index dfd91fc..31edc75 100644 (file)
 static char MTEST_Descrip[] = "";
 */
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     int buf[10];
     MPI_Aint a1, a2;
 
-    MTest_Init( &argc, &argv );
-    
-    MPI_Get_address( &buf[0], &a1 );
-    MPI_Get_address( &buf[1], &a2 );
-    
-    if ((int)(a2-a1) != sizeof(int)) {
-       errs++;
-       printf( "Get address of two address did not return values the correct distance apart\n" );
+    MTest_Init(&argc, &argv);
+
+    MPI_Get_address(&buf[0], &a1);
+    MPI_Get_address(&buf[1], &a2);
+
+    if ((int) (a2 - a1) != sizeof(int)) {
+        errs++;
+        printf("Get address of two address did not return values the correct distance apart\n");
     }
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
index d813b2a..5f44fee 100644 (file)
@@ -20,25 +20,25 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = double_int_test();
-    if (err && verbose) fprintf(stderr, "%d errors in double_int test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in double_int test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -52,8 +52,17 @@ int double_int_test(void)
 {
     int err, errs = 0, count;
 
-    struct { double a; int b; double c; } foo;
-    struct { double a; int b; double c; int d; } bar;
+    struct {
+        double a;
+        int b;
+        double c;
+    } foo;
+    struct {
+        double a;
+        int b;
+        double c;
+        int d;
+    } bar;
 
     int blks[3] = { 1, 1, 1 };
     MPI_Aint disps[3] = { 0, 0, 0 };
@@ -65,35 +74,33 @@ int double_int_test(void)
     /* fill in disps[1..2] with appropriate offset */
     disps[1] = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
     disps[2] = (MPI_Aint) ((char *) &foo.c - (char *) &foo.a);
-   
+
     MPI_Type_create_struct(3, blks, disps, types, &stype);
     MPI_Type_commit(&stype);
 
     err = MPI_Sendrecv((const void *) &foo, 1, stype, 0, 0,
-                      (void *) &bar, 2, MPI_DOUBLE_INT, 0, 0,
-                      MPI_COMM_SELF, &recvstatus);
+                       (void *) &bar, 2, MPI_DOUBLE_INT, 0, 0, MPI_COMM_SELF, &recvstatus);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "MPI_Sendrecv returned error (%d)\n",
-                            err);
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "MPI_Sendrecv returned error (%d)\n", err);
+        return errs;
     }
 
     err = MPI_Get_elements(&recvstatus, MPI_DOUBLE_INT, &count);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "MPI_Get_elements returned error (%d)\n",
-                            err);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "MPI_Get_elements returned error (%d)\n", err);
     }
 
     if (count != 3) {
-       errs++;
-       if (verbose) fprintf(stderr,
-                            "MPI_Get_elements returned count of %d, should be 3\n",
-                            count);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "MPI_Get_elements returned count of %d, should be 3\n", count);
     }
 
-    MPI_Type_free( &stype );
+    MPI_Type_free(&stype);
 
     return errs;
 }
@@ -101,6 +108,6 @@ int double_int_test(void)
 int parse_args(int argc, char **argv)
 {
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 2809a3d..add7289 100644 (file)
@@ -36,15 +36,15 @@ int main(int argc, char **argv)
      * (B) a type that has an odd number of ints in its "type contents" (1 in
      *     this case)
      * This triggers a specific bug in some versions of MPICH. */
-    blens[0]  = 1;
+    blens[0] = 1;
     displs[0] = offsetof(struct test_struct, a);
-    types[0]  = MPI_CHAR;
-    blens[1]  = 1;
+    types[0] = MPI_CHAR;
+    blens[1] = 1;
     displs[1] = offsetof(struct test_struct, b);
-    types[1]  = MPI_SHORT;
-    blens[2]  = 1;
+    types[1] = MPI_SHORT;
+    blens[2] = 1;
     displs[2] = offsetof(struct test_struct, c);
-    types[2]  = MPI_INT;
+    types[2] = MPI_INT;
     MPI_Type_create_struct(3, blens, displs, types, &struct_type);
     MPI_Type_contiguous(1, struct_type, &contig);
     MPI_Type_commit(&struct_type);
@@ -58,9 +58,7 @@ int main(int argc, char **argv)
     recvbuf.c = -1;
 
     /* send to ourself */
-    MPI_Sendrecv(&sendbuf, 1, contig, 0, 0,
-                 &recvbuf, 1, contig, 0, 0,
-                 MPI_COMM_SELF, &status);
+    MPI_Sendrecv(&sendbuf, 1, contig, 0, 0, &recvbuf, 1, contig, 0, 0, MPI_COMM_SELF, &status);
 
     /* sanity */
     assert(sendbuf.a == recvbuf.a);
@@ -86,4 +84,3 @@ int main(int argc, char **argv)
     MPI_Finalize();
     return 0;
 }
-
diff --git a/teshsuite/smpi/mpich3-test/datatype/get-struct.c b/teshsuite/smpi/mpich3-test/datatype/get-struct.c
deleted file mode 100644 (file)
index 8970008..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
- *  (C) 2014 by Argonne National Laboratory.
- *      See COPYRIGHT in top-level directory.
- */
-#include "mpi.h"
-#include "mpitest.h"
-#include <stdio.h>
-#include <string.h>
-
-/* Communicating a datatype built out of structs
- * This test was motivated by the failure of an example program for
- * RMA involving simple operations on a struct that included a struct
- *
- * The observed failure was a SEGV in the MPI_Get
- *
- * 
- */
-#define MAX_KEY_SIZE 64
-#define MAX_VALUE_SIZE 256
-typedef struct {
-    MPI_Aint disp;
-    int      rank;
-    void     *lptr;
-} Rptr;
-typedef struct {
-    Rptr     next;
-    char     key[MAX_KEY_SIZE], value[MAX_VALUE_SIZE];
-} ListElm;
-Rptr nullDptr = {0,-1,0};
-
-int testCases = -1;
-#define BYTE_ONLY 0x1
-#define TWO_STRUCT 0x2
-int isOneLevel = 0;
-
-int main(int argc, char **argv)
-{
-    int  errors=0;
-    Rptr         headDptr;
-    ListElm      *headLptr=0;
-    int          i, wrank;
-    MPI_Datatype dptrType, listelmType;
-    MPI_Win      listwin;
-
-    MTest_Init(&argc, &argv);
-    MPI_Comm_rank(MPI_COMM_WORLD,&wrank);
-
-    for (i=1; i<argc; i++) {
-        if (strcmp(argv[i], "-byteonly") == 0) {
-            testCases = BYTE_ONLY;
-        }
-        else if (strcmp(argv[i], "-twostruct") == 0) {
-            testCases = TWO_STRUCT;
-        }
-        else if (strcmp(argv[i], "-onelevel") == 0) {
-            isOneLevel = 1;
-        }
-        else {
-            printf("Unrecognized argument %s\n", argv[i] );
-        }
-    }
-
-    /* Create the datatypes that we will use to move the data */
-    {
-       int      blens[3];
-       MPI_Aint displ[3];
-       MPI_Datatype dtypes[3];
-       ListElm  sampleElm;
-
-       blens[0] = 1; blens[1] = 1;
-       MPI_Get_address( &nullDptr.disp, &displ[0] );
-       MPI_Get_address( &nullDptr.rank, &displ[1] );
-       displ[1] = displ[1] - displ[0];
-       displ[0] = 0;
-       dtypes[0] = MPI_AINT;
-       dtypes[1] = MPI_INT;
-       MPI_Type_create_struct(2, blens, displ, dtypes, &dptrType);
-       MPI_Type_commit(&dptrType);
-
-        if (isOneLevel) {
-            blens[0]  = sizeof(nullDptr); dtypes[0] = MPI_BYTE;
-        }
-        else {
-            blens[0] = 1;                 dtypes[0] = dptrType;
-        }
-       blens[1] = MAX_KEY_SIZE;   dtypes[1] = MPI_CHAR;
-       blens[2] = MAX_VALUE_SIZE; dtypes[2] = MPI_CHAR;
-       MPI_Get_address(&sampleElm.next,&displ[0]);
-       MPI_Get_address(&sampleElm.key[0],&displ[1]);
-       MPI_Get_address(&sampleElm.value[0],&displ[2]);
-       displ[2] -= displ[0];
-       displ[1] -= displ[0];
-       displ[0] = 0;
-        for (i=0; i<3; i++) {
-            MTestPrintfMsg(0,"%d:count=%d,disp=%ld\n",i, blens[i], displ[i]);
-        }
-       MPI_Type_create_struct(3, blens, displ, dtypes, &listelmType);
-       MPI_Type_commit(&listelmType);
-    }
-
-    MPI_Win_create_dynamic(MPI_INFO_NULL, MPI_COMM_WORLD, &listwin);
-
-    headDptr.rank = 0;
-    if (wrank == 0) {
-       /* Create 1 list element (the head) and initialize it */
-       MPI_Alloc_mem(sizeof(ListElm), MPI_INFO_NULL, &headLptr);
-       MPI_Get_address(headLptr, &headDptr.disp);
-       headLptr->next.rank = -1;
-       headLptr->next.disp = (MPI_Aint)MPI_BOTTOM;
-       headLptr->next.lptr = 0;
-       strncpy(headLptr->key,"key1",MAX_KEY_SIZE);
-       strncpy(headLptr->value,"value1",MAX_VALUE_SIZE);
-       MPI_Win_attach(listwin, headLptr, sizeof(ListElm));
-    }
-    MPI_Bcast(&headDptr.disp, 1, MPI_AINT, 0, MPI_COMM_WORLD);
-
-    MPI_Barrier(MPI_COMM_WORLD);
-
-    if (wrank == 1) {
-       ListElm headcopy;
-
-       MPI_Win_lock_all(0, listwin);
-       /* Get head element with simple get of BYTES */
-        if (testCases & BYTE_ONLY) {
-            headcopy.next.rank=100;
-            headcopy.next.disp=0xefefefef;
-            MPI_Get(&headcopy, sizeof(ListElm), MPI_BYTE,
-                    headDptr.rank, headDptr.disp,
-                    sizeof(ListElm), MPI_BYTE, listwin);
-            MPI_Win_flush(headDptr.rank, listwin);
-            if (headcopy.next.rank != -1 &&
-                headcopy.next.disp != (MPI_Aint)MPI_BOTTOM) {
-                errors++;
-                printf("MPI_BYTE: headcopy contains incorrect next:<%d,%ld>\n",
-                       headcopy.next.rank, (long)headcopy.next.disp);
-            }
-        }
-
-        if (testCases & TWO_STRUCT) {
-            headcopy.next.rank=100;
-            headcopy.next.disp=0xefefefef;
-            /* Get head element using struct of struct type.  This is
-               not an identical get to the simple BYTE one above but should
-               work */
-            MPI_Get(&headcopy, 1, listelmType, headDptr.rank, headDptr.disp,
-                    1, listelmType, listwin);
-            MPI_Win_flush(headDptr.rank, listwin);
-            if (headcopy.next.rank != -1 &&
-                headcopy.next.disp != (MPI_Aint)MPI_BOTTOM) {
-                errors++;
-                printf("ListelmType: headcopy contains incorrect next:<%d,%ld>\n",
-                       headcopy.next.rank, (long)headcopy.next.disp);
-            }
-        }
-
-       MPI_Win_unlock_all(listwin);
-    }
-    MPI_Barrier(MPI_COMM_WORLD);
-    if (wrank == 0) {
-       MPI_Win_detach(listwin,headLptr);
-       MPI_Free_mem(headLptr);
-    }
-    MPI_Win_free(&listwin);
-    MPI_Type_free(&dptrType);
-    MPI_Type_free(&listelmType);
-
-    MTest_Finalize( errors );
-    MPI_Finalize();
-    return MTestReturnValue( errors );
-}
index 9fe778f..b2205c5 100644 (file)
@@ -6,6 +6,7 @@
  */
 #include "mpi.h"
 #include <stdio.h>
+#include <string.h>
 #include "mpitest.h"
 
 /*
@@ -13,112 +14,109 @@ static char MTest_descrip[] = "Receive partial datatypes and check that\
 MPI_Getelements gives the correct version";
 */
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     MPI_Datatype outtype, oldtypes[2];
-    MPI_Aint     offsets[2];
-    int          blklens[2];
-    MPI_Comm     comm;
-    int          size, rank, src, dest, tag;
+    MPI_Aint offsets[2];
+    int blklens[2];
+    MPI_Comm comm;
+    int size, rank, src, dest, tag;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     comm = MPI_COMM_WORLD;
 
-    MPI_Comm_rank( comm, &rank );
-    MPI_Comm_size( comm, &size );
-    
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &size);
+
     if (size < 2) {
-       errs++;
-       printf( "This test requires at least 2 processes\n" );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+        errs++;
+        printf("This test requires at least 2 processes\n");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
-    
-    src  = 0;
+
+    src = 0;
     dest = 1;
 
     if (rank == src) {
-       int buf[128], position, cnt;
-       /* sender */
-
-       /* Create a datatype and send it (multiple of sizeof(int)) */
-       /* Create a send struct type */
-       oldtypes[0] = MPI_INT;
-       oldtypes[1] = MPI_CHAR;
-       blklens[0]  = 1;
-       blklens[1]  = 4*sizeof(int);
-       offsets[0]  = 0;
-       offsets[1]  = sizeof(int);
-       MPI_Type_struct( 2, blklens, offsets, oldtypes, &outtype );
-       MPI_Type_commit( &outtype );
-
-       buf[0] = 4*sizeof(int);
-       /* printf( "About to send to %d\n", dest ); */
-       MPI_Send( buf, 1, outtype, dest, 0, comm );
-       MPI_Type_free( &outtype );
-
-       /* Create a datatype and send it (not a multiple of sizeof(int)) */
-       /* Create a send struct type */
-       oldtypes[0] = MPI_INT;
-       oldtypes[1] = MPI_CHAR;
-       blklens[0]  = 1;
-       blklens[1]  = 4*sizeof(int)+1;
-       offsets[0]  = 0;
-       offsets[1]  = sizeof(int);
-       MPI_Type_struct( 2, blklens, offsets, oldtypes, &outtype );
-       MPI_Type_commit( &outtype );
-
-       buf[0] = 4*sizeof(int) + 1;
-       MPI_Send( buf, 1, outtype, dest, 1, comm );
-       MPI_Type_free( &outtype );
-
-       /* Pack data and send as packed */
-       position = 0;
-       cnt = 7;
-       MPI_Pack( &cnt, 1, MPI_INT, 
-                 buf, 128*sizeof(int), &position, comm );
-       MPI_Pack( (void*)"message", 7, MPI_CHAR,
-                 buf, 128*sizeof(int), &position, comm );
-       MPI_Send( buf, position, MPI_PACKED, dest, 2, comm );
+        int buf[128], position, cnt;
+        MTEST_VG_MEM_INIT(buf, 128 * sizeof(buf[0]));
+        /* sender */
+
+        /* Create a datatype and send it (multiple of sizeof(int)) */
+        /* Create a send struct type */
+        oldtypes[0] = MPI_INT;
+        oldtypes[1] = MPI_CHAR;
+        blklens[0] = 1;
+        blklens[1] = 4 * sizeof(int);
+        offsets[0] = 0;
+        offsets[1] = sizeof(int);
+        MPI_Type_struct(2, blklens, offsets, oldtypes, &outtype);
+        MPI_Type_commit(&outtype);
+
+        buf[0] = 4 * sizeof(int);
+        /* printf("About to send to %d\n", dest); */
+        MPI_Send(buf, 1, outtype, dest, 0, comm);
+        MPI_Type_free(&outtype);
+
+        /* Create a datatype and send it (not a multiple of sizeof(int)) */
+        /* Create a send struct type */
+        oldtypes[0] = MPI_INT;
+        oldtypes[1] = MPI_CHAR;
+        blklens[0] = 1;
+        blklens[1] = 4 * sizeof(int) + 1;
+        offsets[0] = 0;
+        offsets[1] = sizeof(int);
+        MPI_Type_struct(2, blklens, offsets, oldtypes, &outtype);
+        MPI_Type_commit(&outtype);
+
+        buf[0] = 4 * sizeof(int) + 1;
+        MPI_Send(buf, 1, outtype, dest, 1, comm);
+        MPI_Type_free(&outtype);
+
+        /* Pack data and send as packed */
+        position = 0;
+        cnt = 7;
+        MPI_Pack(&cnt, 1, MPI_INT, buf, 128 * sizeof(int), &position, comm);
+        MPI_Pack((void *) "message", 7, MPI_CHAR, buf, 128 * sizeof(int), &position, comm);
+        MPI_Send(buf, position, MPI_PACKED, dest, 2, comm);
     }
     else if (rank == dest) {
-       MPI_Status status;
-       int        buf[128], i, elms, count;
-
-       /* Receiver */
-       /* Create a receive struct type */
-       oldtypes[0] = MPI_INT;
-       oldtypes[1] = MPI_CHAR;
-       blklens[0]  = 1;
-       blklens[1]  = 256;
-       offsets[0]  = 0;
-       offsets[1]  = sizeof(int);
-       MPI_Type_struct( 2, blklens, offsets, oldtypes, &outtype );
-       MPI_Type_commit( &outtype );
-
-       for (i=0; i<3; i++) {
-           tag = i;
-           /* printf( "about to receive tag %d from %d\n", i, src ); */
-           MPI_Recv( buf, 1, outtype, src, tag, comm, &status );
-           MPI_Get_elements( &status, outtype, &elms );
-           if (elms != buf[0] + 1) {
-               errs++;
-               printf( "For test %d, Get elements gave %d but should be %d\n",
-                       i, elms, buf[0] + 1 );
-           }
-           MPI_Get_count( &status, outtype, &count );
-           if (count != MPI_UNDEFINED) {
-               errs++;
-               printf( "For partial send, Get_count did not return MPI_UNDEFINED\n" );
-           }
-       }
-       MPI_Type_free( &outtype );
+        MPI_Status status;
+        int buf[128], i, elms, count;
+
+        /* Receiver */
+        /* Create a receive struct type */
+        oldtypes[0] = MPI_INT;
+        oldtypes[1] = MPI_CHAR;
+        blklens[0] = 1;
+        blklens[1] = 256;
+        offsets[0] = 0;
+        offsets[1] = sizeof(int);
+        MPI_Type_struct(2, blklens, offsets, oldtypes, &outtype);
+        MPI_Type_commit(&outtype);
+
+        for (i = 0; i < 3; i++) {
+            tag = i;
+            /* printf("about to receive tag %d from %d\n", i, src); */
+            MPI_Recv(buf, 1, outtype, src, tag, comm, &status);
+            MPI_Get_elements(&status, outtype, &elms);
+            if (elms != buf[0] + 1) {
+                errs++;
+                printf("For test %d, Get elements gave %d but should be %d\n", i, elms, buf[0] + 1);
+            }
+            MPI_Get_count(&status, outtype, &count);
+            if (count != MPI_UNDEFINED) {
+                errs++;
+                printf("For partial send, Get_count did not return MPI_UNDEFINED\n");
+            }
+        }
+        MPI_Type_free(&outtype);
     }
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
-  
+
 }
index db9d165..90a4cd0 100644 (file)
 
 static int verbose = 0;
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 int hindexed_zerotype_test(void);
 int hindexed_sparsetype_test(void);
 
 struct test_struct_1 {
-    int a,b,c,d;
+    int a, b, c, d;
 };
 
 int main(int argc, char *argv[])
@@ -28,23 +29,25 @@ int main(int argc, char *argv[])
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     err = hindexed_zerotype_test();
-    if (verbose && err) fprintf(stderr, "error in hindexed_zerotype_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in hindexed_zerotype_test\n");
     errs += err;
 
     err = hindexed_sparsetype_test();
-    if (verbose && err) fprintf(stderr, "error in hindexed_sparsetype_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in hindexed_sparsetype_test\n");
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -59,73 +62,73 @@ int hindexed_zerotype_test(void)
     MPI_Request request;
     MPI_Status status;
 
-    int blks[]       = { 0, 0, 0 };
+    int blks[] = { 0, 0, 0 };
     MPI_Aint disps[] = { 0, 4, 16 };
 
     err = MPI_Type_hindexed(3, blks, disps, MPI_INT, &mytype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_hindexed returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_hindexed returned error\n");
+        }
     }
 
     MPI_Type_commit(&mytype);
 
     err = MPI_Irecv(NULL, 2, mytype, 0, 0, MPI_COMM_SELF, &request);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Irecv returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Irecv returned error\n");
+        }
     }
 
     err = MPI_Send(NULL, 1, mytype, 0, 0, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Send returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Send returned error\n");
+        }
     }
 
     err = MPI_Wait(&request, &status);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Wait returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Wait returned error\n");
+        }
     }
 
     /* verify count and elements */
     err = MPI_Get_count(&status, mytype, &count);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Get_count returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Get_count returned error\n");
+        }
     }
     if (count != 0) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "count = %d; should be 0\n", count);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "count = %d; should be 0\n", count);
+        }
     }
 
     err = MPI_Get_elements(&status, mytype, &elements);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Get_elements returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Get_elements returned error\n");
+        }
     }
     if (elements != 0) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "elements = %d; should be 0\n", elements);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "elements = %d; should be 0\n", elements);
+        }
     }
 
-   // MPI_Type_free(&mytype);
+    MPI_Type_free(&mytype);
 
     return errs;
 }
@@ -142,92 +145,92 @@ int hindexed_sparsetype_test(void)
     MPI_Request request;
     MPI_Status status;
 
-    int sendbuf[6]   = { 1, 2, 3, 4, 5, 6 };
+    int sendbuf[6] = { 1, 2, 3, 4, 5, 6 };
     int recvbuf[16];
     int correct[16] = { 1, -2, 4, -4, 2, 3, 5, -8, -9, -10, 6,
-                       -12, -13, -14, -15, -16 };
+        -12, -13, -14, -15, -16
+    };
 
-    int blks[]       = { 1, 0,             2,             1 };
-    MPI_Aint disps[] = { 0, 1*sizeof(int), 4*sizeof(int), 2*sizeof(int) };
+    int blks[] = { 1, 0, 2, 1 };
+    MPI_Aint disps[] = { 0, 1 * sizeof(int), 4 * sizeof(int), 2 * sizeof(int) };
 
     err = MPI_Type_hindexed(4, blks, disps, MPI_INT, &mytype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_hindexed returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_hindexed returned error\n");
+        }
     }
 
     MPI_Type_commit(&mytype);
 
-    for (i=0; i < 16; i++) recvbuf[i] = -(i+1);
+    for (i = 0; i < 16; i++)
+        recvbuf[i] = -(i + 1);
 
     err = MPI_Irecv(recvbuf, 2, mytype, 0, 0, MPI_COMM_SELF, &request);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Irecv returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Irecv returned error\n");
+        }
     }
 
     err = MPI_Send(sendbuf, 6, MPI_INT, 0, 0, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Send returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Send returned error\n");
+        }
     }
 
     err = MPI_Wait(&request, &status);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Wait returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Wait returned error\n");
+        }
     }
+
     /* verify data */
-    for (i=0; i < 16; i++) {
-       if (recvbuf[i] != correct[i]) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "recvbuf[%d] = %d; should be %d\n",
-                       i, recvbuf[i], correct[i]);
-           }
-       }
+    for (i = 0; i < 16; i++) {
+        if (recvbuf[i] != correct[i]) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "recvbuf[%d] = %d; should be %d\n", i, recvbuf[i], correct[i]);
+            }
+        }
     }
 
     /* verify count and elements */
     err = MPI_Get_count(&status, mytype, &count);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Get_count returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Get_count returned error\n");
+        }
     }
     if (count != MPI_UNDEFINED) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n",
-                   count, MPI_UNDEFINED);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n", count, MPI_UNDEFINED);
+        }
     }
 
     err = MPI_Get_elements(&status, mytype, &elements);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Get_elements returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Get_elements returned error\n");
+        }
     }
     if (elements != 6) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "elements = %d; should be 6\n", elements);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "elements = %d; should be 6\n", elements);
+        }
     }
 
-//    MPI_Type_free(&mytype);
+    MPI_Type_free(&mytype);
 
     return errs;
 }
@@ -236,18 +239,18 @@ int hindexed_sparsetype_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 23f8f62..5f00009 100644 (file)
@@ -15,9 +15,7 @@
 #define TEST_HINDEXED_BLOCK 1
 #endif
 
-#if defined(TEST_HINDEXED_BLOCK)
 static int verbose = 0;
-#endif
 
 /* tests */
 int hindexed_block_contig_test(void);
@@ -29,10 +27,7 @@ static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int
 
 int main(int argc, char **argv)
 {
-#if defined(TEST_HINDEXED_BLOCK)
-    int err;
-#endif
-    int errs = 0;
+    int err, errs = 0;
     int rank;
 
     MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
@@ -54,7 +49,7 @@ int main(int argc, char **argv)
     if (err && verbose)
         fprintf(stderr, "%d errors in hindexed_block vector test.\n", err);
     errs += err;
-#endif /*defined(TEST_HINDEXED_BLOCK)*/
+#endif /*defined(TEST_HINDEXED_BLOCK) */
 
     /* print message and exit */
     if (rank == 0) {
@@ -175,19 +170,19 @@ int hindexed_block_vector_test(void)
 #define NELT (18)
     int buf[NELT] = {
         -1, -1, -1,
-         1, -2,  2,
+        1, -2, 2,
         -3, -3, -3,
         -4, -4, -4,
-         3, -5,  4,
-         5, -6,  6
+        3, -5, 4,
+        5, -6, 6
     };
     int expected[NELT] = {
-         0,  0,  0,
-         1,  0,  2,
-         0,  0,  0,
-         0,  0,  0,
-         3,  0,  4,
-         5,  0,  6
+        0, 0, 0,
+        1, 0, 2,
+        0, 0, 0,
+        0, 0, 0,
+        3, 0, 4,
+        5, 0, 6
     };
     int err, errs = 0;
 
@@ -216,8 +211,7 @@ int hindexed_block_vector_test(void)
     err = MPI_Type_create_hindexed_block(count, 1, disp, vectype, &newtype);
     if (err != MPI_SUCCESS) {
         if (verbose) {
-            fprintf(stderr,
-                    "error creating hindexed_block type in hindexed_block_contig_test()\n");
+            fprintf(stderr, "error creating hindexed_block type in hindexed_block_contig_test()\n");
         }
         errs++;
     }
@@ -349,4 +343,4 @@ int parse_args(int argc, char **argv)
         verbose = 1;
     return 0;
 }
-#endif /*defined(TEST_HINDEXED_BLOCK)*/
+#endif /*defined(TEST_HINDEXED_BLOCK) */
index e316c70..c5d0483 100644 (file)
@@ -31,15 +31,13 @@ int main(int argc, char **argv)
     MPI_Datatype t;
     int count = 4;
     int blocklength = 2;
-    MPI_Aint displacements[] = {0, 8, 16, 24};
+    MPI_Aint displacements[] = { 0, 8, 16, 24 };
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
     if (!rank) {
-        MPI_Type_create_hindexed_block(count, blocklength,
-                                        displacements, MPI_INT,
-                                        &t);
+        MPI_Type_create_hindexed_block(count, blocklength, displacements, MPI_INT, &t);
         MPI_Type_commit(&t);
         {
             int ni, na, nd, combiner;
@@ -55,7 +53,7 @@ int main(int argc, char **argv)
             check(i[1] == 2);
 
             check(na == 4);
-            for (k=0; k < na; k++)
+            for (k = 0; k < na; k++)
                 check(a[k] == (k * 8));
 
             check(nd == 1);
index d9a6aa5..2734885 100644 (file)
 /* Inspired by the Intel MPI_Type_hvector_blklen test.
    Added to include a test of a dataloop optimization that failed.
 */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     MPI_Datatype ot, ot2, newtype;
     int position, psize, insize, outsize;
-    signed char *inbuf=0, *outbuf=0, *pbuf=0, *p;
-    int  i, j, k;
-    int  errs = 0;
-    int  veccount=16, stride=16;
+    signed char *inbuf = 0, *outbuf = 0, *pbuf = 0, *p;
+    int i, j, k;
+    int errs = 0;
+    int veccount = 16, stride = 16;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
     /*
      * Create a type with some padding
      */
-    MPI_Type_contiguous( 59, MPI_CHAR, &ot );
-    MPI_Type_create_resized( ot, 0, 64, &ot2 );
+    MPI_Type_contiguous(59, MPI_CHAR, &ot);
+    MPI_Type_create_resized(ot, 0, 64, &ot2);
     /*
-      Use a vector type with a block size equal to the stride - thus
-      tiling the target memory with copies of old type.  This is not
-      a contiguous copy since oldtype has a gap at the end.
-    */
-    MPI_Type_hvector( veccount, stride, stride*64, ot2, &newtype );
-    MPI_Type_commit( &newtype );
+     * Use a vector type with a block size equal to the stride - thus
+     * tiling the target memory with copies of old type.  This is not
+     * a contiguous copy since oldtype has a gap at the end.
+     */
+    MPI_Type_hvector(veccount, stride, stride * 64, ot2, &newtype);
+    MPI_Type_commit(&newtype);
 
     insize = veccount * stride * 64;
     outsize = insize;
-    inbuf = (char *)malloc( insize );
-    outbuf = (char *)malloc( outsize );
-    for (i=0; i<outsize; i++) {
+    inbuf = (char *) malloc(insize);
+    outbuf = (char *) malloc(outsize);
+    for (i = 0; i < outsize; i++) {
         inbuf[i] = i % 64;
         outbuf[i] = -1;
     }
 
-    MPI_Pack_size( 1, newtype, MPI_COMM_WORLD, &psize );
-    pbuf = (char *)malloc( psize );
+    MPI_Pack_size(1, newtype, MPI_COMM_WORLD, &psize);
+    pbuf = (char *) malloc(psize);
 
     position = 0;
-    MPI_Pack( inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD );
-    psize    = position;
+    MPI_Pack(inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD);
+    psize = position;
     position = 0;
-    MPI_Unpack( pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD );
+    MPI_Unpack(pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD);
 
 
     /* Check the output */
     p = outbuf;
-    for (i=0; i<veccount; i++) {
-        for (j=0; j<stride; j++) {
-            for (k=0; k<59; k++) {
+    for (i = 0; i < veccount; i++) {
+        for (j = 0; j < stride; j++) {
+            for (k = 0; k < 59; k++) {
                 if (*p != k % 64) {
                     errs++;
-                    fprintf( stderr, "[%d,%d,%d]expected %d but saw %d\n",
-                             i, j, k, (k%64), *p );
+                    fprintf(stderr, "[%d,%d,%d]expected %d but saw %d\n", i, j, k, (k % 64), *p);
                 }
                 p++;
             }
-            for (k=59; k<64; k++) {
+            for (k = 59; k < 64; k++) {
                 if (*p != -1) {
                     errs++;
-                    fprintf( stderr, "[%d,%d,%d]expected -1 but saw %d\n",
-                             i, j, k, *p );
+                    fprintf(stderr, "[%d,%d,%d]expected -1 but saw %d\n", i, j, k, *p);
                 }
                 p++;
             }
         }
     }
 
-    free( pbuf );
-    free( inbuf );
-    free( outbuf );
+    free(pbuf);
+    free(inbuf);
+    free(outbuf);
 
-    MPI_Type_free( &ot );
-    MPI_Type_free( &ot2 );
-    MPI_Type_free( &newtype );
-    MTest_Finalize( errs );
+    MPI_Type_free(&ot);
+    MPI_Type_free(&ot2);
+    MPI_Type_free(&newtype);
+    MTest_Finalize(errs);
     MPI_Finalize();
 
     return 0;
index bab12d0..4f8954e 100644 (file)
@@ -45,65 +45,56 @@ int indexed_same_lengths(void);
 
 /* helper functions */
 int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
 
 int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = indexed_contig_test();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in indexed_contig_test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in indexed_contig_test.\n", err);
     errs += err;
 
     err = indexed_zeroblock_first_test();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in indexed_zeroblock_first_test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in indexed_zeroblock_first_test.\n", err);
     errs += err;
 
     err = indexed_zeroblock_middle_test();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in indexed_zeroblock_middle_test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in indexed_zeroblock_middle_test.\n", err);
     errs += err;
 
     err = indexed_zeroblock_last_test();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in indexed_zeroblock_last_test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in indexed_zeroblock_last_test.\n", err);
     errs += err;
 
     err = indexed_contig_leading_zero_test();
-    if (err && verbose) fprintf(stderr,
-                                "%d errors in indexed_contig_leading_zero_test.\n",
-                                err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in indexed_contig_leading_zero_test.\n", err);
     errs += err;
 
     err = indexed_same_lengths();
-    if (err && verbose) fprintf(stderr,
-                                "%d errors in indexed_contig_leading_zero_test.\n",
-                                err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in indexed_contig_leading_zero_test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -114,40 +105,36 @@ int indexed_zeroblock_first_test(void)
     int err, errs = 0;
 
     MPI_Datatype type;
-    int len[3]  = { 0, 1, 1 };
+    int len[3] = { 0, 1, 1 };
     int disp[3] = { 0, 1, 4 };
     MPI_Aint lb, ub;
 
     err = MPI_Type_indexed(3, len, disp, MPI_INT, &type);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating indexed type in indexed_zeroblock_first_test()\n");
-       }
-       errs += 1;
+        if (verbose) {
+            fprintf(stderr, "error creating indexed type in indexed_zeroblock_first_test()\n");
+        }
+        errs += 1;
     }
 
     MPI_Type_lb(type, &lb);
     if (lb != sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr,
-                   "lb mismatch; is %d, should be %d\n",
-                   (int) lb, (int) sizeof(int));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "lb mismatch; is %d, should be %d\n", (int) lb, (int) sizeof(int));
+        }
+        errs++;
     }
     MPI_Type_ub(type, &ub);
     if (ub != 5 * sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr,
-                   "ub mismatch; is %d, should be %d\n",
-                   (int) ub, (int) (5 * sizeof(int)));
-       }
-       errs++;
-    }
-    
-    MPI_Type_free( &type );
-    
+        if (verbose) {
+            fprintf(stderr,
+                    "ub mismatch; is %d, should be %d\n", (int) ub, (int) (5 * sizeof(int)));
+        }
+        errs++;
+    }
+
+    MPI_Type_free(&type);
+
     return errs;
 }
 
@@ -156,40 +143,36 @@ int indexed_zeroblock_middle_test(void)
     int err, errs = 0;
 
     MPI_Datatype type;
-    int len[3]  = { 1, 0, 1 };
+    int len[3] = { 1, 0, 1 };
     int disp[3] = { 1, 2, 4 };
     MPI_Aint lb, ub;
 
     err = MPI_Type_indexed(3, len, disp, MPI_INT, &type);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating indexed type in indexed_zeroblock_middle_test()\n");
-       }
-       errs += 1;
+        if (verbose) {
+            fprintf(stderr, "error creating indexed type in indexed_zeroblock_middle_test()\n");
+        }
+        errs += 1;
     }
 
     MPI_Type_lb(type, &lb);
     if (lb != sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr,
-                   "lb mismatch; is %d, should be %d\n",
-                   (int) lb, (int) sizeof(int));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "lb mismatch; is %d, should be %d\n", (int) lb, (int) sizeof(int));
+        }
+        errs++;
     }
     MPI_Type_ub(type, &ub);
     if (ub != 5 * sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr,
-                   "ub mismatch; is %d, should be %d\n",
-                   (int) ub, (int) (5 * sizeof(int)));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "ub mismatch; is %d, should be %d\n", (int) ub, (int) (5 * sizeof(int)));
+        }
+        errs++;
     }
 
-    MPI_Type_free( &type );
-    
+    MPI_Type_free(&type);
+
     return errs;
 }
 
@@ -198,40 +181,36 @@ int indexed_zeroblock_last_test(void)
     int err, errs = 0;
 
     MPI_Datatype type;
-    int len[3]  = { 1, 1, 0 };
+    int len[3] = { 1, 1, 0 };
     int disp[3] = { 1, 4, 8 };
     MPI_Aint lb, ub;
 
     err = MPI_Type_indexed(3, len, disp, MPI_INT, &type);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating indexed type in indexed_zeroblock_last_test()\n");
-       }
-       errs += 1;
+        if (verbose) {
+            fprintf(stderr, "error creating indexed type in indexed_zeroblock_last_test()\n");
+        }
+        errs += 1;
     }
 
     MPI_Type_lb(type, &lb);
     if (lb != sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr,
-                   "lb mismatch; is %d, should be %d\n",
-                   (int) lb, (int) sizeof(int));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "lb mismatch; is %d, should be %d\n", (int) lb, (int) sizeof(int));
+        }
+        errs++;
     }
     MPI_Type_ub(type, &ub);
     if (ub != 5 * sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr,
-                   "ub mismatch; is %d, should be %d\n",
-                   (int) ub, (int) (5 * sizeof(int)));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "ub mismatch; is %d, should be %d\n", (int) ub, (int) (5 * sizeof(int)));
+        }
+        errs++;
     }
 
-    MPI_Type_free( &type );
-    
+    MPI_Type_free(&type);
+
     return errs;
 }
 
@@ -244,93 +223,85 @@ int indexed_zeroblock_last_test(void)
  */
 int indexed_contig_test(void)
 {
-    int buf[9] = {-1, 1, 2, 3, -2, 4, 5, -3, 6};
+    int buf[9] = { -1, 1, 2, 3, -2, 4, 5, -3, 6 };
     int err, errs = 0;
 
     int i, count = 5;
-    int blklen[]    = { 1, 2, 1, 1, 1 };
+    int blklen[] = { 1, 2, 1, 1, 1 };
     int disp[] = { 1, 2, 5, 6, 8 };
     MPI_Datatype newtype;
 
     int size, int_size;
 
-    err = MPI_Type_indexed(count,
-                          blklen,
-                          disp,
-                          MPI_INT,
-                          &newtype);
+    err = MPI_Type_indexed(count, blklen, disp, MPI_INT, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating indexed type in indexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating indexed type in indexed_contig_test()\n");
+        }
+        errs++;
     }
 
     MPI_Type_size(MPI_INT, &int_size);
 
     err = MPI_Type_size(newtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in indexed_contig_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in indexed_contig_test()\n");
+        }
+        errs++;
     }
-    
+
     if (size != 6 * int_size) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != 6 * int_size in indexed_contig_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: size != 6 * int_size in indexed_contig_test()\n");
+        }
+        errs++;
+    }
 
     MPI_Type_commit(&newtype);
 
     err = pack_and_unpack((char *) buf, 1, newtype, 9 * sizeof(int));
     if (err != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error packing/unpacking in indexed_contig_test()\n");
-       }
-       errs += err;
-    }
-
-    for (i=0; i < 9; i++) {
-       int goodval;
-
-       switch(i) {
-           case 1:
-               goodval = 1;
-               break;
-           case 2:
-               goodval = 2;
-               break;
-           case 3:
-               goodval = 3;
-               break;
-           case 5:
-               goodval = 4;
-               break;
-           case 6:
-               goodval = 5;
-               break;
-           case 8:
-               goodval = 6;
-               break;
-           default:
-               goodval = 0; /* pack_and_unpack() zeros before unpack */
-               break;
-       }
-       if (buf[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "buf[%d] = %d; should be %d\n",
-                                i, buf[i], goodval);
-       }
-    }
-
-    MPI_Type_free( &newtype );
+        if (verbose) {
+            fprintf(stderr, "error packing/unpacking in indexed_contig_test()\n");
+        }
+        errs += err;
+    }
+
+    for (i = 0; i < 9; i++) {
+        int goodval;
+
+        switch (i) {
+        case 1:
+            goodval = 1;
+            break;
+        case 2:
+            goodval = 2;
+            break;
+        case 3:
+            goodval = 3;
+            break;
+        case 5:
+            goodval = 4;
+            break;
+        case 6:
+            goodval = 5;
+            break;
+        case 8:
+            goodval = 6;
+            break;
+        default:
+            goodval = 0;        /* pack_and_unpack() zeros before unpack */
+            break;
+        }
+        if (buf[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], goodval);
+        }
+    }
+
+    MPI_Type_free(&newtype);
 
     return errs;
 }
@@ -346,8 +317,8 @@ int indexed_contig_leading_zero_test(void)
     MPI_Datatype type = MPI_DATATYPE_NULL;
     MPI_Datatype struct_type = MPI_DATATYPE_NULL;
     MPI_Datatype types[2];
-    int len[3]  = { 0, 4, 0 };
-    int disp[3] = { INT_MAX, 2, INT_MAX};
+    int len[3] = { 0, 4, 0 };
+    int disp[3] = { INT_MAX, 2, INT_MAX };
     MPI_Aint adisp[3];
     MPI_Aint lb, ub;
     int *buf = NULL;
@@ -364,7 +335,7 @@ int indexed_contig_leading_zero_test(void)
 
     /* make sure packing/unpacking works (hits a simple "is_contig" case in
      * MPICH's pack/unpack routines) */
-    buf = malloc(10*sizeof(int));
+    buf = malloc(10 * sizeof(int));
     assert(buf != NULL);
     for (i = 0; i < 10; ++i) {
         buf[i] = i + 1;
@@ -388,7 +359,7 @@ int indexed_contig_leading_zero_test(void)
     len[0] = 1;
     len[1] = 1;
     adisp[0] = 0;
-    adisp[1] = 8*sizeof(int);
+    adisp[1] = 8 * sizeof(int);
     types[0] = type;
     types[1] = MPI_INT;
 
@@ -399,7 +370,7 @@ int indexed_contig_leading_zero_test(void)
     err = MPI_Type_commit(&struct_type);
     check_err(err, "committing struct type in indexed_contig_leading_zero_test()");
 
-    buf = malloc(10*sizeof(int));
+    buf = malloc(10 * sizeof(int));
     assert(buf != NULL);
     for (i = 0; i < 10; ++i) {
         buf[i] = i + 1;
@@ -418,7 +389,7 @@ int indexed_contig_leading_zero_test(void)
     free(buf);
 
     MPI_Type_free(&struct_type);
-    MPI_Type_free( &type );
+    MPI_Type_free(&type);
 
     /* -------------------------------------------------------------------- */
     /* now do the same as above, but with hindexed */
@@ -430,16 +401,16 @@ int indexed_contig_leading_zero_test(void)
     /* FIXME: This should also look at long, or use a different approach */
 #if defined(HAVE_LONG_LONG) && defined(LLONG_MAX)
     if (sizeof(MPI_Aint) == sizeof(long long)) {
-        adisp[0] = (MPI_Aint)LLONG_MAX;
-        adisp[1] = 2*sizeof(int);
-        adisp[2] = (MPI_Aint)LLONG_MAX;
+        adisp[0] = (MPI_Aint) LLONG_MAX;
+        adisp[1] = 2 * sizeof(int);
+        adisp[2] = (MPI_Aint) LLONG_MAX;
     }
-    else 
+    else
 #endif
     {
-        adisp[0] = (MPI_Aint)INT_MAX;
-        adisp[1] = 2*sizeof(int);
-        adisp[2] = (MPI_Aint)INT_MAX;
+        adisp[0] = (MPI_Aint) INT_MAX;
+        adisp[1] = 2 * sizeof(int);
+        adisp[2] = (MPI_Aint) INT_MAX;
     }
 
     err = MPI_Type_hindexed(3, len, adisp, MPI_INT, &type);
@@ -453,7 +424,7 @@ int indexed_contig_leading_zero_test(void)
     MPI_Type_ub(type, &ub);
     check(ub == 6 * sizeof(int));
 
-    buf = malloc(10*sizeof(int));
+    buf = malloc(10 * sizeof(int));
     assert(buf != NULL);
     for (i = 0; i < 10; ++i) {
         buf[i] = i + 1;
@@ -479,7 +450,7 @@ int indexed_contig_leading_zero_test(void)
     len[0] = 1;
     len[1] = 1;
     adisp[0] = 0;
-    adisp[1] = 8*sizeof(int);
+    adisp[1] = 8 * sizeof(int);
 
     /* struct layout: xx0123xx4x ('x' indicates a hole), one char is an
      * MPI_INT */
@@ -488,7 +459,7 @@ int indexed_contig_leading_zero_test(void)
     err = MPI_Type_commit(&struct_type);
     check_err(err, "committing struct type in indexed_contig_leading_zero_test()");
 
-    buf = malloc(10*sizeof(int));
+    buf = malloc(10 * sizeof(int));
     assert(buf != NULL);
     for (i = 0; i < 10; ++i) {
         buf[i] = i + 1;
@@ -551,7 +522,7 @@ int indexed_same_lengths(void)
     MPI_Type_ub(type, &ub);
     check(ub == 9 * sizeof(int));
 
-    buf = malloc(10*sizeof(int));
+    buf = malloc(10 * sizeof(int));
     assert(buf != NULL);
     for (i = 0; i < 10; ++i) {
         buf[i] = i + 1;
@@ -592,7 +563,7 @@ int indexed_same_lengths(void)
     MPI_Type_ub(type, &ub);
     check(ub == 9 * sizeof(int));
 
-    buf = malloc(10*sizeof(int));
+    buf = malloc(10 * sizeof(int));
     assert(buf != NULL);
     for (i = 0; i < 10; ++i) {
         buf[i] = i + 1;
@@ -629,87 +600,64 @@ int indexed_same_lengths(void)
  *             between the pack and unpack steps
  *
  */
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
 {
     char *packbuf;
     int err, errs = 0, pack_size, type_size, position;
 
     err = MPI_Type_size(datatype, &type_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     type_size *= count;
 
     err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Pack_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     packbuf = (char *) malloc(pack_size);
     if (packbuf == NULL) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in malloc call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     position = 0;
-    err = MPI_Pack(typebuf,
-                  count,
-                  datatype,
-                  packbuf,
-                  type_size,
-                  &position,
-                  MPI_COMM_SELF);
+    err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
     }
 
     memset(typebuf, 0, typebufsz);
     position = 0;
-    err = MPI_Unpack(packbuf,
-                    type_size,
-                    &position,
-                    typebuf,
-                    count,
-                    datatype,
-                    MPI_COMM_SELF);
+    err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Unpack call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     free(packbuf);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
     }
 
     return errs;
@@ -718,19 +666,18 @@ static int pack_and_unpack(char *typebuf,
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index fd316d6..da733fc 100644 (file)
@@ -66,38 +66,38 @@ int main(int argc, char *argv[])
     MPI_Type_commit(&four_ints);
 
     /* a type with size>INT_MAX */
-    MPI_Type_vector(INT_MAX/2, 1, 3, four_ints, &imx4i);
+    MPI_Type_vector(INT_MAX / 2, 1, 3, four_ints, &imx4i);
     MPI_Type_commit(&imx4i);
     /* don't forget, ub for dtype w/ stride doesn't include any holes at the end
      * of the type, hence the more complicated calculation below */
-    imx4i_true_extent = 3LL*4LL*sizeof(int)*((INT_MAX/2)-1) + 4LL*sizeof(int);
+    imx4i_true_extent = 3LL * 4LL * sizeof(int) * ((INT_MAX / 2) - 1) + 4LL * sizeof(int);
 
     /* sanity check that the MPI_COUNT predefined named datatype exists */
     MPI_Send(&imx4i_true_extent, 1, MPI_COUNT, MPI_PROC_NULL, 0, MPI_COMM_SELF);
 
     /* the same oversized type but with goofy extents */
-    MPI_Type_create_resized(imx4i, /*lb=*/INT_MAX, /*extent=*/-1024, &imx4i_rsz);
+    MPI_Type_create_resized(imx4i, /*lb= */ INT_MAX, /*extent= */ -1024, &imx4i_rsz);
     MPI_Type_commit(&imx4i_rsz);
 
     /* MPI_Type_size */
     MPI_Type_size(imax_contig, &size);
     check(size == INT_MAX);
     MPI_Type_size(four_ints, &size);
-    check(size == 4*sizeof(int));
+    check(size == 4 * sizeof(int));
     MPI_Type_size(imx4i, &size);
-    check(size == MPI_UNDEFINED); /* should overflow an int */
+    check(size == MPI_UNDEFINED);       /* should overflow an int */
     MPI_Type_size(imx4i_rsz, &size);
-    check(size == MPI_UNDEFINED); /* should overflow an int */
+    check(size == MPI_UNDEFINED);       /* should overflow an int */
 
     /* MPI_Type_size_x */
     MPI_Type_size_x(imax_contig, &size_x);
     check(size_x == INT_MAX);
     MPI_Type_size_x(four_ints, &size_x);
-    check(size_x == 4*sizeof(int));
+    check(size_x == 4 * sizeof(int));
     MPI_Type_size_x(imx4i, &size_x);
-    check(size_x == 4LL*sizeof(int)*(INT_MAX/2)); /* should overflow an int */
+    check(size_x == 4LL * sizeof(int) * (INT_MAX / 2)); /* should overflow an int */
     MPI_Type_size_x(imx4i_rsz, &size_x);
-    check(size_x == 4LL*sizeof(int)*(INT_MAX/2)); /* should overflow an int */
+    check(size_x == 4LL * sizeof(int) * (INT_MAX / 2)); /* should overflow an int */
 
     /* MPI_Type_get_extent */
     MPI_Type_get_extent(imax_contig, &lb, &extent);
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
     check(extent == INT_MAX);
     MPI_Type_get_extent(four_ints, &lb, &extent);
     check(lb == 0);
-    check(extent == 4*sizeof(int));
+    check(extent == 4 * sizeof(int));
     MPI_Type_get_extent(imx4i, &lb, &extent);
     check(lb == 0);
     if (sizeof(MPI_Aint) == sizeof(int))
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
     check(extent_x == INT_MAX);
     MPI_Type_get_extent_x(four_ints, &lb_x, &extent_x);
     check(lb_x == 0);
-    check(extent_x == 4*sizeof(int));
+    check(extent_x == 4 * sizeof(int));
     MPI_Type_get_extent_x(imx4i, &lb_x, &extent_x);
     check(lb_x == 0);
     check(extent_x == imx4i_true_extent);
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
     check(extent == INT_MAX);
     MPI_Type_get_true_extent(four_ints, &lb, &extent);
     check(lb == 0);
-    check(extent == 4*sizeof(int));
+    check(extent == 4 * sizeof(int));
     MPI_Type_get_true_extent(imx4i, &lb, &extent);
     check(lb == 0);
     if (sizeof(MPI_Aint) == sizeof(int))
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
     check(extent_x == INT_MAX);
     MPI_Type_get_true_extent_x(four_ints, &lb_x, &extent_x);
     check(lb_x == 0);
-    check(extent_x == 4*sizeof(int));
+    check(extent_x == 4 * sizeof(int));
     MPI_Type_get_true_extent_x(imx4i, &lb_x, &extent_x);
     check(lb_x == 0);
     check(extent_x == imx4i_true_extent);
@@ -221,14 +221,18 @@ int main(int argc, char *argv[])
 
     check_set_elements(imax_contig, INT_MAX);
     check_set_elements(four_ints, 4);
-    check_set_elements(imx4i, 4LL*(INT_MAX/2));
-    check_set_elements(imx4i_rsz, 4LL*(INT_MAX/2));
-
-epilogue:
-    if (imax_contig != MPI_DATATYPE_NULL) MPI_Type_free(&imax_contig);
-    if (four_ints != MPI_DATATYPE_NULL) MPI_Type_free(&four_ints);
-    if (imx4i != MPI_DATATYPE_NULL) MPI_Type_free(&imx4i);
-    if (imx4i_rsz != MPI_DATATYPE_NULL) MPI_Type_free(&imx4i_rsz);
+    check_set_elements(imx4i, 4LL * (INT_MAX / 2));
+    check_set_elements(imx4i_rsz, 4LL * (INT_MAX / 2));
+
+  epilogue:
+    if (imax_contig != MPI_DATATYPE_NULL)
+        MPI_Type_free(&imax_contig);
+    if (four_ints != MPI_DATATYPE_NULL)
+        MPI_Type_free(&four_ints);
+    if (imx4i != MPI_DATATYPE_NULL)
+        MPI_Type_free(&imx4i);
+    if (imx4i_rsz != MPI_DATATYPE_NULL)
+        MPI_Type_free(&imx4i_rsz);
 
     MPI_Reduce((wrank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
     if (wrank == 0) {
index 4688e1b..48a256d 100644 (file)
 
 static MPI_Datatype make_largexfer_type_struct(MPI_Offset nbytes)
 {
-    int typechunk_size = 1024*1024; /* in bytes: TODO: figure out how big a
-                                       chunk is really needed */
+    int typechunk_size = 1024 * 1024;   /* in bytes: TODO: figure out how big a
+                                         * chunk is really needed */
     int chunk_count;
-    int remainder=0;
+    int remainder = 0;
     MPI_Datatype memtype, chunktype;
 
     /* need to cook up a new datatype to accomodate large datatypes */
     /* first pass: chunks of 1 MiB plus an additional remainder.  Does require
      * 8 byte MPI_Aint, which should have been checked for earlier */
 
-    chunk_count = nbytes/typechunk_size;
+    chunk_count = nbytes / typechunk_size;
     remainder = nbytes % typechunk_size;
     MPI_Type_contiguous(typechunk_size, MPI_BYTE, &chunktype);
     MPI_Type_commit(&chunktype);
 
     /* a zero remainder means we can just count contigs */
     if (remainder == 0) {
-       MPI_Type_contiguous(chunk_count, chunktype, &memtype);
-       MPI_Type_free(&chunktype);
-    } else {
-       if (sizeof(MPI_Aint) <= sizeof(int)) {
-           return MPI_DATATYPE_NULL;
-       }
-       /* struct type: some number of chunks plus remaining bytes tacked
+        MPI_Type_contiguous(chunk_count, chunktype, &memtype);
+        MPI_Type_free(&chunktype);
+    }
+    else {
+        if (sizeof(MPI_Aint) <= sizeof(int)) {
+            return MPI_DATATYPE_NULL;
+        }
+        /* struct type: some number of chunks plus remaining bytes tacked
          * on at end */
-        int lens[] = {chunk_count, remainder};
-        MPI_Aint disp[] = {0, (MPI_Aint) typechunk_size * (MPI_Aint)chunk_count};
-        MPI_Datatype types[] = {chunktype, MPI_BYTE};
+        int lens[] = { chunk_count, remainder };
+        MPI_Aint disp[] = { 0, (MPI_Aint) typechunk_size * (MPI_Aint) chunk_count };
+        MPI_Datatype types[] = { chunktype, MPI_BYTE };
 
         MPI_Type_struct(2, lens, disp, types, &memtype);
         MPI_Type_free(&chunktype);
@@ -46,10 +47,11 @@ static MPI_Datatype make_largexfer_type_struct(MPI_Offset nbytes)
     MPI_Type_commit(&memtype);
     return memtype;
 }
+
 static MPI_Datatype make_largexfer_type_hindexed(MPI_Offset nbytes)
 {
     int i, count;
-    int chunk_size = 1024*1024;
+    int chunk_size = 1024 * 1024;
     int *blocklens;
     MPI_Aint *disp;
     MPI_Datatype memtype;
@@ -61,53 +63,55 @@ static MPI_Datatype make_largexfer_type_hindexed(MPI_Offset nbytes)
     if (sizeof(MPI_Aint) <= sizeof(int)) {
         return MPI_DATATYPE_NULL;
     }
-    
+
     /* ceiling division */
-    count = 1 + ((nbytes -1) / chunk_size );
+    count = 1 + ((nbytes - 1) / chunk_size);
 
     blocklens = calloc(count, sizeof(int));
     disp = calloc(count, sizeof(MPI_Aint));
 
 
-    for (i=0; i<(count-1); i++) {
-       blocklens[i] = chunk_size;
-       disp[i] = (MPI_Aint)chunk_size*i;
+    for (i = 0; i < (count - 1); i++) {
+        blocklens[i] = chunk_size;
+        disp[i] = (MPI_Aint) chunk_size *i;
     }
-    blocklens[count-1] = nbytes-((MPI_Aint)chunk_size*i);
-    disp[count-1] = (MPI_Aint)chunk_size*(count-1);
+    blocklens[count - 1] = nbytes - ((MPI_Aint) chunk_size * i);
+    disp[count - 1] = (MPI_Aint) chunk_size *(count - 1);
 
     MPI_Type_create_hindexed(count, blocklens, disp, MPI_BYTE, &memtype);
     MPI_Type_commit(&memtype);
 
+    free(blocklens);
+    free(disp);
     return memtype;
 }
 
 
-int testtype(MPI_Datatype type, MPI_Offset expected) {
+int testtype(MPI_Datatype type, MPI_Offset expected)
+{
     MPI_Count size, lb, extent;
-    int nerrors=0;
+    int nerrors = 0;
     MPI_Type_size_x(type, &size);
 
-    if (size < 0)  {
-       printf("ERROR: type size apparently overflowed integer\n");
-       nerrors++;
+    if (size < 0) {
+        printf("ERROR: type size apparently overflowed integer\n");
+        nerrors++;
     }
 
     if (size != expected) {
-       printf("reported type size %lld does not match expected %lld\n",
-               size, expected);
-       nerrors++;
+        printf("reported type size %lld does not match expected %lld\n", size, expected);
+        nerrors++;
     }
 
     MPI_Type_get_true_extent_x(type, &lb, &extent);
     if (lb != 0) {
-       printf("ERROR: type should have lb of 0, reported %lld\n", lb);
-       nerrors ++;
+        printf("ERROR: type should have lb of 0, reported %lld\n", lb);
+        nerrors++;
     }
 
-    if (extent != size) { 
-       printf("ERROR: extent should match size, not %lld\n", extent);
-       nerrors ++;
+    if (extent != size) {
+        printf("ERROR: extent should match size, not %lld\n", extent);
+        nerrors++;
     }
     return nerrors;
 }
@@ -116,16 +120,17 @@ int testtype(MPI_Datatype type, MPI_Offset expected) {
 int main(int argc, char **argv)
 {
 
-    int nerrors=0, i;
+    int nerrors = 0, i;
     int rank, size;
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
     MPI_Comm_size(MPI_COMM_WORLD, &size);
 
 #define NR_TYPES 3
-    MPI_Offset expected_sizes[NR_TYPES] = {1024UL*1024UL*2400UL,
-       2346319872,
-       2346319872};
+    MPI_Offset expected_sizes[NR_TYPES] = { 1024UL * 1024UL * 2400UL,
+        2346319872,
+        2346319872
+    };
     MPI_Datatype types[NR_TYPES];
 
     /* a contig type, itself large, but does not need 8 byte aints */
@@ -135,20 +140,21 @@ int main(int argc, char **argv)
     /* similar, but with hindexed type */
     types[2] = make_largexfer_type_hindexed(expected_sizes[2]);
 
-    for (i=0; i<NR_TYPES; i++) {
-       if (types[i] != MPI_DATATYPE_NULL) {
-               nerrors += testtype(types[i], expected_sizes[i]);
-               MPI_Type_free(&(types[i]));
-       }
+    for (i = 0; i < NR_TYPES; i++) {
+        if (types[i] != MPI_DATATYPE_NULL) {
+            nerrors += testtype(types[i], expected_sizes[i]);
+            MPI_Type_free(&(types[i]));
+        }
     }
 
     MPI_Finalize();
     if (rank == 0) {
-       if (nerrors) {
-           printf("found %d errors\n", nerrors);
-       } else {
-           printf(" No errors\n");
-       }
+        if (nerrors) {
+            printf("found %d errors\n", nerrors);
+        }
+        else {
+            printf(" No errors\n");
+        }
     }
 
     return 0;
index 056c4a7..013bb68 100644 (file)
 #include <assert.h>
 static void verbose_abort(int errorcode)
 {
+    int rank;
+    char errorstring[MPI_MAX_ERROR_STRING];
+    int errorclass;
+    int resultlen;
+
     /* We do not check error codes here
      * because if MPI is in a really sorry state,
      * all of them might fail. */
-
-    int rank;
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-
-    char errorstring[MPI_MAX_ERROR_STRING];
-    memset(errorstring, 0, MPI_MAX_ERROR_STRING); /* optional */
-
-    int errorclass;
     MPI_Error_class(errorcode, &errorclass);
-
-    int resultlen;
     MPI_Error_string(errorcode, errorstring, &resultlen);
 
+    memset(errorstring, 0, MPI_MAX_ERROR_STRING);       /* optional */
     fprintf(stderr, "%d: MPI failed (%d: %s) \n", rank, errorclass, errorstring);
-    fflush(stderr); /* almost certainly redundant with the following... */
+    fflush(stderr);     /* almost certainly redundant with the following... */
 
     MPI_Abort(MPI_COMM_WORLD, errorclass);
 
     return;
 }
+
 #define MPI_ASSERT(rc)  \
     do { if ((rc)!=MPI_SUCCESS) verbose_abort(rc); } while (0)
 
-int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype,
-       MPI_Datatype * newtype);
+int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newtype);
 
 #define BIGMPI_MAX INT_MAX
 
@@ -56,7 +53,7 @@ int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype,
  * int Type_contiguous_x(MPI_Count      count,
  *                            MPI_Datatype   oldtype,
  *                            MPI_Datatype * newtype)
- *                         
+ *
  *  Input Parameters
  *
  *   count             replication count (nonnegative integer)
@@ -69,28 +66,29 @@ int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype,
  */
 int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newtype)
 {
-    MPI_Count c = count/BIGMPI_MAX;
-    MPI_Count r = count%BIGMPI_MAX;
+    MPI_Count c = count / BIGMPI_MAX;
+    MPI_Count r = count % BIGMPI_MAX;
 
     MPI_Datatype chunk;
-    MPI_ASSERT(MPI_Type_contiguous(BIGMPI_MAX, oldtype, &chunk));
-
     MPI_Datatype chunks;
-    MPI_ASSERT(MPI_Type_contiguous(c, chunk, &chunks));
-
     MPI_Datatype remainder;
-    MPI_ASSERT(MPI_Type_contiguous(r, oldtype, &remainder));
-
     int typesize;
+
+    MPI_ASSERT(MPI_Type_contiguous(BIGMPI_MAX, oldtype, &chunk));
+    MPI_ASSERT(MPI_Type_contiguous(c, chunk, &chunks));
+    MPI_ASSERT(MPI_Type_contiguous(r, oldtype, &remainder));
     MPI_ASSERT(MPI_Type_size(oldtype, &typesize));
 
-    MPI_Aint remdisp                   = (MPI_Aint)c*BIGMPI_MAX*typesize; /* must explicit-cast to avoid overflow */
-    int array_of_blocklengths[2]       = {1,1};
-    MPI_Aint array_of_displacements[2] = {0,remdisp};
-    MPI_Datatype array_of_types[2]     = {chunks,remainder};
+    {
+        MPI_Aint remdisp = (MPI_Aint) c * BIGMPI_MAX * typesize;    /* must explicit-cast to avoid overflow */
+        int array_of_blocklengths[2] = { 1, 1 };
+        MPI_Aint array_of_displacements[2] = { 0, remdisp };
+        MPI_Datatype array_of_types[2] = { chunks, remainder };
 
-    MPI_ASSERT(MPI_Type_create_struct(2, array_of_blocklengths, array_of_displacements, array_of_types, newtype));
-    MPI_ASSERT(MPI_Type_commit(newtype));
+        MPI_ASSERT(MPI_Type_create_struct
+                   (2, array_of_blocklengths, array_of_displacements, array_of_types, newtype));
+        MPI_ASSERT(MPI_Type_commit(newtype));
+    }
 
     MPI_ASSERT(MPI_Type_free(&chunk));
     MPI_ASSERT(MPI_Type_free(&chunks));
@@ -100,76 +98,84 @@ int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newt
 }
 
 
-int main(int argc, char * argv[])
+int main(int argc, char *argv[])
 {
     int provided;
     size_t i;
-    MPI_Count j;
-    MPI_ASSERT(MPI_Init_thread(&argc, &argv, MPI_THREAD_SINGLE, &provided));
 
     int rank, size;
-    MPI_ASSERT(MPI_Comm_rank(MPI_COMM_WORLD, &rank));
-    MPI_ASSERT(MPI_Comm_size(MPI_COMM_WORLD, &size));
 
-    int logn = (argc>1) ? atoi(argv[1]) : 32;
-    size_t count = (size_t)1<<logn; /* explicit cast required */
+    int logn = (argc > 1) ? atoi(argv[1]) : 32;
+    size_t count = (size_t) 1 << logn;  /* explicit cast required */
 
     MPI_Datatype bigtype;
-    MPI_ASSERT(Type_contiguous_x( (MPI_Count)count, MPI_CHAR, &bigtype));
-    MPI_ASSERT(MPI_Type_commit(&bigtype));
 
     MPI_Request requests[2];
     MPI_Status statuses[2];
+    MPI_Count ocount;
+
+    char *rbuf = NULL;
+    char *sbuf = NULL;
 
-    char * rbuf = NULL;
-    char * sbuf = NULL;
+    MPI_ASSERT(MPI_Init_thread(&argc, &argv, MPI_THREAD_SINGLE, &provided));
+
+    MPI_ASSERT(MPI_Comm_rank(MPI_COMM_WORLD, &rank));
+    MPI_ASSERT(MPI_Comm_size(MPI_COMM_WORLD, &size));
+
+    MPI_ASSERT(Type_contiguous_x((MPI_Count) count, MPI_CHAR, &bigtype));
+    MPI_ASSERT(MPI_Type_commit(&bigtype));
 
-    if (rank==(size-1)) {
-        rbuf = malloc( count * sizeof(char)); assert(rbuf!=NULL);
-        for (i=0; i<count; i++)
+    if (rank == (size - 1)) {
+        rbuf = malloc(count * sizeof(char));
+        assert(rbuf != NULL);
+        for (i = 0; i < count; i++)
             rbuf[i] = 'a';
 
-        MPI_ASSERT(MPI_Irecv(rbuf, 1, bigtype, 0,      0, MPI_COMM_WORLD, &(requests[1]) ));
+        MPI_ASSERT(MPI_Irecv(rbuf, 1, bigtype, 0, 0, MPI_COMM_WORLD, &(requests[1])));
     }
-    if (rank==0) {
-        sbuf = malloc( count * sizeof(char)); assert(sbuf!=NULL);
-        for (i=0; i<count; i++)
+    if (rank == 0) {
+        sbuf = malloc(count * sizeof(char));
+        assert(sbuf != NULL);
+        for (i = 0; i < count; i++)
             sbuf[i] = 'z';
 
-        MPI_ASSERT(MPI_Isend(sbuf, 1, bigtype, size-1, 0, MPI_COMM_WORLD, &(requests[0]) ));
+        MPI_ASSERT(MPI_Isend(sbuf, 1, bigtype, size - 1, 0, MPI_COMM_WORLD, &(requests[0])));
     }
 
-    MPI_Count ocount[2];
-
-    if (size==1) {
+    if (size == 1) {
         MPI_ASSERT(MPI_Waitall(2, requests, statuses));
-        MPI_ASSERT(MPI_Get_elements_x( &(statuses[1]), MPI_CHAR, &(ocount[1])));
+        MPI_ASSERT(MPI_Get_elements_x(&(statuses[1]), MPI_CHAR, &ocount));
     }
     else {
-        if (rank==(size-1)) {
-            MPI_ASSERT(MPI_Wait( &(requests[1]), &(statuses[1]) ));
-            MPI_ASSERT(MPI_Get_elements_x( &(statuses[1]), MPI_CHAR, &(ocount[1]) ));
-        } else if (rank==0) {
-            MPI_ASSERT(MPI_Wait( &(requests[0]), &(statuses[0]) ));
-           /* No valid fields in status from a send request (MPI-3 p53,
-              line 1-5) */
+        if (rank == (size - 1)) {
+            MPI_ASSERT(MPI_Wait(&(requests[1]), &(statuses[1])));
+            MPI_ASSERT(MPI_Get_elements_x(&(statuses[1]), MPI_CHAR, &ocount));
+        }
+        else if (rank == 0) {
+            MPI_ASSERT(MPI_Wait(&(requests[0]), &(statuses[0])));
+            /* No valid fields in status from a send request (MPI-3 p53,
+             * line 1-5) */
         }
     }
 
     /* correctness check */
-    if (rank==(size-1)) {
-        MPI_Count errors = 0;
-        for (j=0; j<count; j++)
-            errors += ( rbuf[j] != 'z' );
+    if (rank == (size - 1)) {
+        MPI_Count j, errors = 0;
+        for (j = 0; j < count; j++)
+            errors += (rbuf[j] != 'z');
+        if (count != ocount) ++errors;
         if (errors == 0) {
-           printf(" No Errors\n");
-       } else {
-           printf("errors = %lld \n", errors);
-       }
+            printf(" No Errors\n");
+        }
+        else {
+            printf("errors = %lld \n", errors);
+        }
     }
 
-    if (rbuf) free(rbuf);
-    if (sbuf) free(sbuf);
+    if (rbuf)
+        free(rbuf);
+    if (sbuf)
+        free(sbuf);
 
     MPI_ASSERT(MPI_Type_free(&bigtype));
 
diff --git a/teshsuite/smpi/mpich3-test/datatype/large_vec.c b/teshsuite/smpi/mpich3-test/datatype/large_vec.c
new file mode 100644 (file)
index 0000000..f912a60
--- /dev/null
@@ -0,0 +1,82 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (C) 2014 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+#include <mpi.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/* tests non-contig send/recv of a message > 2GB. count=270M, type=long long
+   run with 3 processes to exercise both shared memory and TCP in Nemesis tests*/
+
+int main(int argc, char *argv[])
+{
+    int i, size, rank;
+    int elems = 270000000;
+    MPI_Status status;
+    MPI_Datatype dtype;
+    long long *cols;
+    int errs = 0;
+
+
+    MTest_Init(&argc, &argv);
+
+    /* need large memory */
+    if (sizeof(void *) < 8) {
+        MTest_Finalize(errs);
+        MPI_Finalize();
+        return 0;
+    }
+
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    if (size != 3) {
+        fprintf(stderr, "[%d] usage: mpiexec -n 3 %s\n", rank, argv[0]);
+        MPI_Abort(MPI_COMM_WORLD, 1);
+    }
+
+    cols = malloc(elems * sizeof(long long));
+    if (cols == NULL) {
+        printf("malloc of >2GB array failed\n");
+        errs++;
+        MTest_Finalize(errs);
+        MPI_Finalize();
+        return 0;
+    }
+
+    MPI_Type_vector(elems / 2, 1, 2, MPI_LONG_LONG_INT, &dtype);
+    MPI_Type_commit(&dtype);
+
+    if (rank == 0) {
+        for (i = 0; i < elems; i++)
+            cols[i] = i;
+        /* printf("[%d] sending...\n",rank); */
+        MPI_Send(cols, 1, dtype, 1, 0, MPI_COMM_WORLD);
+        MPI_Send(cols, 1, dtype, 2, 0, MPI_COMM_WORLD);
+    }
+    else {
+        /* printf("[%d] receiving...\n",rank); */
+        for (i = 0; i < elems; i++)
+            cols[i] = -1;
+        MPI_Recv(cols, 1, dtype, 0, 0, MPI_COMM_WORLD, &status);
+        /* MPI_Get_count(&status,MPI_LONG_LONG_INT,&cnt);
+         * Get_count still fails because count is not 64 bit */
+        for (i = 0; i < elems; i++) {
+            if (i % 2)
+                continue;
+            if (cols[i] != i) {
+                printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i);
+                errs++;
+            }
+        }
+    }
+
+    MPI_Type_free(&dtype);
+    free(cols);
+
+    MTest_Finalize(errs);
+    MPI_Finalize();
+    return 0;
+}
index 366dd6c..b1c4824 100644 (file)
@@ -12,7 +12,7 @@
 #include <string.h>
 #endif
 
-/* 
+/*
    The default behavior of the test routines should be to briefly indicate
    the cause of any errors - in this test, that means that verbose needs
    to be set. Verbose should turn on output that is independent of error
@@ -39,55 +39,65 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in simple lb/ub test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in simple lb/ub test\n", err);
     errs += err;
 
     err = contig_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in contig test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in contig test\n", err);
     errs += err;
 
     err = contig_negextent_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in negextent contig test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in negextent contig test\n", err);
     errs += err;
 
     err = vector_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in simple vector test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in simple vector test\n", err);
     errs += err;
 
     err = vector_blklen_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in vector blklen test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in vector blklen test\n", err);
     errs += err;
 
     err = vector_blklen_stride_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in strided vector test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in strided vector test\n", err);
     errs += err;
 
     err = vector_blklen_negstride_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in negstrided vector test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in negstrided vector test\n", err);
     errs += err;
 
     err = int_with_negextent_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in negextent lb/ub test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in negextent lb/ub test\n", err);
     errs += err;
 
     err = vector_blklen_stride_negextent_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in strided negextent vector test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in strided negextent vector test\n", err);
     errs += err;
 
     err = vector_blklen_negstride_negextent_of_int_with_lb_ub_test();
-    if (err && verbose) fprintf(stderr, "found %d errors in negstrided negextent vector test\n", err);
+    if (err && verbose)
+        fprintf(stderr, "found %d errors in negstrided negextent vector test\n", err);
     errs += err;
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
@@ -95,19 +105,19 @@ int main(int argc, char **argv)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
 
@@ -123,95 +133,115 @@ int int_with_lb_ub_test(void)
 
     err = MPI_Type_struct(3, blocks, disps, types, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 4) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 4);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 4);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 9) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %ld; should be %d\n", (long) aval, 9);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %ld; should be %d\n", (long) aval, 9);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
     }
 
     if (extent != 9) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, 9);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, 9);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 6) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 6);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 6);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != 0) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
     }
 
     if (aval != 4) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 4);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 4);
     }
-    
+
     MPI_Type_free(&eviltype);
 
     return errs;
@@ -229,117 +259,143 @@ int contig_of_int_with_lb_ub_test(void)
     MPI_Datatype inttype, eviltype;
 
     /* build same type as in int_with_lb_ub_test() */
-    typemapstring = (char*)"{ (LB,-3),4*(BYTE,0),(UB,6) }";
+    typemapstring = (char *) "{ (LB,-3),4*(BYTE,0),(UB,6) }";
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct of %s failed.\n",
-                            typemapstring );
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
-    typemapstring=(char*)"{ (LB,-3),4*(BYTE,0),(UB,6),(LB,6),4*(BYTE,9),(UB,15),(LB,15),4*(BYTE,18),(UB,24)}";
+    typemapstring = (char *)
+        "{ (LB,-3),4*(BYTE,0),(UB,6),(LB,6),4*(BYTE,9),(UB,15),(LB,15),4*(BYTE,18),(UB,24)}";
     err = MPI_Type_contiguous(3, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_contiguous of %s failed.\n",
-                            typemapstring );
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_contiguous of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size of %s failed.\n", 
-                            typemapstring );
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 12) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", 
-                            val, 12);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 12);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 27) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 27);
-       if (verbose) fprintf( stderr, " for type %s\n", typemapstring );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 27);
+        if (verbose)
+            fprintf(stderr, " for type %s\n", typemapstring);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d from Type_lb; should be %d in %s\n", (int) aval, -3, typemapstring );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d from Type_lb; should be %d in %s\n", (int) aval, -3,
+                    typemapstring);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d from Type_get_extent; should be %d in %s\n",
-                            (int) aval, -3, typemapstring );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d from Type_get_extent; should be %d in %s\n",
+                    (int) aval, -3, typemapstring);
     }
 
     if (extent != 27) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d from Type_get_extent; should be %d in %s\n",
-                            (int) extent, 27, typemapstring);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d from Type_get_extent; should be %d in %s\n",
+                    (int) extent, 27, typemapstring);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 24) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d in Type_ub; should be %din %s\n", (int) aval, 24, typemapstring);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d in Type_ub; should be %din %s\n", (int) aval, 24,
+                    typemapstring);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != 0) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d in %s\n", (int) true_lb, 0, typemapstring);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d in %s\n", (int) true_lb, 0,
+                    typemapstring);
     }
 
     if (aval != 22) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d in %s\n", (int) aval, 22, typemapstring);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d in %s\n", (int) aval, 22,
+                    typemapstring);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
 
     return errs;
 }
@@ -356,116 +412,136 @@ int contig_negextent_of_int_with_lb_ub_test(void)
     MPI_Datatype inttype, eviltype;
 
     /* build same type as in int_with_lb_ub_test() */
-    typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3) }";
+    typemapstring = (char *) "{ (LB,6),4*(BYTE,0),(UB,-3) }";
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct of %s failed.\n",
-                            typemapstring );
-       if (verbose) MTestPrintError( err  );
-       /* No point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
+        /* No point in continuing */
+        return errs;
     }
 
-    typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3),(LB,-3),4*(BYTE,-9),(UB,-12),(LB,-12),4*(BYTE,-18),(UB,-21) }";
+    typemapstring = (char *)
+        "{ (LB,6),4*(BYTE,0),(UB,-3),(LB,-3),4*(BYTE,-9),(UB,-12),(LB,-12),4*(BYTE,-18),(UB,-21) }";
     err = MPI_Type_contiguous(3, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_contiguous of %s failed.\n",
-                            typemapstring);
-       if (verbose) MTestPrintError( err  );
-       /* No point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_contiguous of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
+        /* No point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size of %s failed.\n", 
-                            typemapstring);
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 12) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 12);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 12);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 9) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 9);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 9);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -12) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -12);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -12);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -12) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, -12);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -12);
     }
 
     if (extent != 9) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, 9);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, 9);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, -3);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != -18) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, -18);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, -18);
     }
 
     if (aval != 22) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 22);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 22);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
-    
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
+
     return errs;
 }
 
@@ -482,108 +558,130 @@ int vector_of_int_with_lb_ub_test(void)
     /* build same type as in int_with_lb_ub_test() */
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_vector(3, 1, 1, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_vector failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_vector failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 12) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 12);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 12);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 27) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 27);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 27);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
     }
 
     if (extent != 27) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, 27);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, 27);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 24) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 24);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 24);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != 0) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
     }
 
     if (aval != 22) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 22);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 22);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
 
     return errs;
 }
@@ -604,109 +702,132 @@ int vector_blklen_of_int_with_lb_ub_test(void)
     /* build same type as in int_with_lb_ub_test() */
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_vector(3, 4, 1, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_vector failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_vector failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 48) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 54) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 54);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 54);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
+        if (verbose)
+            MTestPrintError(err);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
     }
 
     if (extent != 54) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, 54);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, 54);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 51) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 51);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 51);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != 0) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
     }
 
     if (aval != 49) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 49);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 49);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
 
     return errs;
 }
@@ -723,112 +844,133 @@ int vector_blklen_stride_of_int_with_lb_ub_test(void)
     MPI_Datatype inttype, eviltype;
 
     /* build same type as in int_with_lb_ub_test() */
-    typemapstring = (char*)"{ (LB,-3),4*(BYTE,0),(UB,6) }";
+    typemapstring = (char *) "{ (LB,-3),4*(BYTE,0),(UB,6) }";
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct of %s failed.\n",
-                            typemapstring );
-       if (verbose) MTestPrintError( err  );
-       /* No point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
+        /* No point in continuing */
+        return errs;
     }
 
     err = MPI_Type_vector(3, 4, 5, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_vector failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_vector failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 48) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 126) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 126);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 126);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -3);
     }
 
     if (extent != 126) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, 126);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, 126);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 123) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 123);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 123);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != 0) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
     }
 
     if (aval != 121) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 121);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 121);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
 
     return errs;
 }
@@ -846,108 +988,130 @@ int vector_blklen_negstride_of_int_with_lb_ub_test(void)
     /* build same type as in int_with_lb_ub_test() */
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_vector(3, 4, -5, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_vector failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_vector failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 48) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 126) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 126);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 126);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -93) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -93);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -93);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -93) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, -93);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -93);
     }
 
     if (extent != 126) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, 126);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, 126);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 33) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 33);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, 33);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != -90) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, -90);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, -90);
     }
 
     if (aval != 121) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 121);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 121);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
 
     return errs;
 }
@@ -959,105 +1123,124 @@ int int_with_negextent_test(void)
     int blocks[3] = { 1, 4, 1 };
     MPI_Aint disps[3] = { 6, 0, -3 };
     MPI_Datatype types[3] = { MPI_LB, MPI_BYTE, MPI_UB };
-    char *typemapstring =0;
+    char *typemapstring = 0;
 
     MPI_Datatype eviltype;
 
-    typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3) }";
+    typemapstring = (char *) "{ (LB,6),4*(BYTE,0),(UB,-3) }";
     err = MPI_Type_struct(3, blocks, disps, types, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct of %s failed.\n",
-                            typemapstring );
-       if (verbose) MTestPrintError( err  );
-       /* No point in contiuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
+        /* No point in contiuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 4) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 4);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 4);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -9) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, -9);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, -9);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 6) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, 6);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, 6);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != 6) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, 6);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, 6);
     }
 
     if (extent != -9) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, -9);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, -9);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, -3);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != 0) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, 0);
     }
 
     if (aval != 4) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 4);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 4);
     }
-    
+
     MPI_Type_free(&eviltype);
 
     return errs;
@@ -1074,112 +1257,133 @@ int vector_blklen_stride_negextent_of_int_with_lb_ub_test(void)
     char *typemapstring = 0;
 
     /* build same type as in int_with_lb_ub_test() */
-    typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3) }";
+    typemapstring = (char *) "{ (LB,6),4*(BYTE,0),(UB,-3) }";
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct of %s failed.\n",
-                            typemapstring );
-       if (verbose) MTestPrintError( err  );
-       /* No point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct of %s failed.\n", typemapstring);
+        if (verbose)
+            MTestPrintError(err);
+        /* No point in continuing */
+        return errs;
     }
 
     err = MPI_Type_vector(3, 4, 5, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_vector failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_vector failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 48) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 108) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 108);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) aval, 108);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -111) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -111);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -111);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -111) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %d; should be %d\n",
-                            (int) aval, -111);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %d; should be %d\n", (int) aval, -111);
     }
 
     if (extent != 108) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %d; should be %d\n",
-                            (int) extent, 108);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %d; should be %d\n", (int) extent, 108);
     }
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -3) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, -3);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %d; should be %d\n", (int) aval, -3);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != -117) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, -117);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %d; should be %d\n", (int) true_lb, -117);
     }
 
     if (aval != 121) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 121);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %d; should be %d\n", (int) aval, 121);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
 
     return errs;
 }
@@ -1197,109 +1401,131 @@ int vector_blklen_negstride_negextent_of_int_with_lb_ub_test(void)
     /* build same type as in int_with_lb_ub_test() */
     err = MPI_Type_struct(3, blocks, disps, types, &inttype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_struct failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_struct failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_vector(3, 4, -5, inttype, &eviltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_vector failed.\n");
-       if (verbose) MTestPrintError( err  );
-       /* no point in continuing */
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_vector failed.\n");
+        if (verbose)
+            MTestPrintError(err);
+        /* no point in continuing */
+        return errs;
     }
 
     err = MPI_Type_size(eviltype, &val);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_size failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_size failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (val != 48) {
-       errs++;
-       if (verbose) fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  size of type = %d; should be %d\n", val, 48);
     }
 
     err = MPI_Type_extent(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 108) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %ld; should be %d\n", (long) aval, 108);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %ld; should be %d\n", (long) aval, 108);
     }
-    
+
     err = MPI_Type_lb(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_lb failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_lb failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != -21) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %ld; should be %d\n", (long) aval, -21);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %ld; should be %d\n", (long) aval, -21);
     }
 
     err = MPI_Type_get_extent(eviltype, &lb, &extent);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (lb != -21) {
-       errs++;
-       if (verbose) fprintf(stderr, "  lb of type = %ld; should be %d\n",
-                            (long) aval, -21);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  lb of type = %ld; should be %d\n", (long) aval, -21);
     }
 
     if (extent != 108) {
-       errs++;
-       if (verbose) fprintf(stderr, "  extent of type = %ld; should be %d\n",
-                            (long) extent, 108);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  extent of type = %ld; should be %d\n", (long) extent, 108);
     }
 
 
     err = MPI_Type_ub(eviltype, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_ub failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_ub failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (aval != 87) {
-       errs++;
-       if (verbose) fprintf(stderr, "  ub of type = %ld; should be %d\n", (long) aval, 87);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  ub of type = %ld; should be %d\n", (long) aval, 87);
     }
 
     err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
-       if (verbose) MTestPrintError( err  );
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  MPI_Type_get_true_extent failed.\n");
+        if (verbose)
+            MTestPrintError(err);
     }
 
     if (true_lb != -27) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true_lb of type = %ld; should be %d\n", (long) true_lb, -27);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true_lb of type = %ld; should be %d\n", (long) true_lb, -27);
     }
 
     if (aval != 121) {
-       errs++;
-       if (verbose) fprintf(stderr, "  true extent of type = %ld; should be %d\n", (long) aval, 121);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "  true extent of type = %ld; should be %d\n", (long) aval, 121);
     }
 
-    MPI_Type_free( &inttype );
-    MPI_Type_free( &eviltype );
+    MPI_Type_free(&inttype);
+    MPI_Type_free(&eviltype);
 
     return errs;
 }
index 11e165a..54e3d4f 100644 (file)
@@ -20,6 +20,7 @@ static int verbose = 0;
 
 #define BUF_SIZE 16384
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 
 int main(int argc, char *argv[])
@@ -27,51 +28,54 @@ int main(int argc, char *argv[])
     int errs = 0;
     char buffer[BUF_SIZE];
     int n, size;
-    double a,b;
+    double a, b;
     int pos;
 
     /* Initialize MPI */
     MPI_Init(&argc, &argv);
     parse_args(argc, argv);
 
-    pos        = 0;
-    n  = 10;
-    a  = 1.1;
-    b  = 2.2;
+    pos = 0;
+    n = 10;
+    a = 1.1;
+    b = 2.2;
 
     MPI_Pack(&n, 1, MPI_INT, buffer, BUF_SIZE, &pos, MPI_COMM_WORLD);
     MPI_Pack(&a, 1, MPI_DOUBLE, buffer, BUF_SIZE, &pos, MPI_COMM_WORLD);
     MPI_Pack(&b, 1, MPI_DOUBLE, buffer, BUF_SIZE, &pos, MPI_COMM_WORLD);
 
     size = pos;
-    pos  = 0;
-    n    = 0;
-    a    = 0;
-    b    = 0;
+    pos = 0;
+    n = 0;
+    a = 0;
+    b = 0;
 
     MPI_Unpack(buffer, size, &pos, &n, 1, MPI_INT, MPI_COMM_WORLD);
     MPI_Unpack(buffer, size, &pos, &a, 1, MPI_DOUBLE, MPI_COMM_WORLD);
     MPI_Unpack(buffer, size, &pos, &b, 1, MPI_DOUBLE, MPI_COMM_WORLD);
     /* Check results */
-    if (n != 10) { 
-       errs++;
-       if (verbose) fprintf(stderr, "Wrong value for n; got %d expected %d\n", n, 10 );
+    if (n != 10) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "Wrong value for n; got %d expected %d\n", n, 10);
     }
-    if (a != 1.1) { 
-       errs++;
-       if (verbose) fprintf(stderr, "Wrong value for a; got %f expected %f\n", a, 1.1 );
+    if (a != 1.1) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "Wrong value for a; got %f expected %f\n", a, 1.1);
     }
-    if (b != 2.2) { 
-       errs++;
-       if (verbose) fprintf(stderr, "Wrong value for b; got %f expected %f\n", b, 2.2 );
+    if (b != 2.2) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "Wrong value for b; got %f expected %f\n", b, 2.2);
     }
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -80,18 +84,18 @@ int main(int argc, char *argv[])
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 7175e91..9275ef1 100644 (file)
@@ -35,8 +35,8 @@ int main(int argc, char *argv[])
         if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
             MPI_Type_size(MPI_LONG_DOUBLE, &type_size);
             if (type_size != sizeof(long double)) {
-                printf("type_size != sizeof(long double) : (%zd != %zd)\n",
-                       (size_t)type_size, sizeof(long double));
+                printf("type_size != sizeof(long double) : (%d != %zd)\n",
+                       type_size, sizeof(long double));
                 ++errs;
             }
         }
@@ -45,8 +45,8 @@ int main(int argc, char *argv[])
         if (MPI_C_LONG_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
             MPI_Type_size(MPI_C_LONG_DOUBLE_COMPLEX, &type_size);
             if (type_size != sizeof(long double _Complex)) {
-                printf("type_size != sizeof(long double _Complex) : (%zd != %zd)\n",
-                       (size_t)type_size, sizeof(long double _Complex));
+                printf("type_size != sizeof(long double _Complex) : (%d != %zd)\n",
+                       type_size, sizeof(long double _Complex));
                 ++errs;
             }
         }
@@ -62,4 +62,3 @@ int main(int argc, char *argv[])
     MPI_Finalize();
     return 0;
 }
-
index 418ff0b..c3f6e66 100644 (file)
@@ -10,7 +10,7 @@
 #include "mpi.h"
 #include "mpitest.h"
 
-/* 
+/*
    The default behavior of the test routines should be to briefly indicate
    the cause of any errors - in this test, that means that verbose needs
    to be set. Verbose should turn on output that is independent of error
 */
 static int verbose = 1;
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 int lots_of_types_test(void);
 
 struct test_struct_1 {
-    int a,b,c,d;
+    int a, b, c, d;
 };
 
 int main(int argc, char *argv[])
@@ -34,15 +35,16 @@ int main(int argc, char *argv[])
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     err = lots_of_types_test();
-    if (verbose && err) fprintf(stderr, "error in lots_of_types_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in lots_of_types_test\n");
     errs += err;
 
     /* print message and exit */
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
 
     MPI_Finalize();
     return 0;
@@ -71,107 +73,104 @@ int lots_of_types_test(void)
     int disps[NUM_BLOCKS];
     int blks[NUM_BLOCKS];
 
-    for (i=0; i < NUM_DTYPES; i++)
+    for (i = 0; i < NUM_DTYPES; i++)
         mytypes[i] = MPI_DATATYPE_NULL;
 
-    for (i=0; i < NUM_DTYPES; i++) {
-       int j;
-
-       disps[0] = 0;
-       blks[0]  = 4;
-       
-       for (j=1; j < NUM_BLOCKS; j++) {
-           disps[j] = 4 * j;
-           blks[j]  = (j % 3) + 1;
-       }
-
-       err = MPI_Type_indexed(NUM_BLOCKS, blks, disps, MPI_INT, &mytypes[i]);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Type_indexed returned error on type %d\n",
-                       i);
-           }
+    for (i = 0; i < NUM_DTYPES; i++) {
+        int j;
+
+        disps[0] = 0;
+        blks[0] = 4;
+
+        for (j = 1; j < NUM_BLOCKS; j++) {
+            disps[j] = 4 * j;
+            blks[j] = (j % 3) + 1;
+        }
+
+        err = MPI_Type_indexed(NUM_BLOCKS, blks, disps, MPI_INT, &mytypes[i]);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Type_indexed returned error on type %d\n", i);
+            }
             mytypes[i] = MPI_DATATYPE_NULL;
             goto fn_exit;
-       }
-       
-       MPI_Type_commit(&mytypes[i]);
+        }
+
+        MPI_Type_commit(&mytypes[i]);
     }
 
-    for (i=0; i < NUM_DTYPES; i++) {
-       int j;
-       int recvbuf[4] = { -1, -1, -1, -1 };
-
-       /* we will only receive 4 ints, so short buffer is ok */
-       err = MPI_Irecv(recvbuf, 1, mytypes[i], 0, 0, MPI_COMM_SELF, &request);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Irecv returned error\n");
-           }
-       }
-       
-       err = MPI_Send(sendbuf, 4, MPI_INT, 0, 0, MPI_COMM_SELF);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Send returned error\n");
-           }
-       }
-       
-       err = MPI_Wait(&request, &status);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Wait returned error\n");
-           }
-       }
-       
-       /* verify data */
-       for (j=0; j < 4; j++) {
-           if (recvbuf[j] != sendbuf[j]) {
-               errs++;
-               if (verbose) {
-                   fprintf(stderr, "recvbuf[%d] = %d; should be %d\n",
-                           j, recvbuf[j], sendbuf[j]);
-               }
-           }
-       }
-
-       /* verify count and elements */
-       err = MPI_Get_count(&status, mytypes[i], &count);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Get_count returned error\n");
-           }
-       }
-       if (count != MPI_UNDEFINED) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n",
-                       count, MPI_UNDEFINED);
-           }
-       }
-       
-       err = MPI_Get_elements(&status, mytypes[i], &elements);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Get_elements returned error\n");
-           }
-       }
-       if (elements != 4) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "elements = %d; should be 4\n", elements);
-           }
-       }
+    for (i = 0; i < NUM_DTYPES; i++) {
+        int j;
+        int recvbuf[4] = { -1, -1, -1, -1 };
+
+        /* we will only receive 4 ints, so short buffer is ok */
+        err = MPI_Irecv(recvbuf, 1, mytypes[i], 0, 0, MPI_COMM_SELF, &request);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Irecv returned error\n");
+            }
+        }
+
+        err = MPI_Send(sendbuf, 4, MPI_INT, 0, 0, MPI_COMM_SELF);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Send returned error\n");
+            }
+        }
+
+        err = MPI_Wait(&request, &status);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Wait returned error\n");
+            }
+        }
+
+        /* verify data */
+        for (j = 0; j < 4; j++) {
+            if (recvbuf[j] != sendbuf[j]) {
+                errs++;
+                if (verbose) {
+                    fprintf(stderr, "recvbuf[%d] = %d; should be %d\n", j, recvbuf[j], sendbuf[j]);
+                }
+            }
+        }
+
+        /* verify count and elements */
+        err = MPI_Get_count(&status, mytypes[i], &count);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Get_count returned error\n");
+            }
+        }
+        if (count != MPI_UNDEFINED) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n", count, MPI_UNDEFINED);
+            }
+        }
+
+        err = MPI_Get_elements(&status, mytypes[i], &elements);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Get_elements returned error\n");
+            }
+        }
+        if (elements != 4) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "elements = %d; should be 4\n", elements);
+            }
+        }
     }
 
- fn_exit:
-    for (i=0; i < NUM_DTYPES; i++) {
 fn_exit:
+    for (i = 0; i < NUM_DTYPES; i++) {
         if (mytypes[i] != MPI_DATATYPE_NULL)
             MPI_Type_free(&mytypes[i]);
     }
@@ -183,18 +182,18 @@ int lots_of_types_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 8086bd5..04199ab 100644 (file)
@@ -17,31 +17,28 @@ int short_int_pack_test(void);
 
 /* helper functions */
 int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
 
 int main(int argc, char *argv[])
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     err = short_int_pack_test();
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -51,39 +48,41 @@ int short_int_pack_test(void)
 {
     int i, err, errs = 0;
 
-    struct shortint { short a; int b; } sibuf[16];
+    struct shortint {
+        short a;
+        int b;
+    } sibuf[16];
 
-    for (i=0; i < 16; i++) {
-       sibuf[i].a = (short) (i * 2);
-       sibuf[i].b = i * 2 + 1;
+    for (i = 0; i < 16; i++) {
+        sibuf[i].a = (short) (i * 2);
+        sibuf[i].b = i * 2 + 1;
     }
 
     err = pack_and_unpack((char *) sibuf, 16, MPI_SHORT_INT, sizeof(sibuf));
     if (err != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error packing/unpacking in short_int_pack_test()\n");
-       }
-       errs += err;
+        if (verbose) {
+            fprintf(stderr, "error packing/unpacking in short_int_pack_test()\n");
+        }
+        errs += err;
     }
 
-    for (i=0; i < 16; i++) {
-       if (sibuf[i].a != (short) (i * 2)) {
-           err++;
-           if (verbose) {
-               fprintf(stderr,
-                       "buf[%d] has invalid short (%d); should be %d\n",
-                       i, (int) sibuf[i].a, i * 2);
-           }
-       }
-       if (sibuf[i].b != i * 2 + 1) {
-           err++;
-           if (verbose) {
-               fprintf(stderr,
-                       "buf[%d] has invalid int (%d); should be %d\n",
-                       i, (int) sibuf[i].b, i * 2 + 1);
-           }
-       }
+    for (i = 0; i < 16; i++) {
+        if (sibuf[i].a != (short) (i * 2)) {
+            err++;
+            if (verbose) {
+                fprintf(stderr,
+                        "buf[%d] has invalid short (%d); should be %d\n",
+                        i, (int) sibuf[i].a, i * 2);
+            }
+        }
+        if (sibuf[i].b != i * 2 + 1) {
+            err++;
+            if (verbose) {
+                fprintf(stderr,
+                        "buf[%d] has invalid int (%d); should be %d\n",
+                        i, (int) sibuf[i].b, i * 2 + 1);
+            }
+        }
     }
 
     return errs;
@@ -104,87 +103,64 @@ int short_int_pack_test(void)
  *             between the pack and unpack steps
  *
  */
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
 {
     char *packbuf;
     int err, errs = 0, pack_size, type_size, position;
 
     err = MPI_Type_size(datatype, &type_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     type_size *= count;
 
     err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Pack_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     packbuf = (char *) malloc(pack_size);
     if (packbuf == NULL) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in malloc call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     position = 0;
-    err = MPI_Pack(typebuf,
-                  count,
-                  datatype,
-                  packbuf,
-                  type_size,
-                  &position,
-                  MPI_COMM_SELF);
+    err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
     }
 
     memset(typebuf, 0, typebufsz);
     position = 0;
-    err = MPI_Unpack(packbuf,
-                    type_size,
-                    &position,
-                    typebuf,
-                    count,
-                    datatype,
-                    MPI_COMM_SELF);
+    err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Unpack call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     free(packbuf);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
     }
 
     return errs;
@@ -193,18 +169,18 @@ static int pack_and_unpack(char *typebuf,
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 1025f83..441661a 100644 (file)
 
 static int verbose = 1;
 
-
+static struct {
+    MPI_Datatype atype, ptype;
+    char name[32];
+} pairtypes[] = { {
+MPI_FLOAT, MPI_FLOAT_INT, "MPI_FLOAT_INT"}, {
+MPI_DOUBLE, MPI_DOUBLE_INT, "MPI_DOUBLE_INT"}, {
+MPI_LONG, MPI_LONG_INT, "MPI_LONG_INT"}, {
+MPI_SHORT, MPI_SHORT_INT, "MPI_SHORT_INT"}, {
+MPI_LONG_DOUBLE, MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT"}, {
+(MPI_Datatype) - 1, (MPI_Datatype) - 1, "end"}
+};
 
 int parse_args(int argc, char **argv);
 
@@ -23,110 +33,116 @@ MPI_Aint pairtype_displacement(MPI_Datatype type, int *out_size_p)
 {
     MPI_Aint disp;
 
-    /* Note that a portable test may not use a switch statement for 
-       datatypes, as they are not required to be compile-time constants */
+    /* Note that a portable test may not use a switch statement for
+     * datatypes, as they are not required to be compile-time constants */
     if (type == MPI_FLOAT_INT) {
-       struct { float a; int b; } foo;
-       disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
-       *out_size_p = sizeof(foo);
+        struct {
+            float a;
+            int b;
+        } foo;
+        disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+        *out_size_p = sizeof(foo);
     }
     else if (type == MPI_DOUBLE_INT) {
-       struct { double a; int b; } foo;
-       disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
-       *out_size_p = sizeof(foo);
+        struct {
+            double a;
+            int b;
+        } foo;
+        disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+        *out_size_p = sizeof(foo);
     }
     else if (type == MPI_LONG_INT) {
-       struct { long a; int b; } foo;
-       disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
-       *out_size_p = sizeof(foo);
+        struct {
+            long a;
+            int b;
+        } foo;
+        disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+        *out_size_p = sizeof(foo);
     }
     else if (type == MPI_SHORT_INT) {
-       struct { short a; int b; } foo;
-       disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
-       *out_size_p = sizeof(foo);
+        struct {
+            short a;
+            int b;
+        } foo;
+        disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+        *out_size_p = sizeof(foo);
     }
     else if (type == MPI_LONG_DOUBLE_INT && type != MPI_DATATYPE_NULL) {
-       struct { long double a; int b; } foo;
-       disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
-       *out_size_p = sizeof(foo);
+        struct {
+            long double a;
+            int b;
+        } foo;
+        disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+        *out_size_p = sizeof(foo);
     }
     else {
-       disp = -1;
+        disp = -1;
     }
     return disp;
 }
 
 int main(int argc, char *argv[])
 {
-
-struct { MPI_Datatype atype, ptype; char name[32]; }
-pairtypes[] =
-    { {MPI_FLOAT, MPI_FLOAT_INT, "MPI_FLOAT_INT"},
-      {MPI_DOUBLE, MPI_DOUBLE_INT, "MPI_DOUBLE_INT"},
-      {MPI_LONG, MPI_LONG_INT, "MPI_LONG_INT"},
-      {MPI_SHORT, MPI_SHORT_INT, "MPI_SHORT_INT"},
-      {MPI_LONG_DOUBLE, MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT"},
-      {(MPI_Datatype) -1, (MPI_Datatype) -1, "end"}
-    };
     int errs = 0;
 
     int i;
-    int blks[2] = {1, 1};
-    MPI_Aint disps[2] = {0, 0};
-    MPI_Datatype types[2] = {MPI_INT, MPI_INT};
+    int blks[2] = { 1, 1 };
+    MPI_Aint disps[2] = { 0, 0 };
+    MPI_Datatype types[2] = { MPI_INT, MPI_INT };
     MPI_Datatype stype;
-    
+
     MPI_Init(&argc, &argv);
     parse_args(argc, argv);
 
-    for (i=0; pairtypes[i].atype != (MPI_Datatype) -1; i++) {
-       int atype_size, ptype_size, stype_size, handbuilt_extent;
-       MPI_Aint ptype_extent, stype_extent, dummy_lb;
-
-       types[0] = pairtypes[i].atype;
-
-       /* Check for undefined optional types, such as
-          LONG_DOUBLE_INT (if, for example, long double or
-          long long are not supported) */
-       if (types[0] == MPI_DATATYPE_NULL) continue;
-
-       MPI_Type_size(types[0], &atype_size);
-       disps[1] = pairtype_displacement(pairtypes[i].ptype,
-                                        &handbuilt_extent);
-
-       MPI_Type_create_struct(2, blks, disps, types, &stype);
-
-       MPI_Type_size(stype, &stype_size);
-       MPI_Type_size(pairtypes[i].ptype, &ptype_size);
-       if (stype_size != ptype_size) {
-           errs++;
-
-           if (verbose) fprintf(stderr,
-                                "size of %s (%d) does not match size of hand-built MPI struct (%d)\n",
-                                pairtypes[i].name, ptype_size, stype_size);
-       }
-
-       MPI_Type_get_extent(stype, &dummy_lb, &stype_extent);
-       MPI_Type_get_extent(pairtypes[i].ptype, &dummy_lb, &ptype_extent);
-       if (stype_extent != ptype_extent || stype_extent != handbuilt_extent) {
-           errs++;
-
-           if (verbose) fprintf(stderr,
-                                "extent of %s (%d) does not match extent of either hand-built MPI struct (%d) or equivalent C struct (%d)\n",
-                                pairtypes[i].name, (int) ptype_extent,
-                                (int) stype_extent,
-                                handbuilt_extent);
-       }
-       MPI_Type_free( &stype );
+    for (i = 0; pairtypes[i].atype != (MPI_Datatype) - 1; i++) {
+        int atype_size, ptype_size, stype_size, handbuilt_extent;
+        MPI_Aint ptype_extent, stype_extent, dummy_lb;
+
+        types[0] = pairtypes[i].atype;
+
+        /* Check for undefined optional types, such as
+         * LONG_DOUBLE_INT (if, for example, long double or
+         * long long are not supported) */
+        if (types[0] == MPI_DATATYPE_NULL)
+            continue;
+
+        MPI_Type_size(types[0], &atype_size);
+        disps[1] = pairtype_displacement(pairtypes[i].ptype, &handbuilt_extent);
+
+        MPI_Type_create_struct(2, blks, disps, types, &stype);
+
+        MPI_Type_size(stype, &stype_size);
+        MPI_Type_size(pairtypes[i].ptype, &ptype_size);
+        if (stype_size != ptype_size) {
+            errs++;
+
+            if (verbose)
+                fprintf(stderr,
+                        "size of %s (%d) does not match size of hand-built MPI struct (%d)\n",
+                        pairtypes[i].name, ptype_size, stype_size);
+        }
+
+        MPI_Type_get_extent(stype, &dummy_lb, &stype_extent);
+        MPI_Type_get_extent(pairtypes[i].ptype, &dummy_lb, &ptype_extent);
+        if (stype_extent != ptype_extent || stype_extent != handbuilt_extent) {
+            errs++;
+
+            if (verbose)
+                fprintf(stderr,
+                        "extent of %s (%d) does not match extent of either hand-built MPI struct (%d) or equivalent C struct (%d)\n",
+                        pairtypes[i].name, (int) ptype_extent,
+                        (int) stype_extent, handbuilt_extent);
+        }
+        MPI_Type_free(&stype);
     }
-    
+
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -136,8 +152,8 @@ int parse_args(int argc, char **argv)
 {
     /* We use a simple test because getopt isn't universally available */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     if (argc > 1 && strcmp(argv[1], "-nov") == 0)
-       verbose = 0;
+        verbose = 0;
     return 0;
 }
index 78ad55a..504aa13 100644 (file)
@@ -7,11 +7,11 @@
 #include "mpiimpl.h"
 #include <stdio.h>
 
-/* 
+/*
  * Simple segment test, including timing code
  */
 
-/* 
+/*
  * Build datatype structures
  *
  * Contiguous
  *     offsets   = i*24 for i = 0 to n, n = 0, 64, 512
  * Indexed
  *     blocksizes = 1, 2, 4, 3, 7, 5, 6
- *     offsets    = i*24 for i = 0 to n, n = 0, 4, 7, 64, 512 
+ *     offsets    = i*24 for i = 0 to n, n = 0, 4, 7, 64, 512
  *     (Wrap blocksizes to match offsets)
  *
  * Also need a few nested datatypes, such as vector of vectors
  * Do the versions in Using MPI
- * 
+ *
  */
 
 /*
 /*
  *  Contig
  */
-MPID_Dataloop *MPID_Dataloop_init_contig( int count )
+MPID_Dataloop *MPID_Dataloop_init_contig(int count)
 {
     MPID_Dataloop *ct;
-    
-    ct = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop ) );
-    ct->kind                     = MPID_DTYPE_CONTIG | DATALOOP_FINAL_MASK;
-    ct->loop_params.c_t.count    = count;
+
+    ct = (MPID_Dataloop *) MPL_malloc(sizeof(MPID_Dataloop));
+    ct->kind = MPID_DTYPE_CONTIG | DATALOOP_FINAL_MASK;
+    ct->loop_params.c_t.count = count;
     ct->loop_params.c_t.dataloop = 0;
-    ct->extent                   = count;
-    ct->handle                       = 0;
+    ct->extent = count;
+    ct->handle = 0;
 
     return ct;
 }
@@ -55,155 +55,149 @@ MPID_Dataloop *MPID_Dataloop_init_contig( int count )
 /*
  * Vector
  */
-MPID_Dataloop *MPID_Dataloop_init_vector( int count, int blocksize, 
-                                         int stride )
+MPID_Dataloop *MPID_Dataloop_init_vector(int count, int blocksize, int stride)
 {
     MPID_Dataloop *v;
 
-    v = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop) );
-    v->kind                      = MPID_DTYPE_VECTOR | DATALOOP_FINAL_MASK;
-    v->loop_params.v_t.count     = count;
+    v = (MPID_Dataloop *) MPL_malloc(sizeof(MPID_Dataloop));
+    v->kind = MPID_DTYPE_VECTOR | DATALOOP_FINAL_MASK;
+    v->loop_params.v_t.count = count;
     v->loop_params.v_t.blocksize = blocksize;
-    v->loop_params.v_t.stride    = stride;
-    v->loop_params.v_t.dataloop  = 0;
-    v->extent                    = (count-1)*stride + blocksize;
-    v->handle                        = 0;
+    v->loop_params.v_t.stride = stride;
+    v->loop_params.v_t.dataloop = 0;
+    v->extent = (count - 1) * stride + blocksize;
+    v->handle = 0;
 
     return v;
 }
 
-/* 
+/*
  * Block indexed
  */
-MPID_Dataloop *MPID_Dataloop_init_blockindexed( int count, int blocksize, 
-                                               MPI_Aint *offset )
+MPID_Dataloop *MPID_Dataloop_init_blockindexed(int count, int blocksize, MPI_Aint * offset)
 {
     MPID_Dataloop *bi;
-    MPI_Aint      extent;
-    int           i;
+    MPI_Aint extent;
+    int i;
 
-    bi = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop) );
-    bi->kind                       = MPID_DTYPE_BLOCKINDEXED | DATALOOP_FINAL_MASK;
-    bi->loop_params.bi_t.count     = count;
+    bi = (MPID_Dataloop *) MPL_malloc(sizeof(MPID_Dataloop));
+    bi->kind = MPID_DTYPE_BLOCKINDEXED | DATALOOP_FINAL_MASK;
+    bi->loop_params.bi_t.count = count;
     bi->loop_params.bi_t.blocksize = blocksize;
-    bi->loop_params.bi_t.offset    = 
-       (MPI_Aint *)MPIU_Malloc( sizeof(MPI_Aint) * count );
-    for (i=0; i<count; i++) {
-       bi->loop_params.bi_t.offset[i] = offset[i];
-       if (offset[i] + blocksize > extent) 
-           extent = offset[i] + blocksize;
+    bi->loop_params.bi_t.offset = (MPI_Aint *) MPL_malloc(sizeof(MPI_Aint) * count);
+    for (i = 0; i < count; i++) {
+        bi->loop_params.bi_t.offset[i] = offset[i];
+        if (offset[i] + blocksize > extent)
+            extent = offset[i] + blocksize;
     }
-    bi->loop_params.bi_t.dataloop  = 0;
-    bi->extent                     = extent;
-    bi->handle                         = 0;
+    bi->loop_params.bi_t.dataloop = 0;
+    bi->extent = extent;
+    bi->handle = 0;
 
     return bi;
 }
 
 /*
- * Indexed 
+ * Indexed
  */
-MPID_Dataloop *MPID_Dataloop_init_indexed( int count, int *blocksize, 
-                                          MPI_Aint *offset )
+MPID_Dataloop *MPID_Dataloop_init_indexed(int count, int *blocksize, MPI_Aint * offset)
 {
     MPID_Dataloop *it;
-    MPI_Aint      extent = 0;
-    int           i;
-
-    it = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop) );
-    it->kind                      = MPID_DTYPE_INDEXED | DATALOOP_FINAL_MASK;
-    it->loop_params.i_t.count     = count;
-    it->loop_params.i_t.blocksize = (int *)MPIU_Malloc( sizeof(int) * count );
-    it->loop_params.i_t.offset    = 
-       (MPI_Aint *)MPIU_Malloc( sizeof(MPI_Aint) * count );
-    for (i=0; i<count; i++) {
-       it->loop_params.i_t.offset[i]    = offset[i];
-       it->loop_params.i_t.blocksize[i] = blocksize[i];
-       if (offset[i] + blocksize[i] > extent) 
-           extent = offset[i] + blocksize[i];
+    MPI_Aint extent = 0;
+    int i;
+
+    it = (MPID_Dataloop *) MPL_malloc(sizeof(MPID_Dataloop));
+    it->kind = MPID_DTYPE_INDEXED | DATALOOP_FINAL_MASK;
+    it->loop_params.i_t.count = count;
+    it->loop_params.i_t.blocksize = (int *) MPL_malloc(sizeof(int) * count);
+    it->loop_params.i_t.offset = (MPI_Aint *) MPL_malloc(sizeof(MPI_Aint) * count);
+    for (i = 0; i < count; i++) {
+        it->loop_params.i_t.offset[i] = offset[i];
+        it->loop_params.i_t.blocksize[i] = blocksize[i];
+        if (offset[i] + blocksize[i] > extent)
+            extent = offset[i] + blocksize[i];
     }
-    it->loop_params.i_t.dataloop  = 0;
-    it->extent                    = extent;
-    it->handle                        = 0;
+    it->loop_params.i_t.dataloop = 0;
+    it->extent = extent;
+    it->handle = 0;
 
     return it;
 }
 
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
     /* MPID_Dataloop *vecloop; */
     MPI_Datatype vectype;
-    int count=200, blocksize=4, stride = 7*4;
+    int count = 200, blocksize = 4, stride = 7 * 4;
     char *src_buf, *dest_buf;
-    int  i,j,k;
+    int i, j, k;
     double r1, r2;
 
-    MPI_Init( &argc, &argv );
-    
-/*    vecloop = MPID_Dataloop_init_vector( count, blocksize, stride ); */
+    MPI_Init(&argc, &argv);
 
-    MPI_Type_vector( count, 1, 7, MPI_INT, &vectype );
+/*    vecloop = MPID_Dataloop_init_vector(count, blocksize, stride); */
+
+    MPI_Type_vector(count, 1, 7, MPI_INT, &vectype);
 
     /* Initialize the data */
-    src_buf = (char *)MPIU_Malloc( (count - 1) * stride + blocksize );
-    for (i=0; i<(count-1)*stride+blocksize; i++) 
-       src_buf[i] = -i;
-    for (i=0; i<count; i++) {
-       for (j=0; j<blocksize; j++) 
-           src_buf[i*stride+j] = i*blocksize + j;
+    src_buf = (char *) MPL_malloc((count - 1) * stride + blocksize);
+    for (i = 0; i < (count - 1) * stride + blocksize; i++)
+        src_buf[i] = -i;
+    for (i = 0; i < count; i++) {
+        for (j = 0; j < blocksize; j++)
+            src_buf[i * stride + j] = i * blocksize + j;
     }
-    dest_buf = (char *)MPIU_Malloc( count*blocksize );
-    for (i=0; i<count*blocksize; i++) {
-       dest_buf[i] = -i;
+    dest_buf = (char *) MPL_malloc(count * blocksize);
+    for (i = 0; i < count * blocksize; i++) {
+        dest_buf[i] = -i;
     }
     r1 = MPI_Wtime();
-    for (i=0; i<100; i++) {
-       int position = 0;
-       /*MPID_Segment_pack( vecloop, src_buf, dest_buf );*/
-       MPI_Pack( src_buf, count, vectype, dest_buf, count*blocksize, 
-                 &position, MPI_COMM_WORLD );
+    for (i = 0; i < 100; i++) {
+        int position = 0;
+        /*MPID_Segment_pack(vecloop, src_buf, dest_buf); */
+        MPI_Pack(src_buf, count, vectype, dest_buf, count * blocksize, &position, MPI_COMM_WORLD);
     }
     r2 = MPI_Wtime();
-    printf( "Timer for vector pack is %e\n", (r2-r1)/100 );
-    for (i=0; i<count*blocksize; i++) {
-       if (dest_buf[i] != (char)i) { 
-           printf( "Error at location %d\n", i );
-       }
+    printf("Timer for vector pack is %e\n", (r2 - r1) / 100);
+    for (i = 0; i < count * blocksize; i++) {
+        if (dest_buf[i] != (char) i) {
+            printf("Error at location %d\n", i);
+        }
     }
     r1 = MPI_Wtime();
-    for (k=0; k<100; k++) {
-       char *dest=dest_buf, *src=src_buf;
-       for (i=0; i<count; i++) {
-           for (j=0; j<blocksize; j++) 
-               *dest++ = src[j];
-           src+= stride;
-       }
+    for (k = 0; k < 100; k++) {
+        char *dest = dest_buf, *src = src_buf;
+        for (i = 0; i < count; i++) {
+            for (j = 0; j < blocksize; j++)
+                *dest++ = src[j];
+            src += stride;
+        }
     }
     r2 = MPI_Wtime();
-    printf( "Timer for hand vector pack is %e\n", (r2-r1)/100 );
+    printf("Timer for hand vector pack is %e\n", (r2 - r1) / 100);
 
     r1 = MPI_Wtime();
-    for (k=0; k<100; k++) {
-       int *dest=(int*)dest_buf, *src=(int*)src_buf;
-       int bsize = blocksize >> 2;
-       int istride = stride >> 2;
-       if (bsize == 1) { 
-           for (i=0; i<count; i++) {
-               *dest++ = *src;
-               src+= istride;
-           }
-       }
-       else {
-           for (i=0; i<count; i++) {
-               for (j=0; j<bsize; j++) 
-                   *dest++ = src[j];
-               src+= istride;
-           }
-       }
+    for (k = 0; k < 100; k++) {
+        int *dest = (int *) dest_buf, *src = (int *) src_buf;
+        int bsize = blocksize >> 2;
+        int istride = stride >> 2;
+        if (bsize == 1) {
+            for (i = 0; i < count; i++) {
+                *dest++ = *src;
+                src += istride;
+            }
+        }
+        else {
+            for (i = 0; i < count; i++) {
+                for (j = 0; j < bsize; j++)
+                    *dest++ = src[j];
+                src += istride;
+            }
+        }
     }
     r2 = MPI_Wtime();
-    printf( "Timer for hand vector pack (int) is %e\n", (r2-r1)/100 );
-    
+    printf("Timer for hand vector pack (int) is %e\n", (r2 - r1) / 100);
+
     MPI_Finalize();
     return 0;
 }
@@ -211,7 +205,7 @@ int main( int argc, char **argv )
 /*
  * Nested vector.
  *   The y-z subface is
- *   Type_vector( ey-sy+1, 1, nx, MPI_DOUBLE, &newx1 );
- *   Type_hvector( ez-sz+1, 1, nx*ny_sizeof(double), newx1, &newx );
+ *   Type_vector(ey-sy+1, 1, nx, MPI_DOUBLE, &newx1);
+ *   Type_hvector(ez-sz+1, 1, nx*ny_sizeof(double), newx1, &newx);
  * This gives the a(i,sy:ey,sz:ez) of a(nx,ny,nz) (in Fortran notation)
  */
index 6d7bc4c..14c5725 100644 (file)
    This program is derived from one in the MPICH-1 test suite.  It
    tests a wide variety of basic and derived datatypes.
  */
-int main( int argc, char **argv)
+int main(int argc, char **argv)
 {
     MPI_Datatype *types;
-    void         **inbufs, **outbufs;
-    int          *counts, *bytesize, ntype;
-    MPI_Comm     comm;
-    int          rank, np, partner, tag, count;
-    int          i, j, k, err, world_rank, errloc;
-    MPI_Status   status;
-    char         *obuf;
-    char         myname[MPI_MAX_OBJECT_NAME];
-    int          mynamelen;
+    void **inbufs, **outbufs;
+    int *counts, *bytesize, ntype;
+    MPI_Comm comm;
+    int rank, np, partner, tag, count;
+    int i, j, k, err, world_rank, errloc;
+    MPI_Status status;
+    char *obuf;
+    char myname[MPI_MAX_OBJECT_NAME];
+    int mynamelen;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     /*
      * Check for -basiconly to select only the simple datatypes
      */
-    for (i=1; i<argc; i++) {
-       if (!argv[i]) break;
-       if (strcmp( argv[i], "-basiconly" ) == 0) {
-           MTestDatatype2BasicOnly();
-       }
+    for (i = 1; i < argc; i++) {
+        if (!argv[i])
+            break;
+        if (strcmp(argv[i], "-basiconly") == 0) {
+            MTestDatatype2BasicOnly();
+        }
     }
 
-    MTestDatatype2Allocate( &types, &inbufs, &outbufs, &counts, &bytesize,
-                           &ntype );
-    MTestDatatype2Generate( types, inbufs, outbufs, counts, bytesize, &ntype );
+    MTestDatatype2Allocate(&types, &inbufs, &outbufs, &counts, &bytesize, &ntype);
+    MTestDatatype2Generate(types, inbufs, outbufs, counts, bytesize, &ntype);
 
-    MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
+    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
 
- /* Test over a wide range of datatypes and communicators */
   /* Test over a wide range of datatypes and communicators */
     err = 0;
     tag = 0;
-    while (MTestGetIntracomm( &comm, 2 )) {
-       if (comm == MPI_COMM_NULL) continue;
-       MPI_Comm_rank( comm, &rank );
-       MPI_Comm_size( comm, &np );
-       if (np < 2) continue;
-       if (world_rank == 0)
-           MTestPrintfMsg( 10, "Testing communicator number %s\n",
-                           MTestGetIntracommName() );
+    while (MTestGetIntracomm(&comm, 2)) {
+        if (comm == MPI_COMM_NULL)
+            continue;
+        MPI_Comm_rank(comm, &rank);
+        MPI_Comm_size(comm, &np);
+        if (np < 2)
+            continue;
+        if (world_rank == 0)
+            MTestPrintfMsg(10, "Testing communicator number %s\n", MTestGetIntracommName());
 
-       tag++;
-       for (j=0; j<ntype; j++) {
-           MPI_Type_get_name( types[j], myname, &mynamelen );
-           if (world_rank == 0)
-               MTestPrintfMsg( 10, "Testing type %s\n", myname );
-           if (rank == 0) {
-               partner = np - 1;
-               MPI_Send( inbufs[j], counts[j], types[j], partner, tag, comm );
+        tag++;
+        for (j = 0; j < ntype; j++) {
+            MPI_Type_get_name(types[j], myname, &mynamelen);
+            if (world_rank == 0)
+                MTestPrintfMsg(10, "Testing type %s\n", myname);
+            if (rank == 0) {
+                partner = np - 1;
+                MPI_Send(inbufs[j], counts[j], types[j], partner, tag, comm);
             }
-           else if (rank == np-1) {
-               partner = 0;
-               obuf = outbufs[j];
-               for (k=0; k<bytesize[j]; k++)
-                   obuf[k] = 0;
-               MPI_Recv( outbufs[j], counts[j], types[j], partner, tag,
-                         comm, &status );
-               /* Test correct */
-               MPI_Get_count( &status, types[j], &count );
-               if (count != counts[j]) {
-                   fprintf( stderr,
-                    "Error in counts (got %d expected %d) with type %s\n",
-                        count, counts[j], myname );
-                   err++;
+            else if (rank == np - 1) {
+                partner = 0;
+                obuf = outbufs[j];
+                for (k = 0; k < bytesize[j]; k++)
+                    obuf[k] = 0;
+                MPI_Recv(outbufs[j], counts[j], types[j], partner, tag, comm, &status);
+                /* Test correct */
+                MPI_Get_count(&status, types[j], &count);
+                if (count != counts[j]) {
+                    fprintf(stderr,
+                            "Error in counts (got %d expected %d) with type %s\n",
+                            count, counts[j], myname);
+                    err++;
                 }
-               if (status.MPI_SOURCE != partner) {
-                   fprintf( stderr,
-                       "Error in source (got %d expected %d) with type %s\n",
-                        status.MPI_SOURCE, partner, myname );
-                   err++;
+                if (status.MPI_SOURCE != partner) {
+                    fprintf(stderr,
+                            "Error in source (got %d expected %d) with type %s\n",
+                            status.MPI_SOURCE, partner, myname);
+                    err++;
                 }
-               if ((errloc = MTestDatatype2Check( inbufs[j], outbufs[j],
-                                                  bytesize[j] ))) {
-                   char *p1, *p2;
-                   fprintf( stderr,
-                   "Error in data with type %s (type %d on %d) at byte %d\n",
-                            myname, j, world_rank, errloc - 1 );
-                   p1 = (char *)inbufs[j];
-                   p2 = (char *)outbufs[j];
-                   fprintf( stderr,
-                       "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
-                   err++;
+                if ((errloc = MTestDatatype2Check(inbufs[j], outbufs[j], bytesize[j]))) {
+                    char *p1, *p2;
+                    fprintf(stderr,
+                            "Error in data with type %s (type %d on %d) at byte %d\n",
+                            myname, j, world_rank, errloc - 1);
+                    p1 = (char *) inbufs[j];
+                    p2 = (char *) outbufs[j];
+                    fprintf(stderr, "Got %x expected %x\n", p1[errloc - 1], p2[errloc - 1]);
+                    err++;
                 }
             }
-       }
-       MTestFreeComm( &comm );
+        }
+        MTestFreeComm(&comm);
     }
 
-    MTestDatatype2Free( types, inbufs, outbufs, counts, bytesize, ntype );
-    MTest_Finalize( err );
+    MTestDatatype2Free(types, inbufs, outbufs, counts, bytesize, ntype);
+    MTest_Finalize(err);
     MPI_Finalize();
-    return MTestReturnValue( err );
+    return MTestReturnValue(err);
 }
index d1ff29d..bd3338d 100644 (file)
    This version sends and receives EVERYTHING from MPI_BOTTOM, by putting
    the data into a structure.
  */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
     MPI_Datatype *types;
-    void         **inbufs, **outbufs;
-    int          *counts, *bytesize, ntype;
-    MPI_Comm     comm;
-    int          rank, np, partner, tag, count;
-    int          j, k, err, world_rank, errloc;
-    MPI_Status   status;
-    char         *obuf;
+    void **inbufs, **outbufs;
+    int *counts, *bytesize, ntype;
+    MPI_Comm comm;
+    int rank, np, partner, tag, count;
+    int j, k, err, world_rank, errloc;
+    MPI_Status status;
+    char *obuf;
     MPI_Datatype offsettype;
-    int          blen;
-    MPI_Aint     displ, extent, natural_extent;
-    char         myname[MPI_MAX_OBJECT_NAME];
-    int          mynamelen;
+    int blen;
+    MPI_Aint displ, extent, natural_extent;
+    char myname[MPI_MAX_OBJECT_NAME];
+    int mynamelen;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
-    MTestDatatype2Allocate( &types, &inbufs, &outbufs, &counts, &bytesize,
-                           &ntype );
-    MTestDatatype2Generate( types, inbufs, outbufs, counts, bytesize, &ntype );
+    MTestDatatype2Allocate(&types, &inbufs, &outbufs, &counts, &bytesize, &ntype);
+    MTestDatatype2Generate(types, inbufs, outbufs, counts, bytesize, &ntype);
 
-    MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
+    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
 
     /* Test over a wide range of datatypes and communicators */
     err = 0;
     tag = 0;
-    while (MTestGetIntracomm( &comm, 2 )) {
-       if (comm == MPI_COMM_NULL) continue;
-       MPI_Comm_rank( comm, &rank );
-       MPI_Comm_size( comm, &np );
-       if (np < 2) continue;
-       tag++;
-       for (j=0; j<ntype; j++) {
-           MPI_Type_get_name( types[j], myname, &mynamelen );
-           if (world_rank == 0)
-               MTestPrintfMsg( 10, "Testing type %s\n", myname );
-           if (rank == 0) {
-               MPI_Get_address( inbufs[j], &displ );
-               blen = 1;
-               MPI_Type_create_struct( 1, &blen, &displ, types + j,
-                                       &offsettype );
-               MPI_Type_commit( &offsettype );
-               /* Warning: if the type has an explicit MPI_UB, then using a
-                  simple shift of the offset won't work.  For now, we skip
-                  types whose extents are negative; the correct solution is
-                  to add, where required, an explicit MPI_UB */
-               MPI_Type_extent( offsettype, &extent );
-               if (extent < 0) {
-                   if (world_rank == 0)
-                       MTestPrintfMsg( 10,
-                       "... skipping (appears to have explicit MPI_UB\n" );
-                   MPI_Type_free( &offsettype );
-                   continue;
-               }
-               MPI_Type_extent( types[j], &natural_extent );
-               if (natural_extent != extent) {
-                   MPI_Type_free( &offsettype );
-                   continue;
-               }
-               partner = np - 1;
-               MPI_Send( MPI_BOTTOM, counts[j], offsettype, partner, tag,
-                         comm );
-               MPI_Type_free( &offsettype );
+    while (MTestGetIntracomm(&comm, 2)) {
+        if (comm == MPI_COMM_NULL)
+            continue;
+        MPI_Comm_rank(comm, &rank);
+        MPI_Comm_size(comm, &np);
+        if (np < 2)
+            continue;
+        tag++;
+        for (j = 0; j < ntype; j++) {
+            MPI_Type_get_name(types[j], myname, &mynamelen);
+            if (world_rank == 0)
+                MTestPrintfMsg(10, "Testing type %s\n", myname);
+            if (rank == 0) {
+                MPI_Get_address(inbufs[j], &displ);
+                blen = 1;
+                MPI_Type_create_struct(1, &blen, &displ, types + j, &offsettype);
+                MPI_Type_commit(&offsettype);
+                /* Warning: if the type has an explicit MPI_UB, then using a
+                 * simple shift of the offset won't work.  For now, we skip
+                 * types whose extents are negative; the correct solution is
+                 * to add, where required, an explicit MPI_UB */
+                MPI_Type_extent(offsettype, &extent);
+                if (extent < 0) {
+                    if (world_rank == 0)
+                        MTestPrintfMsg(10, "... skipping (appears to have explicit MPI_UB\n");
+                    MPI_Type_free(&offsettype);
+                    continue;
+                }
+                MPI_Type_extent(types[j], &natural_extent);
+                if (natural_extent != extent) {
+                    MPI_Type_free(&offsettype);
+                    continue;
+                }
+                partner = np - 1;
+                MPI_Send(MPI_BOTTOM, counts[j], offsettype, partner, tag, comm);
+                MPI_Type_free(&offsettype);
             }
-           else if (rank == np-1) {
-               partner = 0;
-               obuf = outbufs[j];
-               for (k=0; k<bytesize[j]; k++)
-                   obuf[k] = 0;
-               MPI_Get_address( outbufs[j], &displ );
-               blen = 1;
-               MPI_Type_create_struct( 1, &blen, &displ, types + j,
-                                       &offsettype );
-               MPI_Type_commit( &offsettype );
-               /* Warning: if the type has an explicit MPI_UB, then using a
-                  simple shift of the offset won't work.  For now, we skip
-                  types whose extents are negative; the correct solution is
-                  to add, where required, an explicit MPI_UB */
-               MPI_Type_extent( offsettype, &extent );
-               if (extent < 0) {
-                   MPI_Type_free( &offsettype );
-                   continue;
-               }
-               MPI_Type_extent( types[j], &natural_extent );
-               if (natural_extent != extent) {
-                   MPI_Type_free( &offsettype );
-                   continue;
-               }
-               MPI_Recv( MPI_BOTTOM, counts[j], offsettype,
-                         partner, tag, comm, &status );
-               /* Test for correctness */
-               MPI_Get_count( &status, types[j], &count );
-               if (count != counts[j]) {
-                   fprintf( stderr,
-                       "Error in counts (got %d expected %d) with type %s\n",
-                        count, counts[j], myname );
-                   err++;
+            else if (rank == np - 1) {
+                partner = 0;
+                obuf = outbufs[j];
+                for (k = 0; k < bytesize[j]; k++)
+                    obuf[k] = 0;
+                MPI_Get_address(outbufs[j], &displ);
+                blen = 1;
+                MPI_Type_create_struct(1, &blen, &displ, types + j, &offsettype);
+                MPI_Type_commit(&offsettype);
+                /* Warning: if the type has an explicit MPI_UB, then using a
+                 * simple shift of the offset won't work.  For now, we skip
+                 * types whose extents are negative; the correct solution is
+                 * to add, where required, an explicit MPI_UB */
+                MPI_Type_extent(offsettype, &extent);
+                if (extent < 0) {
+                    MPI_Type_free(&offsettype);
+                    continue;
+                }
+                MPI_Type_extent(types[j], &natural_extent);
+                if (natural_extent != extent) {
+                    MPI_Type_free(&offsettype);
+                    continue;
+                }
+                MPI_Recv(MPI_BOTTOM, counts[j], offsettype, partner, tag, comm, &status);
+                /* Test for correctness */
+                MPI_Get_count(&status, types[j], &count);
+                if (count != counts[j]) {
+                    fprintf(stderr,
+                            "Error in counts (got %d expected %d) with type %s\n",
+                            count, counts[j], myname);
+                    err++;
                 }
-               if (status.MPI_SOURCE != partner) {
-                   fprintf( stderr,
-                       "Error in source (got %d expected %d) with type %s\n",
-                        status.MPI_SOURCE, partner, myname );
-                   err++;
+                if (status.MPI_SOURCE != partner) {
+                    fprintf(stderr,
+                            "Error in source (got %d expected %d) with type %s\n",
+                            status.MPI_SOURCE, partner, myname);
+                    err++;
                 }
-               if ((errloc = MTestDatatype2Check( inbufs[j], outbufs[j],
-                                                  bytesize[j] ))) {
-                   fprintf( stderr,
-                  "Error in data with type %s (type %d on %d) at byte %d\n",
-                        myname, j, world_rank, errloc - 1 );
-                   if (err < 10) {
-                       /* Give details on only the first 10 errors */
-                       unsigned char *in_p = (unsigned char *)inbufs[j],
-                           *out_p = (unsigned char *)outbufs[j];
-                       int jj;
-                       jj = errloc - 1;
-                       jj &= 0xfffffffc; /* lop off a few bits */
-                       in_p += jj;
-                       out_p += jj;
-                       fprintf( stderr, "%02x%02x%02x%02x should be %02x%02x%02x%02x\n",
-                                out_p[0], out_p[1], out_p[2], out_p[3],
-                                in_p[0], in_p[1], in_p[2], in_p[3] );
-                   }
-                   err++;
+                if ((errloc = MTestDatatype2Check(inbufs[j], outbufs[j], bytesize[j]))) {
+                    fprintf(stderr,
+                            "Error in data with type %s (type %d on %d) at byte %d\n",
+                            myname, j, world_rank, errloc - 1);
+                    if (err < 10) {
+                        /* Give details on only the first 10 errors */
+                        unsigned char *in_p = (unsigned char *) inbufs[j],
+                            *out_p = (unsigned char *) outbufs[j];
+                        int jj;
+                        jj = errloc - 1;
+                        jj &= 0xfffffffc;       /* lop off a few bits */
+                        in_p += jj;
+                        out_p += jj;
+                        fprintf(stderr, "%02x%02x%02x%02x should be %02x%02x%02x%02x\n",
+                                out_p[0], out_p[1], out_p[2], out_p[3],
+                                in_p[0], in_p[1], in_p[2], in_p[3]);
+                    }
+                    err++;
                 }
-               MPI_Type_free( &offsettype );
+                MPI_Type_free(&offsettype);
             }
-       }
-       MTestFreeComm( &comm );
+        }
+        MTestFreeComm(&comm);
     }
 
-    MTestDatatype2Free( types, inbufs, outbufs, counts, bytesize, ntype );
-    MTest_Finalize( err );
+    MTestDatatype2Free(types, inbufs, outbufs, counts, bytesize, ntype);
+    MTest_Finalize(err);
     MPI_Finalize();
-    return MTestReturnValue( err );
+    return MTestReturnValue(err);
 }
index 2caa4e8..af79be3 100644 (file)
@@ -26,33 +26,33 @@ int main(int argc, char **argv)
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     type = MPI_INT;
     mpi_err = MPI_Type_commit(&type);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_commit of MPI_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_commit of MPI_INT failed.\n");
+        }
+        errs++;
     }
 
     type = MPI_FLOAT_INT;
     mpi_err = MPI_Type_commit(&type);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_commit of MPI_FLOAT_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_commit of MPI_FLOAT_INT failed.\n");
+        }
+        errs++;
     }
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -61,18 +61,18 @@ int main(int argc, char **argv)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 6465944..73cce40 100644 (file)
@@ -29,31 +29,31 @@ int main(int argc, char **argv)
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = builtin_float_test();
-    if (err && verbose) fprintf(stderr, "%d errors in builtin float test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in builtin float test.\n", err);
     errs += err;
 
     err = vector_of_vectors_test();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in vector of vectors test.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in vector of vectors test.\n", err);
     errs += err;
 
     err = optimizable_vector_of_basics_test();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in vector of basics test.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in vector of basics test.\n", err);
     errs += err;
 
     err = struct_of_basics_test();
-    if (err && verbose) fprintf(stderr, 
-                               "%d errors in struct of basics test.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in struct of basics test.\n", err);
     errs += err;
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
@@ -68,15 +68,12 @@ int builtin_float_test(void)
 {
     int nints, nadds, ntypes, combiner;
 
-    int /* err, */ errs = 0;
+    int err, errs = 0;
+
+    err = MPI_Type_get_envelope(MPI_FLOAT, &nints, &nadds, &ntypes, &combiner);
 
-    /* err = */ MPI_Type_get_envelope(MPI_FLOAT,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
-    
-    if (combiner != MPI_COMBINER_NAMED) errs++;
+    if (combiner != MPI_COMBINER_NAMED)
+        errs++;
 
     /* Note: it is erroneous to call MPI_Type_get_contents() on a basic. */
     return errs;
@@ -84,7 +81,7 @@ int builtin_float_test(void)
 
 /* vector_of_vectors_test()
  *
- * Builds a vector of a vector of ints.  Assuming an int array of size 9 
+ * Builds a vector of a vector of ints.  Assuming an int array of size 9
  * integers, and treating the array as a 3x3 2D array, this will grab the
  * corners.
  *
@@ -94,110 +91,94 @@ int vector_of_vectors_test(void)
 {
     MPI_Datatype inner_vector;
     MPI_Datatype outer_vector;
-    int array[9] = {  1, -1,  2,
-                    -2, -3, -4,
-                     3, -5,  4 };
+    int array[9] = { 1, -1, 2,
+        -2, -3, -4,
+        3, -5, 4
+    };
 
     char *buf;
     int i, err, errs = 0;
     MPI_Aint sizeoftype, position;
 
     /* set up type */
-    err = MPI_Type_vector(2,
-                         1,
-                         2,
-                         MPI_INT,
-                         &inner_vector);
+    err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs;
     }
 
-    err = MPI_Type_vector(2,
-                         1,
-                         2,
-                         inner_vector,
-                         &outer_vector);
+    err = MPI_Type_vector(2, 1, 2, inner_vector, &outer_vector);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs;
     }
 
     MPI_Type_commit(&outer_vector);
 
-    MPI_Pack_external_size((char*)"external32", 1, outer_vector, &sizeoftype);
-    if (sizeoftype != 4*4) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            (int) sizeoftype, 4*4);
-       return errs;
+    MPI_Pack_external_size((char *) "external32", 1, outer_vector, &sizeoftype);
+    if (sizeoftype != 4 * 4) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n", (int) sizeoftype, 4 * 4);
+        return errs;
     }
 
     buf = (char *) malloc(sizeoftype);
 
     position = 0;
-    err = MPI_Pack_external((char*)"external32",
-                           array,
-                           1,
-                           outer_vector,
-                           buf,
-                           sizeoftype,
-                           &position);
+    err = MPI_Pack_external((char *) "external32",
+                            array, 1, outer_vector, buf, sizeoftype, &position);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            (int) position, (int) sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n",
+                    (int) position, (int) sizeoftype);
     }
 
-    memset(array, 0, 9*sizeof(int));
+    memset(array, 0, 9 * sizeof(int));
     position = 0;
-    err = MPI_Unpack_external((char*)"external32",
-                             buf,
-                             sizeoftype,
-                             &position,
-                             array,
-                             1,
-                             outer_vector);
+    err = MPI_Unpack_external((char *) "external32",
+                              buf, sizeoftype, &position, array, 1, outer_vector);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            (int) position, (int) sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n",
+                    (int) position, (int) sizeoftype);
     }
 
-    for (i=0; i < 9; i++) {
-       int goodval;
-       switch (i) {
-           case 0:
-               goodval = 1;
-               break;
-           case 2:
-               goodval = 2;
-               break;
-           case 6:
-               goodval = 3;
-               break;
-           case 8:
-               goodval = 4;
-               break;
-           default:
-               goodval = 0;
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    for (i = 0; i < 9; i++) {
+        int goodval;
+        switch (i) {
+        case 0:
+            goodval = 1;
+            break;
+        case 2:
+            goodval = 2;
+            break;
+        case 6:
+            goodval = 3;
+            break;
+        case 8:
+            goodval = 4;
+            break;
+        default:
+            goodval = 0;
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
+    free(buf);
     MPI_Type_free(&inner_vector);
     MPI_Type_free(&outer_vector);
     return errs;
@@ -214,82 +195,71 @@ int optimizable_vector_of_basics_test(void)
 {
     MPI_Datatype parent_type;
     int array[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-                     16, 17, 18, 19 };
+        16, 17, 18, 19
+    };
     char *buf;
     int i;
     MPI_Aint sizeofint, sizeoftype, position;
 
-    int /* err, */ errs = 0;
+    int err, errs = 0;
 
-    MPI_Pack_external_size((char*)"external32", 1, MPI_INT, &sizeofint);
+    MPI_Pack_external_size((char *) "external32", 1, MPI_INT, &sizeofint);
 
     if (sizeofint != 4) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "size of external32 MPI_INT = %d; should be %d\n",
-                            (int) sizeofint, 4);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of external32 MPI_INT = %d; should be %d\n", (int) sizeofint, 4);
     }
 
     /* set up type */
-    /* err = */ MPI_Type_vector(10,
-                         2,
-                         2,
-                         MPI_INT,
-                         &parent_type);
+    err = MPI_Type_vector(10, 2, 2, MPI_INT, &parent_type);
 
     MPI_Type_commit(&parent_type);
 
-    MPI_Pack_external_size((char*)"external32", 1, parent_type, &sizeoftype);
+    MPI_Pack_external_size((char *) "external32", 1, parent_type, &sizeoftype);
 
 
     if (sizeoftype != 20 * sizeofint) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of vector = %d; should be %d\n",
-                            (int) sizeoftype, (int) (20 * sizeofint));
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of vector = %d; should be %d\n",
+                    (int) sizeoftype, (int) (20 * sizeofint));
     }
 
     buf = (char *) malloc(sizeoftype);
 
     position = 0;
-    /* err = */ MPI_Pack_external((char*)"external32",
-                           array,
-                           1,
-                           parent_type,
-                           buf,
-                           sizeoftype,
-                           &position);
+    err = MPI_Pack_external((char *) "external32",
+                            array, 1, parent_type, buf, sizeoftype, &position);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            (int) position, (int) sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n",
+                    (int) position, (int) sizeoftype);
     }
 
     memset(array, 0, 20 * sizeof(int));
     position = 0;
-    /* err = */ MPI_Unpack_external((char*)"external32",
-                             buf,
-                             sizeoftype,
-                             &position,
-                             array,
-                             1,
-                             parent_type);
+    err = MPI_Unpack_external((char *) "external32",
+                              buf, sizeoftype, &position, array, 1, parent_type);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "position = %ld; should be %ld (unpack)\n",
-                            (long) position, (long) sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr,
+                    "position = %ld; should be %ld (unpack)\n", (long) position, (long) sizeoftype);
     }
 
-    for (i=0; i < 20; i++) {
-       if (array[i] != i) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], i);
-       }
+    for (i = 0; i < 20; i++) {
+        if (array[i] != i) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], i);
+        }
     }
 
+    free(buf);
     MPI_Type_free(&parent_type);
     return errs;
 }
@@ -305,7 +275,8 @@ int struct_of_basics_test(void)
 {
     MPI_Datatype parent_type;
     int array[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-                     16, 17, 18, 19 };
+        16, 17, 18, 19
+    };
     char *buf;
     int i;
     MPI_Aint sizeofint, sizeoftype, position;
@@ -313,84 +284,72 @@ int struct_of_basics_test(void)
     MPI_Aint indices[10];
     MPI_Datatype types[10];
 
-    int /* err, */ errs = 0;
+    int err, errs = 0;
 
-    MPI_Pack_external_size((char*)"external32", 1, MPI_INT, &sizeofint);
+    MPI_Pack_external_size((char *) "external32", 1, MPI_INT, &sizeofint);
 
     if (sizeofint != 4) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "size of external32 MPI_INT = %d; should be %d\n",
-                            (int) sizeofint, 4);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of external32 MPI_INT = %d; should be %d\n", (int) sizeofint, 4);
     }
 
     for (i = 0; i < 10; i++) {
-       blocks[i] = 2;
-       indices[i] = 2 * i * sizeofint;
-       /* This will cause MPICH to consider this as a blockindex. We
-        * need different types here. */
-       types[i] = MPI_INT;
+        blocks[i] = 2;
+        indices[i] = 2 * i * sizeofint;
+        /* This will cause MPICH to consider this as a blockindex. We
+         * need different types here. */
+        types[i] = MPI_INT;
     }
 
     /* set up type */
-    /* err = */ MPI_Type_struct(10,
-                         blocks,
-                         indices,
-                         types,
-                         &parent_type);
+    err = MPI_Type_struct(10, blocks, indices, types, &parent_type);
 
     MPI_Type_commit(&parent_type);
 
-    MPI_Pack_external_size((char*)"external32", 1, parent_type, &sizeoftype);
+    MPI_Pack_external_size((char *) "external32", 1, parent_type, &sizeoftype);
 
     if (sizeoftype != 20 * sizeofint) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of vector = %d; should be %d\n",
-                            (int) sizeoftype, (int) (20 * sizeofint));
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of vector = %d; should be %d\n",
+                    (int) sizeoftype, (int) (20 * sizeofint));
     }
 
     buf = (char *) malloc(sizeoftype);
 
     position = 0;
-    /* err = */ MPI_Pack_external((char*)"external32",
-                           array,
-                           1,
-                           parent_type,
-                           buf,
-                           sizeoftype,
-                           &position);
+    err = MPI_Pack_external((char *) "external32",
+                            array, 1, parent_type, buf, sizeoftype, &position);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            (int) position, (int) sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n",
+                    (int) position, (int) sizeoftype);
     }
 
     memset(array, 0, 20 * sizeof(int));
     position = 0;
-    /* err = */ MPI_Unpack_external((char*)"external32",
-                             buf,
-                             sizeoftype,
-                             &position,
-                             array,
-                             1,
-                             parent_type);
+    err = MPI_Unpack_external((char *) "external32",
+                              buf, sizeoftype, &position, array, 1, parent_type);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "position = %ld; should be %ld (unpack)\n",
-                            (long) position, (long) sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr,
+                    "position = %ld; should be %ld (unpack)\n", (long) position, (long) sizeoftype);
     }
 
-    for (i=0; i < 20; i++) {
-       if (array[i] != i) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], i);
-       }
+    for (i = 0; i < 20; i++) {
+        if (array[i] != i) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], i);
+        }
     }
 
+    free(buf);
     MPI_Type_free(&parent_type);
     return errs;
 }
@@ -399,14 +358,12 @@ int parse_args(int argc, char **argv)
 {
     int ret;
 
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
+    while ((ret = getopt(argc, argv, "v")) >= 0) {
+        switch (ret) {
+        case 'v':
+            verbose = 1;
+            break;
+        }
     }
     return 0;
 }
-
diff --git a/teshsuite/smpi/mpich3-test/datatype/simple-pack-external2.c b/teshsuite/smpi/mpich3-test/datatype/simple-pack-external2.c
new file mode 100644 (file)
index 0000000..1730e02
--- /dev/null
@@ -0,0 +1,40 @@
+#include <mpi.h>
+#include <stdlib.h>
+
+char *datarep = "external32";
+
+#define UINT_COUNT (2)
+#define DBLE_COUNT (24)
+
+int main(void)
+{
+    unsigned *uint_data = calloc(UINT_COUNT, sizeof(unsigned));
+    double *dble_data = calloc(DBLE_COUNT, sizeof(double));
+    MPI_Aint uint_pack_size, dble_pack_size;
+    MPI_Aint pack_size;
+    void *pack_buffer;
+    MPI_Aint position = 0;
+
+    MPI_Init(NULL, NULL);
+
+    MPI_Pack_external_size(datarep, UINT_COUNT, MPI_UNSIGNED, &uint_pack_size);
+    MPI_Pack_external_size(datarep, DBLE_COUNT, MPI_DOUBLE, &dble_pack_size);
+
+    pack_size = uint_pack_size + dble_pack_size;
+    pack_buffer = malloc(pack_size);
+
+    MPI_Pack_external(datarep, uint_data, UINT_COUNT, MPI_UNSIGNED, pack_buffer, pack_size,
+                      &position);
+    MPI_Pack_external(datarep, dble_data, DBLE_COUNT, MPI_DOUBLE, pack_buffer, pack_size,
+                      &position);
+
+    free(pack_buffer);
+    free(dble_data);
+    free(uint_data);
+
+    MPI_Finalize();
+
+    printf(" No Errors\n");
+
+    return 0;
+}
index 6e7b244..660326c 100644 (file)
@@ -25,35 +25,35 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = builtin_float_test();
-    if (err && verbose) fprintf(stderr, "%d errors in builtin float test.\n", 
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in builtin float test.\n", err);
     errs += err;
 
     err = vector_of_vectors_test();
-    if (err && verbose) fprintf(stderr, 
-                               "%d errors in vector of vectors test.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in vector of vectors test.\n", err);
     errs += err;
 
     err = optimizable_vector_of_basics_test();
-    if (err && verbose) fprintf(stderr, 
-                               "%d errors in vector of basics test.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in vector of basics test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -69,15 +69,12 @@ int builtin_float_test(void)
 {
     int nints, nadds, ntypes, combiner;
 
-    int /* err, */ errs = 0;
+    int errs = 0;
 
-    /* err = */ MPI_Type_get_envelope(MPI_FLOAT,
-                               &nints,
-                               &nadds,
-                               &ntypes,
-                               &combiner);
-    
-    if (combiner != MPI_COMBINER_NAMED) errs++;
+    MPI_Type_get_envelope(MPI_FLOAT, &nints, &nadds, &ntypes, &combiner);
+
+    if (combiner != MPI_COMBINER_NAMED)
+        errs++;
 
     /* Note: it is erroneous to call MPI_Type_get_contents() on a basic. */
     return errs;
@@ -85,8 +82,8 @@ int builtin_float_test(void)
 
 /* vector_of_vectors_test()
  *
- * Builds a vector of a vector of ints.  Assuming an int array of size 9 
- * integers, and treating the array as a 3x3 2D array, this will grab the 
+ * Builds a vector of a vector of ints.  Assuming an int array of size 9
+ * integers, and treating the array as a 3x3 2D array, this will grab the
  * corners.
  *
  * Returns the number of errors encountered.
@@ -95,108 +92,89 @@ int vector_of_vectors_test(void)
 {
     MPI_Datatype inner_vector;
     MPI_Datatype outer_vector;
-    int array[9] = {  1, -1,  2,
-                    -2, -3, -4,
-                     3, -5,  4 };
+    int array[9] = { 1, -1, 2,
+        -2, -3, -4,
+        3, -5, 4
+    };
 
     char *buf;
     int i, err, errs = 0, sizeoftype, position;
 
     /* set up type */
-    err = MPI_Type_vector(2,
-                         1,
-                         2,
-                         MPI_INT,
-                         &inner_vector);
+    err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs;
     }
 
-    err = MPI_Type_vector(2,
-                         1,
-                         2,
-                         inner_vector,
-                         &outer_vector);
+    err = MPI_Type_vector(2, 1, 2, inner_vector, &outer_vector);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) fprintf(stderr, 
-                            "error in MPI call; aborting after %d errors\n",
-                            errs+1);
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+        return errs;
     }
 
     MPI_Type_commit(&outer_vector);
     MPI_Type_size(outer_vector, &sizeoftype);
-    if (sizeoftype != 4*sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            (int) sizeoftype, (int) (4*sizeof(int)));
-       return errs;
+    if (sizeoftype != 4 * sizeof(int)) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    (int) sizeoftype, (int) (4 * sizeof(int)));
+        return errs;
     }
 
     buf = (char *) malloc(sizeoftype);
 
     position = 0;
-    err = MPI_Pack(array,
-                  1,
-                  outer_vector,
-                  buf,
-                  sizeoftype,
-                  &position,
-                  MPI_COMM_WORLD);
+    err = MPI_Pack(array, 1, outer_vector, buf, sizeoftype, &position, MPI_COMM_WORLD);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            position, sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n", position, sizeoftype);
     }
 
-    memset(array, 0, 9*sizeof(int));
+    memset(array, 0, 9 * sizeof(int));
     position = 0;
-    err = MPI_Unpack(buf,
-                    sizeoftype,
-                    &position,
-                    array,
-                    1,
-                    outer_vector,
-                    MPI_COMM_WORLD);
+    err = MPI_Unpack(buf, sizeoftype, &position, array, 1, outer_vector, MPI_COMM_WORLD);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            position, sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n", position, sizeoftype);
     }
 
-    for (i=0; i < 9; i++) {
-       int goodval;
-       switch (i) {
-           case 0:
-               goodval = 1;
-               break;
-           case 2:
-               goodval = 2;
-               break;
-           case 6:
-               goodval = 3;
-               break;
-           case 8:
-               goodval = 4;
-               break;
-           default:
-               goodval = 0;
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    for (i = 0; i < 9; i++) {
+        int goodval;
+        switch (i) {
+        case 0:
+            goodval = 1;
+            break;
+        case 2:
+            goodval = 2;
+            break;
+        case 6:
+            goodval = 3;
+            break;
+        case 8:
+            goodval = 4;
+            break;
+        default:
+            goodval = 0;
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
+    free(buf);
     MPI_Type_free(&inner_vector);
     MPI_Type_free(&outer_vector);
     return errs;
@@ -213,78 +191,65 @@ int optimizable_vector_of_basics_test(void)
 {
     MPI_Datatype parent_type;
     int array[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-                     16, 17, 18, 19 };
+        16, 17, 18, 19
+    };
     char *buf;
     int i, sizeofint, sizeoftype, position;
 
-    int /* err, */ errs = 0;
+    int errs = 0;
 
     MPI_Type_size(MPI_INT, &sizeofint);
 
     if (sizeofint != sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of MPI_Int = %d; should be %d\n",
-                            sizeofint, (int) sizeof(int));
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of MPI_Int = %d; should be %d\n", sizeofint, (int) sizeof(int));
     }
 
     /* set up type */
-    /* err = */ MPI_Type_vector(10,
-                         2,
-                         2,
-                         MPI_INT,
-                         &parent_type);
+    MPI_Type_vector(10, 2, 2, MPI_INT, &parent_type);
 
     MPI_Type_commit(&parent_type);
 
     MPI_Type_size(parent_type, &sizeoftype);
 
     if (sizeoftype != 20 * sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of vector = %d; should be %d\n",
-                            (int) sizeoftype, (int) (20 * sizeof(int)));
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of vector = %d; should be %d\n",
+                    (int) sizeoftype, (int) (20 * sizeof(int)));
     }
 
     buf = (char *) malloc(sizeoftype);
 
     position = 0;
-    /* err = */ MPI_Pack(array,
-                  1,
-                  parent_type,
-                  buf,
-                  sizeoftype,
-                  &position,
-                  MPI_COMM_WORLD);
+    MPI_Pack(array, 1, parent_type, buf, sizeoftype, &position, MPI_COMM_WORLD);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            position, sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n", position, sizeoftype);
     }
 
     memset(array, 0, 20 * sizeof(int));
     position = 0;
-    /* err = */ MPI_Unpack(buf,
-                    sizeoftype,
-                    &position,
-                    array,
-                    1,
-                    parent_type,
-                    MPI_COMM_WORLD);
+    MPI_Unpack(buf, sizeoftype, &position, array, 1, parent_type, MPI_COMM_WORLD);
 
     if (position != sizeoftype) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            position, sizeoftype);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n", position, sizeoftype);
     }
 
-    for (i=0; i < 20; i++) {
-       if (array[i] != i) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], i);
-       }
+    for (i = 0; i < 20; i++) {
+        if (array[i] != i) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], i);
+        }
     }
 
+    free(buf);
     MPI_Type_free(&parent_type);
     return errs;
 }
@@ -293,19 +258,18 @@ int optimizable_vector_of_basics_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index 83aa629..b8700ac 100644 (file)
@@ -23,25 +23,25 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = derived_resized_test();
-    if (err && verbose) fprintf(stderr, "%d errors in derived_resized test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in derived_resized test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -63,60 +63,52 @@ int derived_resized_test(void)
     int size;
     MPI_Aint extent;
 
-    err = MPI_Type_contiguous(count,
-                            MPI_INT,
-                            &newtype);
+    err = MPI_Type_contiguous(count, MPI_INT, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating type in derived_resized_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating type in derived_resized_test()\n");
+        }
+        errs++;
     }
 
     err = MPI_Type_create_resized(newtype,
-                                 (MPI_Aint) 0,
-                                 (MPI_Aint) (2*sizeof(int) + 10),
-                                 &resizedtype);
+                                  (MPI_Aint) 0, (MPI_Aint) (2 * sizeof(int) + 10), &resizedtype);
 
     err = MPI_Type_size(resizedtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in derived_resized_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in derived_resized_test()\n");
+        }
+        errs++;
+    }
+
+    if (size != 2 * sizeof(int)) {
+        if (verbose) {
+            fprintf(stderr,
+                    "error: size != %d in derived_resized_test()\n", (int) (2 * sizeof(int)));
+        }
+        errs++;
     }
-    
-    if (size != 2*sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != %d in derived_resized_test()\n", (int) (2*sizeof(int)));
-       }
-       errs++;
-    }    
 
     err = MPI_Type_extent(resizedtype, &extent);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type extent in derived_resized_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type extent in derived_resized_test()\n");
+        }
+        errs++;
+    }
+
+    if (extent != 2 * sizeof(int) + 10) {
+        if (verbose) {
+            fprintf(stderr,
+                    "error: invalid extent (%d) in derived_resized_test(); should be %d\n",
+                    (int) extent, (int) (2 * sizeof(int) + 10));
+        }
+        errs++;
     }
-    
-    if (extent != 2*sizeof(int) + 10) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: invalid extent (%d) in derived_resized_test(); should be %d\n",
-                   (int) extent,
-                   (int) (2*sizeof(int) + 10));
-       }
-       errs++;
-    }    
-
-    MPI_Type_free( &newtype );
-    MPI_Type_free( &resizedtype );
+
+    MPI_Type_free(&newtype);
+    MPI_Type_free(&resizedtype);
 
     return errs;
 }
@@ -125,19 +117,18 @@ int derived_resized_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index bde5592..3433079 100644 (file)
@@ -23,125 +23,134 @@ int main(int argc, char **argv)
     MPI_Aint lb, ub, extent;
     MPI_Datatype type;
 
-    struct { float a; int b; } foo;
+    struct {
+        float a;
+        int b;
+    } foo;
 
     MPI_Init(&argc, &argv);
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     type = MPI_INT;
     mpi_err = MPI_Type_size(type, &size);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_size of MPI_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_size of MPI_INT failed.\n");
+        }
+        errs++;
     }
     if (size != sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_size of MPI_INT incorrect size (%d); should be %d.\n",
-                   size, (int) sizeof(int));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_size of MPI_INT incorrect size (%d); should be %d.\n",
+                    size, (int) sizeof(int));
+        }
+        errs++;
     }
 
     mpi_err = MPI_Type_get_extent(type, &lb, &extent);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_get_extent of MPI_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_get_extent of MPI_INT failed.\n");
+        }
+        errs++;
     }
     if (extent != sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_get_extent of MPI_INT returned incorrect extent (%d); should be %d.\n",
-                   (int) extent, (int) sizeof(int));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "MPI_Type_get_extent of MPI_INT returned incorrect extent (%d); should be %d.\n",
+                    (int) extent, (int) sizeof(int));
+        }
+        errs++;
     }
     if (lb != 0) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_get_extent of MPI_INT returned incorrect lb (%d); should be 0.\n",
-                   (int) lb);
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "MPI_Type_get_extent of MPI_INT returned incorrect lb (%d); should be 0.\n",
+                    (int) lb);
+        }
+        errs++;
     }
     mpi_err = MPI_Type_ub(type, &ub);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_ub of MPI_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_ub of MPI_INT failed.\n");
+        }
+        errs++;
     }
     if (ub != extent - lb) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_ub of MPI_INT returned incorrect ub (%d); should be %d.\n",
-                   (int) ub, (int) (extent - lb));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_ub of MPI_INT returned incorrect ub (%d); should be %d.\n",
+                    (int) ub, (int) (extent - lb));
+        }
+        errs++;
     }
 
     type = MPI_FLOAT_INT;
     mpi_err = MPI_Type_size(type, &size);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_size of MPI_FLOAT_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_size of MPI_FLOAT_INT failed.\n");
+        }
+        errs++;
     }
     if (size != sizeof(float) + sizeof(int)) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_size of MPI_FLOAT_INT returned incorrect size (%d); should be %d.\n",
-                   size, (int) (sizeof(float) + sizeof(int)));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "MPI_Type_size of MPI_FLOAT_INT returned incorrect size (%d); should be %d.\n",
+                    size, (int) (sizeof(float) + sizeof(int)));
+        }
+        errs++;
     }
 
     mpi_err = MPI_Type_get_extent(type, &lb, &extent);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT failed.\n");
+        }
+        errs++;
     }
     if (extent != sizeof(foo)) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect extent (%d); should be %d.\n",
-                   (int) extent, (int) sizeof(foo));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect extent (%d); should be %d.\n",
+                    (int) extent, (int) sizeof(foo));
+        }
+        errs++;
     }
     if (lb != 0) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect lb (%d); should be 0.\n",
-                   (int) lb);
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect lb (%d); should be 0.\n",
+                    (int) lb);
+        }
+        errs++;
     }
     mpi_err = MPI_Type_ub(type, &ub);
     if (mpi_err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_ub of MPI_FLOAT_INT failed.\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_ub of MPI_FLOAT_INT failed.\n");
+        }
+        errs++;
     }
     if (ub != extent - lb) {
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_ub of MPI_FLOAT_INT returned incorrect ub (%d); should be %d.\n",
-                   (int) ub, (int) (extent - lb));
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "MPI_Type_ub of MPI_FLOAT_INT returned incorrect ub (%d); should be %d.\n",
+                    (int) ub, (int) (extent - lb));
+        }
+        errs++;
     }
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -150,18 +159,18 @@ int main(int argc, char **argv)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 42bec06..c6ae4b3 100644 (file)
 static char MTEST_Descrip[] = "Test of the sized types, supported in MPI-2";
 */
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     int size;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
-    MPI_Type_size( MPI_REAL4, &size );
+    MPI_Type_size(MPI_REAL4, &size);
     if (size != 4) {
-       errs ++;
-       printf( "MPI_REAL4 has size %d\n", size );
+        errs++;
+        printf("MPI_REAL4 has size %d\n", size);
     }
-    MPI_Type_size( MPI_REAL8, &size );
+    MPI_Type_size(MPI_REAL8, &size);
     if (size != 8) {
-       errs ++;
-       printf( "MPI_REAL8 has size %d\n", size );
+        errs++;
+        printf("MPI_REAL8 has size %d\n", size);
     }
     if (MPI_REAL16 != MPI_DATATYPE_NULL) {
-       MPI_Type_size( MPI_REAL16, &size );
-       if (size != 16) {
-           errs ++;
-           printf( "MPI_REAL16 has size %d\n", size );
-       }
+        MPI_Type_size(MPI_REAL16, &size);
+        if (size != 16) {
+            errs++;
+            printf("MPI_REAL16 has size %d\n", size);
+        }
     }
 
-    MPI_Type_size( MPI_COMPLEX8, &size );
+    MPI_Type_size(MPI_COMPLEX8, &size);
     if (size != 8) {
-       errs ++;
-       printf( "MPI_COMPLEX8 has size %d\n", size );
+        errs++;
+        printf("MPI_COMPLEX8 has size %d\n", size);
     }
-    MPI_Type_size( MPI_COMPLEX16, &size );
+    MPI_Type_size(MPI_COMPLEX16, &size);
     if (size != 16) {
-       errs ++;
-       printf( "MPI_COMPLEX16 has size %d\n", size );
+        errs++;
+        printf("MPI_COMPLEX16 has size %d\n", size);
     }
     if (MPI_COMPLEX32 != MPI_DATATYPE_NULL) {
-       MPI_Type_size( MPI_COMPLEX32, &size );
-       if (size != 32) {
-           errs ++;
-           printf( "MPI_COMPLEX32 has size %d\n", size );
-       }
+        MPI_Type_size(MPI_COMPLEX32, &size);
+        if (size != 32) {
+            errs++;
+            printf("MPI_COMPLEX32 has size %d\n", size);
+        }
     }
 
-    MPI_Type_size( MPI_INTEGER1, &size );
+    MPI_Type_size(MPI_INTEGER1, &size);
     if (size != 1) {
-       errs ++;
-       printf( "MPI_INTEGER1 has size %d\n", size );
+        errs++;
+        printf("MPI_INTEGER1 has size %d\n", size);
     }
-    MPI_Type_size( MPI_INTEGER2, &size );
+    MPI_Type_size(MPI_INTEGER2, &size);
     if (size != 2) {
-       errs ++;
-       printf( "MPI_INTEGER2 has size %d\n", size );
+        errs++;
+        printf("MPI_INTEGER2 has size %d\n", size);
     }
-    MPI_Type_size( MPI_INTEGER4, &size );
+    MPI_Type_size(MPI_INTEGER4, &size);
     if (size != 4) {
-       errs ++;
-       printf( "MPI_INTEGER4 has size %d\n", size );
+        errs++;
+        printf("MPI_INTEGER4 has size %d\n", size);
     }
     if (MPI_INTEGER8 != MPI_DATATYPE_NULL) {
-       MPI_Type_size( MPI_INTEGER8, &size );
-       if (size != 8) {
-           errs ++;
-           printf( "MPI_INTEGER8 has size %d\n", size );
-       }
+        MPI_Type_size(MPI_INTEGER8, &size);
+        if (size != 8) {
+            errs++;
+            printf("MPI_INTEGER8 has size %d\n", size);
+        }
     }
 #ifdef HAVE_MPI_INTEGER16
     if (MPI_INTEGER16 != MPI_DATATYPE_NULL) {
-       MPI_Type_size( MPI_INTEGER16, &size );
-       if (size != 16) {
-           errs ++;
-           printf( "MPI_INTEGER16 has size %d\n", size );
-       }
+        MPI_Type_size(MPI_INTEGER16, &size);
+        if (size != 16) {
+            errs++;
+            printf("MPI_INTEGER16 has size %d\n", size);
+        }
     }
 #endif
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
index 25038fc..8781619 100644 (file)
@@ -12,6 +12,7 @@
 static int verbose = 0;
 int a[100][100][100], e[9][9][9];
 
+int main(int argc, char *argv[]);
 
 /* helper functions */
 static int parse_args(int argc, char **argv);
@@ -23,22 +24,22 @@ int main(int argc, char *argv[])
     int errs = 0;
     MPI_Aint sizeofint, bufsize, position;
     void *buffer;
-       
+
     int i, j, k;
-       
+
     /* Initialize a to some known values. */
     for (i = 0; i < 100; i++) {
-       for (j = 0; j < 100; j++) {
-           for (k = 0; k < 100; k++) {
-               a[i][j][k] = i*1000000+j*1000+k;
-           }
-       }
+        for (j = 0; j < 100; j++) {
+            for (k = 0; k < 100; k++) {
+                a[i][j][k] = i * 1000000 + j * 1000 + k;
+            }
+        }
     }
-       
+
     /* Initialize MPI */
     MPI_Init(&argc, &argv);
     MPI_Type_extent(MPI_INT, &sizeofint);
-  
+
     parse_args(argc, argv);
 
     /* Create data types. */
@@ -46,62 +47,52 @@ int main(int argc, char *argv[])
     /* On the sheet, the slice is a[0, 2, 4, ..., 16][2-10][1-9]. */
     /* Below, the slice is a[0-8][2-10][1, 3, 5, ..., 17]. */
     MPI_Type_vector(9, 1, 2, MPI_INT, &oneslice);
-    MPI_Type_hvector(9, 1, 100*sizeofint, oneslice, &twoslice);
-    MPI_Type_hvector(9, 1, 100*100*sizeofint, twoslice, &threeslice);
-       
+    MPI_Type_hvector(9, 1, 100 * sizeofint, oneslice, &twoslice);
+    MPI_Type_hvector(9, 1, 100 * 100 * sizeofint, twoslice, &threeslice);
+
     MPI_Type_commit(&threeslice);
-       
+
     /* Pack it into a buffer. */
     position = 0;
 /*     MPI_Pack_size(1, threeslice, MPI_COMM_WORLD, &bufsize); */
-    MPI_Pack_external_size((char*)"external32", 1, threeslice, &bufsize);
-    if (bufsize != 2916)
-    {
-        fprintf(stderr," Error on pack size! Got %d; expecting %d\n", (int) bufsize, 2916);
+    MPI_Pack_external_size((char *) "external32", 1, threeslice, &bufsize);
+    if (bufsize != 2916) {
+        fprintf(stderr, " Error on pack size! Got %d; expecting %d\n", (int) bufsize, 2916);
     }
     buffer = (void *) malloc((unsigned) bufsize);
 
     /* -1 to indices on sheet to compensate for Fortran --> C */
-    MPI_Pack_external((char*)"external32",
-                     &(a[0][2][1]),
-                     1, threeslice,
-                     buffer,
-                     bufsize,
-                     &position);
+    MPI_Pack_external((char *) "external32",
+                      &(a[0][2][1]), 1, threeslice, buffer, bufsize, &position);
 
     /* Unpack the buffer into e. */
     position = 0;
-    MPI_Unpack_external((char*)"external32",
-                       buffer,
-                       bufsize,
-                       &position,
-                       e, 9*9*9,
-                       MPI_INT);
-       
+    MPI_Unpack_external((char *) "external32", buffer, bufsize, &position, e, 9 * 9 * 9, MPI_INT);
+
     /* Display errors, if any. */
     for (i = 0; i < 9; i++) {
-       for (j = 0; j < 9; j++) {
-           for (k = 0; k < 9; k++) {
-              /* The truncation in integer division makes this safe. */
-               if (e[i][j][k] != a[i][j+2][k*2+1]) {
-                   errs++;
-                   if (verbose) {
-                       printf("Error in location %d x %d x %d: %d, should be %d.\n",
-                              i, j, k, e[i][j][k], a[i][j+2][k*2+1]);
-                   }
-               }
-           }
-       }
-    } 
-  
+        for (j = 0; j < 9; j++) {
+            for (k = 0; k < 9; k++) {
+                /* The truncation in integer division makes this safe. */
+                if (e[i][j][k] != a[i][j + 2][k * 2 + 1]) {
+                    errs++;
+                    if (verbose) {
+                        printf("Error in location %d x %d x %d: %d, should be %d.\n",
+                               i, j, k, e[i][j][k], a[i][j + 2][k * 2 + 1]);
+                    }
+                }
+            }
+        }
+    }
+
     /* Release memory. */
     free(buffer);
 
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
 
     MPI_Type_free(&oneslice);
@@ -118,13 +109,12 @@ static int parse_args(int argc, char **argv)
 {
     int ret;
 
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
+    while ((ret = getopt(argc, argv, "v")) >= 0) {
+        switch (ret) {
+        case 'v':
+            verbose = 1;
+            break;
+        }
     }
     return 0;
 }
index ef8c3c9..ce6d4a4 100644 (file)
@@ -16,6 +16,7 @@
 static int verbose = 0;
 int a[100][100][100], e[9][9][9];
 
+int main(int argc, char *argv[]);
 
 /* helper functions */
 static int parse_args(int argc, char **argv);
@@ -26,25 +27,25 @@ int main(int argc, char *argv[])
     MPI_Datatype oneslice, twoslice, threeslice;
     int errs = 0;
     MPI_Aint sizeofint;
-       
+
     int bufsize, position;
     void *buffer;
-       
+
     int i, j, k;
-       
+
     /* Initialize a to some known values. */
     for (i = 0; i < 100; i++) {
-       for (j = 0; j < 100; j++) {
-           for (k = 0; k < 100; k++) {
-               a[i][j][k] = i*1000000+j*1000+k;
-           }
-       }
+        for (j = 0; j < 100; j++) {
+            for (k = 0; k < 100; k++) {
+                a[i][j][k] = i * 1000000 + j * 1000 + k;
+            }
+        }
     }
-       
+
     /* Initialize MPI */
     MPI_Init(&argc, &argv);
     MPI_Type_extent(MPI_INT, &sizeofint);
-  
+
     parse_args(argc, argv);
 
     /* Create data types. */
@@ -52,57 +53,47 @@ int main(int argc, char *argv[])
     /* On the sheet, the slice is a[0, 2, 4, ..., 16][2-10][1-9]. */
     /* Below, the slice is a[0-8][2-10][1, 3, 5, ..., 17]. */
     MPI_Type_vector(9, 1, 2, MPI_INT, &oneslice);
-    MPI_Type_hvector(9, 1, 100*sizeofint, oneslice, &twoslice);
-    MPI_Type_hvector(9, 1, 100*100*sizeofint, twoslice, &threeslice);
-       
+    MPI_Type_hvector(9, 1, 100 * sizeofint, oneslice, &twoslice);
+    MPI_Type_hvector(9, 1, 100 * 100 * sizeofint, twoslice, &threeslice);
+
     MPI_Type_commit(&threeslice);
-       
+
     /* Pack it into a buffer. */
     position = 0;
     MPI_Pack_size(1, threeslice, MPI_COMM_WORLD, &bufsize);
     buffer = (void *) malloc((unsigned) bufsize);
 
     /* -1 to indices on sheet to compensate for Fortran --> C */
-    MPI_Pack(&(a[0][2][1]),
-            1, threeslice,
-            buffer,
-            bufsize,
-            &position,
-            MPI_COMM_WORLD);
+    MPI_Pack(&(a[0][2][1]), 1, threeslice, buffer, bufsize, &position, MPI_COMM_WORLD);
 
     /* Unpack the buffer into e. */
     position = 0;
-    MPI_Unpack(buffer,
-              bufsize,
-              &position,
-              e, 9*9*9,
-              MPI_INT,
-              MPI_COMM_WORLD);
-       
+    MPI_Unpack(buffer, bufsize, &position, e, 9 * 9 * 9, MPI_INT, MPI_COMM_WORLD);
+
     /* Display errors, if any. */
     for (i = 0; i < 9; i++) {
-       for (j = 0; j < 9; j++) {
-           for (k = 0; k < 9; k++) {
-              /* The truncation in integer division makes this safe. */
-               if (e[i][j][k] != a[i][j+2][k*2+1]) {
-                   errs++;
-                   if (verbose) {
-                       printf("Error in location %d x %d x %d: %d, should be %d.\n",
-                              i, j, k, e[i][j][k], a[i][j+2][k*2+1]);
-                   }
-               }
-           }
-       }
-    } 
-  
+        for (j = 0; j < 9; j++) {
+            for (k = 0; k < 9; k++) {
+                /* The truncation in integer division makes this safe. */
+                if (e[i][j][k] != a[i][j + 2][k * 2 + 1]) {
+                    errs++;
+                    if (verbose) {
+                        printf("Error in location %d x %d x %d: %d, should be %d.\n",
+                               i, j, k, e[i][j][k], a[i][j + 2][k * 2 + 1]);
+                    }
+                }
+            }
+        }
+    }
+
     /* Release memory. */
     free(buffer);
 
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
 
     MPI_Type_free(&oneslice);
@@ -118,18 +109,18 @@ int main(int argc, char *argv[])
 static int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index f07841a..b57d9d5 100644 (file)
@@ -14,47 +14,47 @@ int main(int argc, char *argv[])
 {
     MPI_Datatype mystruct, vecs[3];
     MPI_Aint stride = 5, displs[3];
-    int i=0, blockcount[3];
-    int errs=0;
+    int i = 0, blockcount[3];
+    int errs = 0;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
-    for(i = 0; i < 3; i++)
-    {
+    for (i = 0; i < 3; i++) {
         MPI_Type_hvector(i, 1, stride, MPI_INT, &vecs[i]);
         MPI_Type_commit(&vecs[i]);
-        blockcount[i]=1;
+        blockcount[i] = 1;
     }
-    displs[0]=0; displs[1]=-100; displs[2]=-200; /* irrelevant */
+    displs[0] = 0;
+    displs[1] = -100;
+    displs[2] = -200;   /* irrelevant */
 
     MPI_Type_struct(3, blockcount, displs, vecs, &mystruct);
     MPI_Type_commit(&mystruct);
 
     MPI_Type_free(&mystruct);
-    for(i = 0; i < 3; i++)
-    {
+    for (i = 0; i < 3; i++) {
         MPI_Type_free(&vecs[i]);
     }
 
     /* this time with the first argument always 0 */
-    for(i = 0; i < 3; i++)
-    {
+    for (i = 0; i < 3; i++) {
         MPI_Type_hvector(0, 1, stride, MPI_INT, &vecs[i]);
         MPI_Type_commit(&vecs[i]);
-        blockcount[i]=1;
+        blockcount[i] = 1;
     }
-    displs[0]=0; displs[1]=-100; displs[2]=-200; /* irrelevant */
+    displs[0] = 0;
+    displs[1] = -100;
+    displs[2] = -200;   /* irrelevant */
 
     MPI_Type_struct(3, blockcount, displs, vecs, &mystruct);
     MPI_Type_commit(&mystruct);
 
     MPI_Type_free(&mystruct);
-    for(i = 0; i < 3; i++)
-    {
+    for (i = 0; i < 3; i++) {
         MPI_Type_free(&vecs[i]);
     }
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
 
     return 0;
index d0c57bd..5b992d9 100644 (file)
 
 static int verbose = 0;
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 int single_struct_test(void);
 
 struct test_struct_1 {
-    int a,b,c,d;
+    int a, b, c, d;
 };
 
 int main(int argc, char *argv[])
@@ -27,19 +28,20 @@ int main(int argc, char *argv[])
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     err = single_struct_test();
-    if (verbose && err) fprintf(stderr, "error in single_struct_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in single_struct_test\n");
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -56,9 +58,9 @@ int single_struct_test(void)
     MPI_Status status;
 
     /* note: first element of struct has zero blklen and should be dropped */
-    MPI_Aint disps[3]     = { 2*sizeof(float), 0,       2*sizeof(int) };
-    int blks[3]           = { 0,               1,       2 };
-    MPI_Datatype types[3] = { MPI_FLOAT,       MPI_INT, MPI_INT };
+    MPI_Aint disps[3] = { 2 * sizeof(float), 0, 2 * sizeof(int) };
+    int blks[3] = { 0, 1, 2 };
+    MPI_Datatype types[3] = { MPI_FLOAT, MPI_INT, MPI_INT };
 
     ts1[0].a = -1;
     ts1[0].b = -1;
@@ -72,115 +74,115 @@ int single_struct_test(void)
 
     err = MPI_Type_struct(3, blks, disps, types, &mystruct);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_struct returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_struct returned error\n");
+        }
     }
 
     MPI_Type_commit(&mystruct);
 
     err = MPI_Irecv(ts1, 2, mystruct, 0, 0, MPI_COMM_SELF, &request);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Irecv returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Irecv returned error\n");
+        }
     }
 
     err = MPI_Send(sendbuf, 6, MPI_INT, 0, 0, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Send returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Send returned error\n");
+        }
     }
 
     err = MPI_Wait(&request, &status);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Wait returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Wait returned error\n");
+        }
     }
 
     /* verify data */
     if (ts1[0].a != 1) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[0].a = %d; should be %d\n", ts1[0].a, 1);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[0].a = %d; should be %d\n", ts1[0].a, 1);
+        }
     }
     if (ts1[0].b != -1) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[0].b = %d; should be %d\n", ts1[0].b, -1);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[0].b = %d; should be %d\n", ts1[0].b, -1);
+        }
     }
     if (ts1[0].c != 2) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[0].c = %d; should be %d\n", ts1[0].c, 2);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[0].c = %d; should be %d\n", ts1[0].c, 2);
+        }
     }
     if (ts1[0].d != 3) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[0].d = %d; should be %d\n", ts1[0].d, 3);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[0].d = %d; should be %d\n", ts1[0].d, 3);
+        }
     }
     if (ts1[1].a != 4) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[1].a = %d; should be %d\n", ts1[1].a, 4);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[1].a = %d; should be %d\n", ts1[1].a, 4);
+        }
     }
     if (ts1[1].b != -1) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[1].b = %d; should be %d\n", ts1[1].b, -1);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[1].b = %d; should be %d\n", ts1[1].b, -1);
+        }
     }
     if (ts1[1].c != 5) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[1].c = %d; should be %d\n", ts1[1].c, 5);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[1].c = %d; should be %d\n", ts1[1].c, 5);
+        }
     }
     if (ts1[1].d != 6) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts1[1].d = %d; should be %d\n", ts1[1].d, 6);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts1[1].d = %d; should be %d\n", ts1[1].d, 6);
+        }
     }
 
     /* verify count and elements */
     err = MPI_Get_count(&status, mystruct, &count);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Get_count returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Get_count returned error\n");
+        }
     }
     if (count != 2) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "count = %d; should be 2\n", count);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "count = %d; should be 2\n", count);
+        }
     }
 
     err = MPI_Get_elements(&status, mystruct, &elements);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Get_elements returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Get_elements returned error\n");
+        }
     }
     if (elements != 6) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "elements = %d; should be 6\n", elements);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "elements = %d; should be 6\n", elements);
+        }
     }
 
     MPI_Type_free(&mystruct);
@@ -192,18 +194,18 @@ int single_struct_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 3c44de2..992fd1f 100644 (file)
 #define SIZE           340
 #define EL_COUNT       1131
 
-char s_buf[EL_COUNT*SIZE];
-char r_buf[EL_COUNT*SIZE];
+char s_buf[EL_COUNT * SIZE];
+char r_buf[EL_COUNT * SIZE];
 
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
-    int                rank, size, ret; 
-    MPI_Status                 Status;
-    MPI_Request                request;
-    MPI_Datatype       struct_type, type1[COUNT];
-    MPI_Aint           disp1[COUNT] = {0, 0, 332, 340};
-    int                        block1[COUNT] = {1, 56, 2, 1};
+    int rank, size, ret;
+    MPI_Status Status;
+    MPI_Request request;
+    MPI_Datatype struct_type, type1[COUNT];
+    MPI_Aint disp1[COUNT] = { 0, 0, 332, 340 };
+    int block1[COUNT] = { 1, 56, 2, 1 };
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -32,26 +32,24 @@ int main( int argc, char **argv )
     type1[1] = MPI_FLOAT;
     type1[2] = MPI_FLOAT;
     type1[3] = MPI_UB;
-    
+
     MPI_Type_struct(4, block1, disp1, type1, &struct_type);
-    
+
     ret = MPI_Type_commit(&struct_type);
-    if (ret != MPI_SUCCESS) 
-    {
-        fprintf(stderr, "Could not make struct type."), fflush(stderr); 
-        MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+    if (ret != MPI_SUCCESS) {
+        fprintf(stderr, "Could not make struct type."), fflush(stderr);
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
-    
-    memset(s_buf, 0, EL_COUNT*SIZE);
-    memset(r_buf, 0, EL_COUNT*SIZE);
+
+    memset(s_buf, 0, EL_COUNT * SIZE);
+    memset(r_buf, 0, EL_COUNT * SIZE);
 
     MPI_Isend(s_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &request);
-    MPI_Recv(r_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &Status );
+    MPI_Recv(r_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &Status);
     MPI_Wait(&request, &Status);
-    
+
     MPI_Type_free(&struct_type);
-    
+
     MPI_Finalize();
 
     printf(" No Errors\n");
index a1bded0..a0e21cb 100644 (file)
@@ -12,7 +12,7 @@
 #include <string.h>
 #endif
 
-/* 
+/*
    The default behavior of the test routines should be to briefly indicate
    the cause of any errors - in this test, that means that verbose needs
    to be set. Verbose should turn on output that is independent of error
@@ -34,16 +34,16 @@ int main(int argc, char **argv)
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = no_real_types_test();
-    if (err && verbose) fprintf(stderr, "%d errors in blockindexed test.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in blockindexed test.\n", err);
     errs += err;
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
@@ -67,60 +67,51 @@ int no_real_types_test(void)
     int size;
     MPI_Aint extent;
 
-    err = MPI_Type_create_struct(count,
-                                &len,
-                                &disp,
-                                &type,
-                                &newtype);
+    err = MPI_Type_create_struct(count, &len, &disp, &type, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating struct type no_real_types_test()\n");
-       }
-       MTestPrintError( err );
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating struct type no_real_types_test()\n");
+        }
+        MTestPrintError(err);
+        errs++;
     }
 
     err = MPI_Type_size(newtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in no_real_types_test()\n");
-       }
-       MTestPrintError( err );
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in no_real_types_test()\n");
+        }
+        MTestPrintError(err);
+        errs++;
     }
-    
+
     if (size != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != 0 in no_real_types_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: size != 0 in no_real_types_test()\n");
+        }
+        errs++;
+    }
 
     err = MPI_Type_extent(newtype, &extent);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type extent in no_real_types_test()\n");
-       }
-       MTestPrintError( err );
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type extent in no_real_types_test()\n");
+        }
+        MTestPrintError(err);
+        errs++;
     }
-    
+
     if (extent != -10) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: extent is %ld but should be -10 in no_real_types_test()\n", 
-                   (long) extent );
-           fprintf( stderr, 
-            "type map is { (LB,10) }, so UB is 0 and extent is ub-lb\n" );
-       }
-       errs++;
-    }    
-
-    MPI_Type_free( &newtype );
+        if (verbose) {
+            fprintf(stderr,
+                    "error: extent is %ld but should be -10 in no_real_types_test()\n",
+                    (long) extent);
+            fprintf(stderr, "type map is { (LB,10) }, so UB is 0 and extent is ub-lb\n");
+        }
+        errs++;
+    }
+
+    MPI_Type_free(&newtype);
 
     return errs;
 }
@@ -129,19 +120,18 @@ int no_real_types_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index cf16e6a..04c0807 100644 (file)
 
 static int verbose = 0;
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 int single_struct_test(void);
 int array_of_structs_test(void);
 int struct_of_structs_test(void);
 
 struct test_struct_1 {
-    int a,b;
-    char c,d;
+    int a, b;
+    char c, d;
     int e;
 };
 
@@ -31,27 +32,30 @@ int main(int argc, char *argv[])
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     err = single_struct_test();
-    if (verbose && err) fprintf(stderr, "error in single_struct_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in single_struct_test\n");
     errs += err;
 
     err = array_of_structs_test();
-    if (verbose && err) fprintf(stderr, "error in array_of_structs_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in array_of_structs_test\n");
     errs += err;
 
     err = struct_of_structs_test();
-    if (verbose && err) fprintf(stderr, "error in struct_of_structs_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in struct_of_structs_test\n");
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -65,7 +69,7 @@ int single_struct_test(void)
     MPI_Datatype mystruct;
     char *buffer;
 
-    MPI_Aint disps[3] = {0, 2*sizeof(int), 3*sizeof(int)}; /* guessing... */
+    MPI_Aint disps[3] = { 0, 2 * sizeof(int), 3 * sizeof(int) };        /* guessing... */
     int blks[3] = { 2, 2, 1 };
     MPI_Datatype types[3] = { MPI_INT, MPI_CHAR, MPI_INT };
 
@@ -77,10 +81,10 @@ int single_struct_test(void)
 
     err = MPI_Type_struct(3, blks, disps, types, &mystruct);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_struct returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_struct returned error\n");
+        }
     }
 
     MPI_Type_commit(&mystruct);
@@ -88,69 +92,55 @@ int single_struct_test(void)
     MPI_Pack_size(1, mystruct, MPI_COMM_WORLD, &bufsize);
     buffer = (char *) malloc(bufsize);
 
-    err = MPI_Pack(&ts1,
-                  1,
-                  mystruct,
-                  buffer,
-                  bufsize,
-                  &position,
-                  MPI_COMM_WORLD);
+    err = MPI_Pack(&ts1, 1, mystruct, buffer, bufsize, &position, MPI_COMM_WORLD);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Pack returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Pack returned error\n");
+        }
     }
 
     position = 0;
-    err = MPI_Unpack(buffer,
-                    bufsize,
-                    &position,
-                    &ts2,
-                    1,
-                    mystruct,
-                    MPI_COMM_WORLD);
+    err = MPI_Unpack(buffer, bufsize, &position, &ts2, 1, mystruct, MPI_COMM_WORLD);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Unpack returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Unpack returned error\n");
+        }
     }
 
     MPI_Type_free(&mystruct);
     free(buffer);
 
     if (ts1.a != ts2.a) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts2.a = %d; should be %d\n", ts2.a, ts1.a);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts2.a = %d; should be %d\n", ts2.a, ts1.a);
+        }
     }
     if (ts1.b != ts2.b) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts2.b = %d; should be %d\n", ts2.b, ts1.b);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts2.b = %d; should be %d\n", ts2.b, ts1.b);
+        }
     }
     if (ts1.c != ts2.c) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts2.c = %d; should be %d\n",
-                   (int) ts2.c, (int) ts1.c);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts2.c = %d; should be %d\n", (int) ts2.c, (int) ts1.c);
+        }
     }
     if (ts1.d != ts2.d) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts2.d = %d; should be %d\n",
-                   (int) ts2.d, (int) ts1.d);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts2.d = %d; should be %d\n", (int) ts2.d, (int) ts1.d);
+        }
     }
     if (ts1.e != ts2.e) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "ts2.e = %d; should be %d\n", ts2.e, ts1.e);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "ts2.e = %d; should be %d\n", ts2.e, ts1.e);
+        }
     }
 
     return errs;
@@ -164,30 +154,30 @@ int array_of_structs_test(void)
     MPI_Datatype mystruct;
     char *buffer;
 
-    MPI_Aint disps[3] = {0, 2*sizeof(int), 3*sizeof(int)}; /* guessing... */
+    MPI_Aint disps[3] = { 0, 2 * sizeof(int), 3 * sizeof(int) };        /* guessing... */
     int blks[3] = { 2, 2, 1 };
     MPI_Datatype types[3] = { MPI_INT, MPI_CHAR, MPI_INT };
 
-    for (i=0; i < 10; i++) {
-       ts1[i].a = 10*i + 1;
-       ts1[i].b = 10*i + 2;
-       ts1[i].c = 10*i + 3;
-       ts1[i].d = 10*i + 4;
-       ts1[i].e = 10*i + 5;
-
-       ts2[i].a = -13;
-       ts2[i].b = -13;
-       ts2[i].c = -13;
-       ts2[i].d = -13;
-       ts2[i].e = -13;
+    for (i = 0; i < 10; i++) {
+        ts1[i].a = 10 * i + 1;
+        ts1[i].b = 10 * i + 2;
+        ts1[i].c = 10 * i + 3;
+        ts1[i].d = 10 * i + 4;
+        ts1[i].e = 10 * i + 5;
+
+        ts2[i].a = -13;
+        ts2[i].b = -13;
+        ts2[i].c = -13;
+        ts2[i].d = -13;
+        ts2[i].e = -13;
     }
 
     err = MPI_Type_struct(3, blks, disps, types, &mystruct);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_struct returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_struct returned error\n");
+        }
     }
 
     MPI_Type_commit(&mystruct);
@@ -195,74 +185,59 @@ int array_of_structs_test(void)
     MPI_Pack_size(10, mystruct, MPI_COMM_WORLD, &bufsize);
     buffer = (char *) malloc(bufsize);
 
-    err = MPI_Pack(ts1,
-                  10,
-                  mystruct,
-                  buffer,
-                  bufsize,
-                  &position,
-                  MPI_COMM_WORLD);
+    err = MPI_Pack(ts1, 10, mystruct, buffer, bufsize, &position, MPI_COMM_WORLD);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Pack returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Pack returned error\n");
+        }
     }
 
     position = 0;
-    err = MPI_Unpack(buffer,
-                    bufsize,
-                    &position,
-                    ts2,
-                    10,
-                    mystruct,
-                    MPI_COMM_WORLD);
+    err = MPI_Unpack(buffer, bufsize, &position, ts2, 10, mystruct, MPI_COMM_WORLD);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Unpack returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Unpack returned error\n");
+        }
     }
 
     MPI_Type_free(&mystruct);
     free(buffer);
 
-    for (i=0; i < 10; i++) {
-       if (ts1[i].a != ts2[i].a) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "ts2[%d].a = %d; should be %d\n",
-                       i, ts2[i].a, ts1[i].a);
-           }
-       }
-       if (ts1[i].b != ts2[i].b) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "ts2[%d].b = %d; should be %d\n",
-                       i, ts2[i].b, ts1[i].b);
-           }
-       }
-       if (ts1[i].c != ts2[i].c) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "ts2[%d].c = %d; should be %d\n",
-                       i, (int) ts2[i].c, (int) ts1[i].c);
-           }
-       }
-       if (ts1[i].d != ts2[i].d) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "ts2[%d].d = %d; should be %d\n",
-                       i, (int) ts2[i].d, (int) ts1[i].d);
-           }
-       }
-       if (ts1[i].e != ts2[i].e) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "ts2[%d].e = %d; should be %d\n",
-                       i, ts2[i].e, ts1[i].e);
-           }
-       }
+    for (i = 0; i < 10; i++) {
+        if (ts1[i].a != ts2[i].a) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "ts2[%d].a = %d; should be %d\n", i, ts2[i].a, ts1[i].a);
+            }
+        }
+        if (ts1[i].b != ts2[i].b) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "ts2[%d].b = %d; should be %d\n", i, ts2[i].b, ts1[i].b);
+            }
+        }
+        if (ts1[i].c != ts2[i].c) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "ts2[%d].c = %d; should be %d\n",
+                        i, (int) ts2[i].c, (int) ts1[i].c);
+            }
+        }
+        if (ts1[i].d != ts2[i].d) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "ts2[%d].d = %d; should be %d\n",
+                        i, (int) ts2[i].d, (int) ts1[i].d);
+            }
+        }
+        if (ts1[i].e != ts2[i].e) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "ts2[%d].e = %d; should be %d\n", i, ts2[i].e, ts1[i].e);
+            }
+        }
     }
 
     return errs;
@@ -274,8 +249,8 @@ int struct_of_structs_test(void)
 
     char buf[50], buf2[50], *packbuf;
 
-    MPI_Aint disps[3] = {0, 3, 0};
-    int blks[3] = {2, 1, 0};
+    MPI_Aint disps[3] = { 0, 3, 0 };
+    int blks[3] = { 2, 1, 0 };
     MPI_Datatype types[3], chartype, tiletype1, tiletype2, finaltype;
 
     /* build a contig of one char to try to keep optimizations
@@ -283,11 +258,11 @@ int struct_of_structs_test(void)
      */
     err = MPI_Type_contiguous(1, MPI_CHAR, &chartype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "chartype create failed\n");
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "chartype create failed\n");
+        }
+        return errs;
     }
 
     /* build a type that we can tile a few times */
@@ -296,40 +271,40 @@ int struct_of_structs_test(void)
 
     err = MPI_Type_struct(2, blks, disps, types, &tiletype1);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "tiletype1 create failed\n");
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "tiletype1 create failed\n");
+        }
+        return errs;
     }
 
     /* build the same type again, again to avoid optimizations */
     err = MPI_Type_struct(2, blks, disps, types, &tiletype2);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "tiletype2 create failed\n");
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "tiletype2 create failed\n");
+        }
+        return errs;
     }
 
     /* build a combination of those two tiletypes */
     disps[0] = 0;
     disps[1] = 5;
     disps[2] = 10;
-    blks[0]  = 1;
-    blks[1]  = 1;
-    blks[2]  = 1;
+    blks[0] = 1;
+    blks[1] = 1;
+    blks[2] = 1;
     types[0] = tiletype1;
     types[1] = tiletype2;
     types[2] = MPI_UB;
     err = MPI_Type_struct(3, blks, disps, types, &finaltype);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "finaltype create failed\n");
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "finaltype create failed\n");
+        }
+        return errs;
     }
 
     MPI_Type_commit(&finaltype);
@@ -341,54 +316,54 @@ int struct_of_structs_test(void)
 
     packbuf = malloc(bufsize);
     if (packbuf == NULL) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "pack buffer allocation (%d bytes) failed\n", bufsize);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "pack buffer allocation (%d bytes) failed\n", bufsize);
+        }
+        return errs;
     }
 
-    for (j=0; j < 10; j++) {
-       for (i=0; i < 5; i++) {
-           if (i == 2 || i == 4) buf[5*j + i] = 0;
-           else                  buf[5*j + i] = i;
-       }
+    for (j = 0; j < 10; j++) {
+        for (i = 0; i < 5; i++) {
+            if (i == 2 || i == 4)
+                buf[5 * j + i] = 0;
+            else
+                buf[5 * j + i] = i;
+        }
     }
 
     position = 0;
     err = MPI_Pack(buf, 5, finaltype, packbuf, bufsize, &position, MPI_COMM_WORLD);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "pack failed\n");
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "pack failed\n");
+        }
+        return errs;
     }
 
     memset(buf2, 0, 50);
     position = 0;
     err = MPI_Unpack(packbuf, bufsize, &position, buf2, 5, finaltype, MPI_COMM_WORLD);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "unpack failed\n");
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "unpack failed\n");
+        }
+        return errs;
     }
 
-    for (j=0; j < 10; j++) {
-       for (i=0; i < 5; i++) {
-           if (buf[5*j + i] != buf2[5*j + i]) {
-               errs++;
-               if (verbose) {
-                   fprintf(stderr,
-                           "buf2[%d] = %d; should be %d\n",
-                           5*j + i,
-                           (int) buf2[5*j+i],
-                           (int) buf[5*j+i]);
-               }
-           }
-       }
+    for (j = 0; j < 10; j++) {
+        for (i = 0; i < 5; i++) {
+            if (buf[5 * j + i] != buf2[5 * j + i]) {
+                errs++;
+                if (verbose) {
+                    fprintf(stderr,
+                            "buf2[%d] = %d; should be %d\n",
+                            5 * j + i, (int) buf2[5 * j + i], (int) buf[5 * j + i]);
+                }
+            }
+        }
     }
 
     free(packbuf);
@@ -399,18 +374,18 @@ int struct_of_structs_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index f8bf884..222a0a3 100644 (file)
 extern int MPIDU_Datatype_debug(MPI_Datatype type, int depth);
 */
 
-int makeHDF5type0(MPI_Datatype *type);
-int makeHDF5type0(MPI_Datatype *type)
+int makeHDF5type0(MPI_Datatype * type);
+int makeHDF5type0(MPI_Datatype * type)
 {
-    MPI_Datatype ctg, vect, structype, vec2, structype2,
-                 vec3, structype3, vec4, structype4, vec5;
+    MPI_Datatype ctg, vect, structype, vec2, structype2, vec3, structype3, vec4, structype4, vec5;
 
     int b[3];
     MPI_Aint d[3];
@@ -30,37 +29,57 @@ int makeHDF5type0(MPI_Datatype *type)
 
     MPI_Type_vector(1, 5, 1, ctg, &vect);
 
-    b[0] =         b[1] =       b[2] = 1;
-    d[0] = 0;      d[1] = 0;    d[2] = 40;
-    t[0] = MPI_LB; t[1] = vect; t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 0;
+    d[2] = 40;
+    t[0] = MPI_LB;
+    t[1] = vect;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype);
 
     MPI_Type_vector(1, 5, 1, structype, &vec2);
 
-    b[0] =         b[1] =        b[2] = 1;
-    d[0] = 0;      d[1] = 2000;  d[2] = 400;
-    t[0] = MPI_LB; t[1] = vec2;  t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 2000;
+    d[2] = 400;
+    t[0] = MPI_LB;
+    t[1] = vec2;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype2);
 
     MPI_Type_vector(1, 5, 1, structype2, &vec3);
 
-    b[0] =         b[1] =        b[2] = 1;
-    d[0] = 0;      d[1] = 0;     d[2] = 4000;
-    t[0] = MPI_LB; t[1] = vec3;  t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 0;
+    d[2] = 4000;
+    t[0] = MPI_LB;
+    t[1] = vec3;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype3);
 
     MPI_Type_vector(1, 5, 1, structype3, &vec4);
 
-    b[0] =         b[1] =        b[2] = 1;
-    d[0] = 0;      d[1] = 0;     d[2] = 40000;
-    t[0] = MPI_LB; t[1] = vec4;  t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 0;
+    d[2] = 40000;
+    t[0] = MPI_LB;
+    t[1] = vec4;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype4);
 
     MPI_Type_vector(1, 1, 1, structype4, &vec5);
 
-    b[0] =         b[1] =         b[2] = 1;
-    d[0] = 0;      d[1] = 160000; d[2] = 200000;
-    t[0] = MPI_LB; t[1] = vec5;   t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 160000;
+    d[2] = 200000;
+    t[0] = MPI_LB;
+    t[1] = vec5;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, type);
 
     MPI_Type_free(&ctg);
@@ -78,11 +97,10 @@ int makeHDF5type0(MPI_Datatype *type)
     return 0;
 }
 
-int makeHDF5type1(MPI_Datatype *type);
-int makeHDF5type1(MPI_Datatype *type)
+int makeHDF5type1(MPI_Datatype * type);
+int makeHDF5type1(MPI_Datatype * type)
 {
-    MPI_Datatype ctg, vect, structype, vec2, structype2,
-                 vec3, structype3, vec4, structype4, vec5;
+    MPI_Datatype ctg, vect, structype, vec2, structype2, vec3, structype3, vec4, structype4, vec5;
 
     int b[3];
     MPI_Aint d[3];
@@ -92,37 +110,57 @@ int makeHDF5type1(MPI_Datatype *type)
 
     MPI_Type_vector(1, 5, 1, ctg, &vect);
 
-    b[0] =         b[1] =       b[2] = 1;
-    d[0] = 0;      d[1] = 20;    d[2] = 40;
-    t[0] = MPI_LB; t[1] = vect; t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 20;
+    d[2] = 40;
+    t[0] = MPI_LB;
+    t[1] = vect;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype);
 
     MPI_Type_vector(1, 5, 1, structype, &vec2);
 
-    b[0] =         b[1] =        b[2] = 1;
-    d[0] = 0;      d[1] = 0;     d[2] = 400;
-    t[0] = MPI_LB; t[1] = vec2; t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 0;
+    d[2] = 400;
+    t[0] = MPI_LB;
+    t[1] = vec2;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype2);
 
     MPI_Type_vector(1, 5, 1, structype2, &vec3);
 
-    b[0] =         b[1] =        b[2] = 1;
-    d[0] = 0;      d[1] = 0;     d[2] = 4000;
-    t[0] = MPI_LB; t[1] = vec3; t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 0;
+    d[2] = 4000;
+    t[0] = MPI_LB;
+    t[1] = vec3;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype3);
 
     MPI_Type_vector(1, 5, 1, structype3, &vec4);
 
-    b[0] =         b[1] =        b[2] = 1;
-    d[0] = 0;      d[1] = 0;     d[2] = 40000;
-    t[0] = MPI_LB; t[1] = vec4; t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 0;
+    d[2] = 40000;
+    t[0] = MPI_LB;
+    t[1] = vec4;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, &structype4);
 
     MPI_Type_vector(1, 1, 1, structype4, &vec5);
 
-    b[0] =         b[1] =         b[2] = 1;
-    d[0] = 0;      d[1] = 160000; d[2] = 200000;
-    t[0] = MPI_LB; t[1] = vec5; t[2] = MPI_UB;
+    b[0] = b[1] = b[2] = 1;
+    d[0] = 0;
+    d[1] = 160000;
+    d[2] = 200000;
+    t[0] = MPI_LB;
+    t[1] = vec5;
+    t[2] = MPI_UB;
     MPI_Type_create_struct(3, b, d, t, type);
 
     MPI_Type_free(&ctg);
@@ -140,8 +178,8 @@ int makeHDF5type1(MPI_Datatype *type)
     return 0;
 }
 
-int makeHDF5type(MPI_Datatype *type);
-int makeHDF5type(MPI_Datatype *type)
+int makeHDF5type(MPI_Datatype * type);
+int makeHDF5type(MPI_Datatype * type)
 {
     int i;
 
@@ -154,7 +192,7 @@ int makeHDF5type(MPI_Datatype *type)
     makeHDF5type0(&(types[0]));
     makeHDF5type1(&(types[1]));
 
-    for (i=0; i< NTYPES; i++) {
+    for (i = 0; i < NTYPES; i++) {
         blocklens[i] = 1;
         disps[i] = 0;
     }
@@ -162,7 +200,7 @@ int makeHDF5type(MPI_Datatype *type)
     MPI_Type_create_struct(NTYPES, blocklens, disps, types, type);
     MPI_Type_commit(type);
 
-    for(i=0; i<NTYPES; i++) {
+    for (i = 0; i < NTYPES; i++) {
         MPI_Type_free(&(types[i]));
     }
     return 0;
@@ -175,7 +213,7 @@ int main(int argc, char **argv)
     MPI_Init(&argc, &argv);
     makeHDF5type(&hdf5type);
 
-    /*MPIDU_Datatype_debug(hdf5type, 32);*/
+    /*MPIDU_Datatype_debug(hdf5type, 32); */
 
     MPI_Type_free(&hdf5type);
     MPI_Finalize();
@@ -184,4 +222,3 @@ int main(int argc, char **argv)
 
     return 0;
 }
-
index 74b2d19..0b76219 100644 (file)
@@ -23,24 +23,25 @@ int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = builtin_struct_test();
-    if (err && verbose) fprintf(stderr, "%d errors in builtin struct test.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in builtin struct test.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -62,54 +63,45 @@ int builtin_struct_test(void)
     int size;
     MPI_Aint extent;
 
-    err = MPI_Type_create_struct(count,
-                                (int *) 0,
-                                (MPI_Aint *) 0,
-                                (MPI_Datatype *) 0,
-                                &newtype);
+    err = MPI_Type_create_struct(count, (int *) 0, (MPI_Aint *) 0, (MPI_Datatype *) 0, &newtype);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error creating struct type in builtin_struct_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error creating struct type in builtin_struct_test()\n");
+        }
+        errs++;
     }
 
     err = MPI_Type_size(newtype, &size);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type size in builtin_struct_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type size in builtin_struct_test()\n");
+        }
+        errs++;
     }
-    
+
     if (size != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: size != 0 in builtin_struct_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: size != 0 in builtin_struct_test()\n");
+        }
+        errs++;
+    }
 
     err = MPI_Type_extent(newtype, &extent);
     if (err != MPI_SUCCESS) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error obtaining type extent in builtin_struct_test()\n");
-       }
-       errs++;
+        if (verbose) {
+            fprintf(stderr, "error obtaining type extent in builtin_struct_test()\n");
+        }
+        errs++;
     }
-    
+
     if (extent != 0) {
-       if (verbose) {
-           fprintf(stderr,
-                   "error: extent != 0 in builtin_struct_test()\n");
-       }
-       errs++;
-    }    
+        if (verbose) {
+            fprintf(stderr, "error: extent != 0 in builtin_struct_test()\n");
+        }
+        errs++;
+    }
 
-    MPI_Type_free( &newtype );
+    MPI_Type_free(&newtype);
 
     return errs;
 }
@@ -118,19 +110,18 @@ int builtin_struct_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index 1dcbd2e..74a511e 100644 (file)
 /* The next is for isprint */
 #include <ctype.h>
 
-int main( int argc, char *argv[])
+int main(int argc, char *argv[])
 {
-       struct a {      int     i;
-                       char    c;
-               } s[10], s1[10];
-       int j;
-       int errs = 0, toterrs;
-       int rank, size, tsize;
-       MPI_Aint text;
-       int blens[2];
-       MPI_Aint disps[2];
-       MPI_Datatype bases[2];
-       MPI_Datatype str, con;
-       char *buffer;
-       int   bufsize, position, insize;
+    struct a {
+        int i;
+        char c;
+    } s[10], s1[10];
+    int j;
+    int errs = 0, toterrs;
+    int rank, size, tsize;
+    MPI_Aint text;
+    int blens[2];
+    MPI_Aint disps[2];
+    MPI_Datatype bases[2];
+    MPI_Datatype str, con;
+    char *buffer;
+    int bufsize, position, insize;
 
-       MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
-       MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-       MPI_Comm_size( MPI_COMM_WORLD, &size );
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
 
-       for( j = 0; j < 10; j ++ ) {
-               s[j].i = j + rank;
-               s[j].c = j + rank + 'a';
-       }
+    for (j = 0; j < 10; j++) {
+        s[j].i = j + rank;
+        s[j].c = j + rank + 'a';
+    }
 
-       blens[0] = blens[1] = 1;
-       disps[0] = 0; disps[1] = sizeof(int);
-       bases[0] = MPI_INT; bases[1] = MPI_CHAR;
-       MPI_Type_struct( 2, blens, disps, bases, &str );
-       MPI_Type_commit( &str );
-       MPI_Type_contiguous( 10, str, &con );
-       MPI_Type_commit( &con );
-       MPI_Type_size( con, &tsize );
-       MPI_Type_extent( con, &text );
+    blens[0] = blens[1] = 1;
+    disps[0] = 0;
+    disps[1] = sizeof(int);
+    bases[0] = MPI_INT;
+    bases[1] = MPI_CHAR;
+    MPI_Type_struct(2, blens, disps, bases, &str);
+    MPI_Type_commit(&str);
+    MPI_Type_contiguous(10, str, &con);
+    MPI_Type_commit(&con);
+    MPI_Type_size(con, &tsize);
+    MPI_Type_extent(con, &text);
 
 #ifdef DEBUG
-       printf("Size of MPI array is %d, extent is %d\n", tsize, text );
+    printf("Size of MPI array is %d, extent is %d\n", tsize, text);
 #endif
 
 #ifdef DEBUG
-        {
-       void * p1, *p2;
-       p1 = s;
-       p2 = &(s[10].i);  /* This statement may fail on some systems */
-       printf("C array starts at %p and ends at %p for a length of %d\n",
-               s, &(s[9].c), (char *)p2-(char *)p1 );
-        }
+    {
+        void *p1, *p2;
+        p1 = s;
+        p2 = &(s[10].i);        /* This statement may fail on some systems */
+        printf("C array starts at %p and ends at %p for a length of %d\n",
+               s, &(s[9].c), (char *) p2 - (char *) p1);
+    }
 #endif
-       MPI_Type_extent( str, &text );
+    MPI_Type_extent(str, &text);
 #ifdef DEBUG
-       MPI_Type_size( str, &tsize );
-       printf("Size of MPI struct is %d, extent is %d\n", tsize, (int)text );
-       printf("Size of C struct is %d\n", sizeof(struct a) );
+    MPI_Type_size(str, &tsize);
+    printf("Size of MPI struct is %d, extent is %d\n", tsize, (int) text);
+    printf("Size of C struct is %d\n", sizeof(struct a));
 #endif
-       if (text != sizeof(struct a)) {
-           printf( "Extent of struct a (%d) does not match sizeof (%d)\n",
-                   (int)text, (int)sizeof(struct a) );
-           errs++;
-       }
+    if (text != sizeof(struct a)) {
+        printf("Extent of struct a (%d) does not match sizeof (%d)\n",
+               (int) text, (int) sizeof(struct a));
+        errs++;
+    }
 
-       MPI_Pack_size(1, con, MPI_COMM_WORLD, &bufsize);
-       buffer = (char *) malloc(bufsize);
+    MPI_Pack_size(1, con, MPI_COMM_WORLD, &bufsize);
+    buffer = (char *) malloc(bufsize);
 
-       position = 0;
-       MPI_Pack(s,1,con,buffer,bufsize,&position,MPI_COMM_WORLD);
-       insize   = position;
-       position = 0;
-       MPI_Unpack(buffer,insize,&position,s1,1,con,MPI_COMM_WORLD );
+    position = 0;
+    MPI_Pack(s, 1, con, buffer, bufsize, &position, MPI_COMM_WORLD);
+    insize = position;
+    position = 0;
+    MPI_Unpack(buffer, insize, &position, s1, 1, con, MPI_COMM_WORLD);
 
-       for( j = 0; j < 10; j++ ) {
+    for (j = 0; j < 10; j++) {
 #ifdef DEBUG
-               printf("%d Sent: %d %c, Got: %d %c\n", rank,
-                       s[j].i, s[j].c, s1[j].i, s1[j].c );
+        printf("%d Sent: %d %c, Got: %d %c\n", rank, s[j].i, s[j].c, s1[j].i, s1[j].c);
 #endif
-               if ( s1[j].i != j + rank ) {
-                   errs++;
-                   printf( "Got s[%d].i = %d (%x); expected %d\n", j, s1[j].i,
-                           s1[j].i, j + rank );
-               }
-               if ( s1[j].c != 'a' + j + rank ) {
-                   errs++;
-                   /* If the character is not a printing character,
-                      this can generate an file that diff, for example,
-                      believes is a binary file */
-                   if (isprint( (int)(s1[j].c) )) {
-                       printf( "Got s[%d].c = %c; expected %c\n", j, s1[j].c,
-                               j + rank + 'a');
-                   }
-                   else {
-                       printf( "Got s[%d].c = %x; expected %c\n", j, (int)s1[j].c,
-                               j + rank + 'a');
-                   }
-               }
-       }
+        if (s1[j].i != j + rank) {
+            errs++;
+            printf("Got s[%d].i = %d (%x); expected %d\n", j, s1[j].i, s1[j].i, j + rank);
+        }
+        if (s1[j].c != 'a' + j + rank) {
+            errs++;
+            /* If the character is not a printing character,
+             * this can generate an file that diff, for example,
+             * believes is a binary file */
+            if (isprint((int) (s1[j].c))) {
+                printf("Got s[%d].c = %c; expected %c\n", j, s1[j].c, j + rank + 'a');
+            }
+            else {
+                printf("Got s[%d].c = %x; expected %c\n", j, (int) s1[j].c, j + rank + 'a');
+            }
+        }
+    }
 
-       MPI_Type_free( &str );
-       MPI_Type_free( &con );
-       MTest_Finalize( errs );
-       MPI_Finalize();
-       return 0;
+    free(buffer);
+    MPI_Type_free(&str);
+    MPI_Type_free(&con);
+    MTest_Finalize(errs);
+    MPI_Finalize();
+    return 0;
 }
index 79cd40b..aa73700 100644 (file)
@@ -21,66 +21,61 @@ int subarray_4d_fortran_test1(void);
 
 /* helper functions */
 static int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
 
 int main(int argc, char **argv)
 {
     int err, errs = 0;
 
-    MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+    MPI_Init(&argc, &argv);     /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     /* perform some tests */
     err = subarray_1d_c_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 1d subarray c test 1.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 1d subarray c test 1.\n", err);
     errs += err;
 
     err = subarray_1d_fortran_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 1d subarray fortran test 1.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 1d subarray fortran test 1.\n", err);
     errs += err;
 
     err = subarray_2d_c_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 2d subarray c test 1.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 2d subarray c test 1.\n", err);
     errs += err;
 
     err = subarray_2d_fortran_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 2d subarray fortran test 1.\n",
-                               err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 2d subarray fortran test 1.\n", err);
     errs += err;
 
     err = subarray_2d_c_test2();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 2d subarray c test 2.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 2d subarray c test 2.\n", err);
     errs += err;
 
     err = subarray_4d_c_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 4d subarray c test 1.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 4d subarray c test 1.\n", err);
     errs += err;
 
     err = subarray_4d_fortran_test1();
-    if (err && verbose) fprintf(stderr,
-                               "%d errors in 4d subarray fortran test 1.\n", err);
+    if (err && verbose)
+        fprintf(stderr, "%d errors in 4d subarray fortran test 1.\n", err);
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -94,62 +89,58 @@ int subarray_1d_c_test1(void)
 {
     MPI_Datatype subarray;
     int array[9] = { -1, 1, 2, 3, -2, -3, -4, -5, -6 };
-    int array_size[] = {9};
-    int array_subsize[] = {3};
-    int array_start[] = {1};
+    int array_size[] = { 9 };
+    int array_subsize[] = { 3 };
+    int array_start[] = { 1 };
 
     int i, err, errs = 0, sizeoftype;
 
     /* set up type */
-    err = MPI_Type_create_subarray(1, /* dims */
-                                  array_size,
-                                  array_subsize,
-                                  array_start,
-                                  MPI_ORDER_C,
-                                  MPI_INT,
-                                  &subarray);
+    err = MPI_Type_create_subarray(1,   /* dims */
+                                   array_size,
+                                   array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_create_subarray call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     MPI_Type_commit(&subarray);
     MPI_Type_size(subarray, &sizeoftype);
     if (sizeoftype != 3 * sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            sizeoftype, (int) (3 * sizeof(int)));
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    sizeoftype, (int) (3 * sizeof(int)));
+        return errs;
     }
 
     err = pack_and_unpack((char *) array, 1, subarray, 9 * sizeof(int));
 
-    for (i=0; i < 9; i++) {
-       int goodval;
-       switch (i) {
-           case 1:
-               goodval = 1;
-               break;
-           case 2:
-               goodval = 2;
-               break;
-           case 3:
-               goodval = 3;
-               break;
-           default:
-               goodval = 0; /* pack_and_unpack() zeros before unpacking */
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    for (i = 0; i < 9; i++) {
+        int goodval;
+        switch (i) {
+        case 1:
+            goodval = 1;
+            break;
+        case 2:
+            goodval = 2;
+            break;
+        case 3:
+            goodval = 3;
+            break;
+        default:
+            goodval = 0;        /* pack_and_unpack() zeros before unpacking */
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
     MPI_Type_free(&subarray);
@@ -164,62 +155,59 @@ int subarray_1d_fortran_test1(void)
 {
     MPI_Datatype subarray;
     int array[9] = { -1, 1, 2, 3, -2, -3, -4, -5, -6 };
-    int array_size[] = {9};
-    int array_subsize[] = {3};
-    int array_start[] = {1};
+    int array_size[] = { 9 };
+    int array_subsize[] = { 3 };
+    int array_start[] = { 1 };
 
     int i, err, errs = 0, sizeoftype;
 
     /* set up type */
-    err = MPI_Type_create_subarray(1, /* dims */
-                                  array_size,
-                                  array_subsize,
-                                  array_start,
-                                  MPI_ORDER_FORTRAN,
-                                  MPI_INT,
-                                  &subarray);
+    err = MPI_Type_create_subarray(1,   /* dims */
+                                   array_size,
+                                   array_subsize,
+                                   array_start, MPI_ORDER_FORTRAN, MPI_INT, &subarray);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_create_subarray call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     MPI_Type_commit(&subarray);
     MPI_Type_size(subarray, &sizeoftype);
     if (sizeoftype != 3 * sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            sizeoftype, (int) (3 * sizeof(int)));
-       return errs;
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    sizeoftype, (int) (3 * sizeof(int)));
+        return errs;
     }
 
     err = pack_and_unpack((char *) array, 1, subarray, 9 * sizeof(int));
 
-    for (i=0; i < 9; i++) {
-       int goodval;
-       switch (i) {
-           case 1:
-               goodval = 1;
-               break;
-           case 2:
-               goodval = 2;
-               break;
-           case 3:
-               goodval = 3;
-               break;
-           default:
-               goodval = 0; /* pack_and_unpack() zeros before unpacking */
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    for (i = 0; i < 9; i++) {
+        int goodval;
+        switch (i) {
+        case 1:
+            goodval = 1;
+            break;
+        case 2:
+            goodval = 2;
+            break;
+        case 3:
+            goodval = 3;
+            break;
+        default:
+            goodval = 0;        /* pack_and_unpack() zeros before unpacking */
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
     MPI_Type_free(&subarray);
@@ -235,67 +223,64 @@ int subarray_2d_c_test1(void)
 {
     MPI_Datatype subarray;
     int array[9] = { -1, -2, -3,
-                    -4,  1,  2,
-                    -5,  3,  4 };
-    int array_size[2] = {3, 3};
-    int array_subsize[2] = {2, 2};
-    int array_start[2] = {1, 1};
+        -4, 1, 2,
+        -5, 3, 4
+    };
+    int array_size[2] = { 3, 3 };
+    int array_subsize[2] = { 2, 2 };
+    int array_start[2] = { 1, 1 };
 
     int i, err, errs = 0, sizeoftype;
 
     /* set up type */
-    err = MPI_Type_create_subarray(2, /* dims */
-                                  array_size,
-                                  array_subsize,
-                                  array_start,
-                                  MPI_ORDER_C,
-                                  MPI_INT,
-                                  &subarray);
+    err = MPI_Type_create_subarray(2,   /* dims */
+                                   array_size,
+                                   array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_create_subarray call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     MPI_Type_commit(&subarray);
     MPI_Type_size(subarray, &sizeoftype);
-    if (sizeoftype != 4*sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            sizeoftype, (int) (4*sizeof(int)));
-       return errs;
+    if (sizeoftype != 4 * sizeof(int)) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    sizeoftype, (int) (4 * sizeof(int)));
+        return errs;
     }
 
-    err = pack_and_unpack((char *) array, 1, subarray, 9*sizeof(int));
-
-    for (i=0; i < 9; i++) {
-       int goodval;
-       switch (i) {
-           case 4:
-               goodval = 1;
-               break;
-           case 5:
-               goodval = 2;
-               break;
-           case 7:
-               goodval = 3;
-               break;
-           case 8:
-               goodval = 4;
-               break;
-           default:
-               goodval = 0;
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    err = pack_and_unpack((char *) array, 1, subarray, 9 * sizeof(int));
+
+    for (i = 0; i < 9; i++) {
+        int goodval;
+        switch (i) {
+        case 4:
+            goodval = 1;
+            break;
+        case 5:
+            goodval = 2;
+            break;
+        case 7:
+            goodval = 3;
+            break;
+        case 8:
+            goodval = 4;
+            break;
+        default:
+            goodval = 0;
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
     MPI_Type_free(&subarray);
@@ -309,61 +294,58 @@ int subarray_2d_c_test1(void)
 int subarray_2d_c_test2(void)
 {
     MPI_Datatype subarray;
-    int array[12] = { -1, -2, -3, -4,  1,   2,
-                     -5, -6, -7, -8, -9, -10 };
-    int array_size[2] = {2, 6};
-    int array_subsize[2] = {1, 2};
-    int array_start[2] = {0, 4};
+    int array[12] = { -1, -2, -3, -4, 1, 2,
+        -5, -6, -7, -8, -9, -10
+    };
+    int array_size[2] = { 2, 6 };
+    int array_subsize[2] = { 1, 2 };
+    int array_start[2] = { 0, 4 };
 
     int i, err, errs = 0, sizeoftype;
 
     /* set up type */
-    err = MPI_Type_create_subarray(2, /* dims */
-                                  array_size,
-                                  array_subsize,
-                                  array_start,
-                                  MPI_ORDER_C,
-                                  MPI_INT,
-                                  &subarray);
+    err = MPI_Type_create_subarray(2,   /* dims */
+                                   array_size,
+                                   array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_create_subarray call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     MPI_Type_commit(&subarray);
     MPI_Type_size(subarray, &sizeoftype);
-    if (sizeoftype != 2*sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            sizeoftype, (int) (2*sizeof(int)));
-       return errs;
+    if (sizeoftype != 2 * sizeof(int)) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    sizeoftype, (int) (2 * sizeof(int)));
+        return errs;
     }
 
-    err = pack_and_unpack((char *) array, 1, subarray, 12*sizeof(int));
-
-    for (i=0; i < 12; i++) {
-       int goodval;
-       switch (i) {
-           case 4:
-               goodval = 1;
-               break;
-           case 5:
-               goodval = 2;
-               break;
-           default:
-               goodval = 0;
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    err = pack_and_unpack((char *) array, 1, subarray, 12 * sizeof(int));
+
+    for (i = 0; i < 12; i++) {
+        int goodval;
+        switch (i) {
+        case 4:
+            goodval = 1;
+            break;
+        case 5:
+            goodval = 2;
+            break;
+        default:
+            goodval = 0;
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
     MPI_Type_free(&subarray);
@@ -378,90 +360,87 @@ int subarray_4d_c_test1(void)
 {
     MPI_Datatype subarray;
     int array[] = {
-       -1111, -1112, -1113, -1114, -1115, -1116,
-       -1121, -1122, -1123, -1124, -1125, -1126,
-       -1131, -1132, -1133, -1134, -1135, -1136,
-       -1211, -1212, -1213, -1214, -1215, -1216,
-       -1221, -1222, -1223, -1224, -1225, -1226,
-       -1231, -1232, -1233, -1234, -1235, -1236,
-       -2111, -2112, -2113, -2114,     1, -2116,
-       -2121, -2122, -2123, -2124,     2, -2126,
-       -2131, -2132, -2133, -2134,     3, -2136,
-       -2211, -2212, -2213, -2214,     4, -2216,
-       -2221, -2222, -2223, -2224,     5, -2226,
-       -2231, -2232, -2233, -2234,     6, -2236
+        -1111, -1112, -1113, -1114, -1115, -1116,
+        -1121, -1122, -1123, -1124, -1125, -1126,
+        -1131, -1132, -1133, -1134, -1135, -1136,
+        -1211, -1212, -1213, -1214, -1215, -1216,
+        -1221, -1222, -1223, -1224, -1225, -1226,
+        -1231, -1232, -1233, -1234, -1235, -1236,
+        -2111, -2112, -2113, -2114, 1, -2116,
+        -2121, -2122, -2123, -2124, 2, -2126,
+        -2131, -2132, -2133, -2134, 3, -2136,
+        -2211, -2212, -2213, -2214, 4, -2216,
+        -2221, -2222, -2223, -2224, 5, -2226,
+        -2231, -2232, -2233, -2234, 6, -2236
     };
-    
-    int array_size[4] = {2, 2, 3, 6};
-    int array_subsize[4] = {1, 2, 3, 1};
-    int array_start[4] = {1, 0, 0, 4};
+
+    int array_size[4] = { 2, 2, 3, 6 };
+    int array_subsize[4] = { 1, 2, 3, 1 };
+    int array_start[4] = { 1, 0, 0, 4 };
 
     int i, err, errs = 0, sizeoftype;
 
     /* set up type */
-    err = MPI_Type_create_subarray(4, /* dims */
-                                  array_size,
-                                  array_subsize,
-                                  array_start,
-                                  MPI_ORDER_C,
-                                  MPI_INT,
-                                  &subarray);
+    err = MPI_Type_create_subarray(4,   /* dims */
+                                   array_size,
+                                   array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_create_subarray call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     MPI_Type_commit(&subarray);
     MPI_Type_size(subarray, &sizeoftype);
-    if (sizeoftype != 6*sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            sizeoftype, (int) (6*sizeof(int)));
-       return errs;
+    if (sizeoftype != 6 * sizeof(int)) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    sizeoftype, (int) (6 * sizeof(int)));
+        return errs;
     }
 
-    err = pack_and_unpack((char *) array, 1, subarray, 72*sizeof(int));
-
-    for (i=0; i < 72; i++) {
-       int goodval;
-       switch (i) {
-           case 40:
-               goodval = 1;
-               break;
-           case 46:
-               goodval = 2;
-               break;
-           case 52:
-               goodval = 3;
-               break;
-           case 58:
-               goodval = 4;
-               break;
-           case 64:
-               goodval = 5;
-               break;
-           case 70:
-               goodval = 6;
-               break;
-           default:
-               goodval = 0;
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    err = pack_and_unpack((char *) array, 1, subarray, 72 * sizeof(int));
+
+    for (i = 0; i < 72; i++) {
+        int goodval;
+        switch (i) {
+        case 40:
+            goodval = 1;
+            break;
+        case 46:
+            goodval = 2;
+            break;
+        case 52:
+            goodval = 3;
+            break;
+        case 58:
+            goodval = 4;
+            break;
+        case 64:
+            goodval = 5;
+            break;
+        case 70:
+            goodval = 6;
+            break;
+        default:
+            goodval = 0;
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
     MPI_Type_free(&subarray);
     return errs;
 }
+
 /* subarray_4d_fortran_test1()
  *
  * Returns the number of errors encountered.
@@ -470,85 +449,82 @@ int subarray_4d_fortran_test1(void)
 {
     MPI_Datatype subarray;
     int array[] = {
-       -1111, -1112, -1113, -1114, -1115, -1116,
-       -1121, -1122, -1123, -1124, -1125, -1126,
-       -1131, -1132, -1133, -1134, -1135, -1136,
-       -1211, -1212, -1213, -1214, -1215, -1216,
-       -1221, -1222, -1223, -1224, -1225, -1226,
-       -1231, -1232, -1233, -1234, -1235, -1236,
-       -2111, -2112, -2113, -2114,     1, -2116,
-       -2121, -2122, -2123, -2124,     2, -2126,
-       -2131, -2132, -2133, -2134,     3, -2136,
-       -2211, -2212, -2213, -2214,     4, -2216,
-       -2221, -2222, -2223, -2224,     5, -2226,
-       -2231, -2232, -2233, -2234,     6, -2236
+        -1111, -1112, -1113, -1114, -1115, -1116,
+        -1121, -1122, -1123, -1124, -1125, -1126,
+        -1131, -1132, -1133, -1134, -1135, -1136,
+        -1211, -1212, -1213, -1214, -1215, -1216,
+        -1221, -1222, -1223, -1224, -1225, -1226,
+        -1231, -1232, -1233, -1234, -1235, -1236,
+        -2111, -2112, -2113, -2114, 1, -2116,
+        -2121, -2122, -2123, -2124, 2, -2126,
+        -2131, -2132, -2133, -2134, 3, -2136,
+        -2211, -2212, -2213, -2214, 4, -2216,
+        -2221, -2222, -2223, -2224, 5, -2226,
+        -2231, -2232, -2233, -2234, 6, -2236
     };
-    
-    int array_size[4] = {6, 3, 2, 2};
-    int array_subsize[4] = {1, 3, 2, 1};
-    int array_start[4] = {4, 0, 0, 1};
+
+    int array_size[4] = { 6, 3, 2, 2 };
+    int array_subsize[4] = { 1, 3, 2, 1 };
+    int array_start[4] = { 4, 0, 0, 1 };
 
     int i, err, errs = 0, sizeoftype;
 
     /* set up type */
-    err = MPI_Type_create_subarray(4, /* dims */
-                                  array_size,
-                                  array_subsize,
-                                  array_start,
-                                  MPI_ORDER_FORTRAN,
-                                  MPI_INT,
-                                  &subarray);
+    err = MPI_Type_create_subarray(4,   /* dims */
+                                   array_size,
+                                   array_subsize,
+                                   array_start, MPI_ORDER_FORTRAN, MPI_INT, &subarray);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_create_subarray call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     MPI_Type_commit(&subarray);
     MPI_Type_size(subarray, &sizeoftype);
-    if (sizeoftype != 6*sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            sizeoftype, (int) (6*sizeof(int)));
-       return errs;
+    if (sizeoftype != 6 * sizeof(int)) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    sizeoftype, (int) (6 * sizeof(int)));
+        return errs;
     }
 
-    err = pack_and_unpack((char *) array, 1, subarray, 72*sizeof(int));
-
-    for (i=0; i < 72; i++) {
-       int goodval;
-       switch (i) {
-           case 40:
-               goodval = 1;
-               break;
-           case 46:
-               goodval = 2;
-               break;
-           case 52:
-               goodval = 3;
-               break;
-           case 58:
-               goodval = 4;
-               break;
-           case 64:
-               goodval = 5;
-               break;
-           case 70:
-               goodval = 6;
-               break;
-           default:
-               goodval = 0;
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    err = pack_and_unpack((char *) array, 1, subarray, 72 * sizeof(int));
+
+    for (i = 0; i < 72; i++) {
+        int goodval;
+        switch (i) {
+        case 40:
+            goodval = 1;
+            break;
+        case 46:
+            goodval = 2;
+            break;
+        case 52:
+            goodval = 3;
+            break;
+        case 58:
+            goodval = 4;
+            break;
+        case 64:
+            goodval = 5;
+            break;
+        case 70:
+            goodval = 6;
+            break;
+        default:
+            goodval = 0;
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
     MPI_Type_free(&subarray);
@@ -563,61 +539,59 @@ int subarray_4d_fortran_test1(void)
 int subarray_2d_fortran_test1(void)
 {
     MPI_Datatype subarray;
-    int array[12] = { -1, -2, -3, -4,  1,   2,
-                     -5, -6, -7, -8, -9, -10 };
-    int array_size[2] = {6, 2};
-    int array_subsize[2] = {2, 1};
-    int array_start[2] = {4, 0};
+    int array[12] = { -1, -2, -3, -4, 1, 2,
+        -5, -6, -7, -8, -9, -10
+    };
+    int array_size[2] = { 6, 2 };
+    int array_subsize[2] = { 2, 1 };
+    int array_start[2] = { 4, 0 };
 
     int i, err, errs = 0, sizeoftype;
 
     /* set up type */
-    err = MPI_Type_create_subarray(2, /* dims */
-                                  array_size,
-                                  array_subsize,
-                                  array_start,
-                                  MPI_ORDER_FORTRAN,
-                                  MPI_INT,
-                                  &subarray);
+    err = MPI_Type_create_subarray(2,   /* dims */
+                                   array_size,
+                                   array_subsize,
+                                   array_start, MPI_ORDER_FORTRAN, MPI_INT, &subarray);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_create_subarray call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr,
+                    "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     MPI_Type_commit(&subarray);
     MPI_Type_size(subarray, &sizeoftype);
-    if (sizeoftype != 2*sizeof(int)) {
-       errs++;
-       if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
-                            sizeoftype, (int) (2*sizeof(int)));
-       return errs;
+    if (sizeoftype != 2 * sizeof(int)) {
+        errs++;
+        if (verbose)
+            fprintf(stderr, "size of type = %d; should be %d\n",
+                    sizeoftype, (int) (2 * sizeof(int)));
+        return errs;
     }
 
-    err = pack_and_unpack((char *) array, 1, subarray, 12*sizeof(int));
-
-    for (i=0; i < 12; i++) {
-       int goodval;
-       switch (i) {
-           case 4:
-               goodval = 1;
-               break;
-           case 5:
-               goodval = 2;
-               break;
-           default:
-               goodval = 0;
-               break;
-       }
-       if (array[i] != goodval) {
-           errs++;
-           if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
-                                i, array[i], goodval);
-       }
+    err = pack_and_unpack((char *) array, 1, subarray, 12 * sizeof(int));
+
+    for (i = 0; i < 12; i++) {
+        int goodval;
+        switch (i) {
+        case 4:
+            goodval = 1;
+            break;
+        case 5:
+            goodval = 2;
+            break;
+        default:
+            goodval = 0;
+            break;
+        }
+        if (array[i] != goodval) {
+            errs++;
+            if (verbose)
+                fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+        }
     }
 
     MPI_Type_free(&subarray);
@@ -641,87 +615,64 @@ int subarray_2d_fortran_test1(void)
  *             between the pack and unpack steps
  *
  */
-static int pack_and_unpack(char *typebuf,
-                          int count,
-                          MPI_Datatype datatype,
-                          int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
 {
     char *packbuf;
     int err, errs = 0, pack_size, type_size, position;
 
     err = MPI_Type_size(datatype, &type_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Type_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     type_size *= count;
 
     err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Pack_size call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     packbuf = (char *) malloc(pack_size);
     if (packbuf == NULL) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in malloc call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
 
     position = 0;
-    err = MPI_Pack(typebuf,
-                  count,
-                  datatype,
-                  packbuf,
-                  type_size,
-                  &position,
-                  MPI_COMM_SELF);
+    err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
     }
 
     memset(typebuf, 0, typebufsz);
     position = 0;
-    err = MPI_Unpack(packbuf,
-                    type_size,
-                    &position,
-                    typebuf,
-                    count,
-                    datatype,
-                    MPI_COMM_SELF);
+    err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr,
-                   "error in MPI_Unpack call; aborting after %d errors\n",
-                   errs);
-       }
-       return errs;
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+        }
+        return errs;
     }
     free(packbuf);
 
     if (position != type_size) {
-       errs++;
-       if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
-                            position, type_size);
+        errs++;
+        if (verbose)
+            fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
     }
 
     return errs;
@@ -730,19 +681,18 @@ static int pack_and_unpack(char *typebuf,
 static int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
-
index d726b5a..65f491b 100644 (file)
@@ -18,9 +18,9 @@ int main(int argc, char *argv[])
 {
     int myrank;
     MPI_Datatype subarray;
-    int array_size[] = {X, Y, Z};
-    int array_subsize[] = {X/2, Y/2, Z};
-    int array_start[] = {0, 0, 0};
+    int array_size[] = { X, Y, Z };
+    int array_subsize[] = { X / 2, Y / 2, Z };
+    int array_start[] = { 0, 0, 0 };
     int i, j, k;
     int errs = 0;
 
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
                              MPI_DOUBLE, &subarray);
     MPI_Type_commit(&subarray);
 
-    if(myrank == 0)
+    if (myrank == 0)
         MPI_Send(array, 1, subarray, 1, 0, MPI_COMM_WORLD);
     else {
         MPI_Recv(array, 1, subarray, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
index c16b840..c084bb3 100644 (file)
@@ -63,6 +63,8 @@ struct-verydeep 1
 #get-elements 1
 hindexed_block 1 mpiversion=3.0
 hindexed_block_contents 1 mpiversion=3.0
+vecblklen 1
+hvecblklen 1
 longdouble 1
 #We still have some alignment issues
 #dataalign 2
index 95bf73d..0d829d9 100644 (file)
@@ -16,91 +16,89 @@ static char MTEST_Descrip[] = "Test that freed datatypes have reference count se
 #define VEC_NELM 128
 #define VEC_STRIDE 8
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     int rank, size, source, dest, i;
-    MPI_Comm      comm;
-    MPI_Status    status;
-    MPI_Request   req;
-    MPI_Datatype  strideType;
-    MPI_Datatype  tmpType[1024];
-    int           *buf = 0;
+    MPI_Comm comm;
+    MPI_Status status;
+    MPI_Request req;
+    MPI_Datatype strideType;
+    MPI_Datatype tmpType[1024];
+    int *buf = 0;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     comm = MPI_COMM_WORLD;
 
-    MPI_Comm_rank( comm, &rank );
-    MPI_Comm_size( comm, &size );
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &size);
 
     if (size < 2) {
-       fprintf( stderr, "This test requires at least two processes." );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+        fprintf(stderr, "This test requires at least two processes.");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
-    source  = 0;
-    dest    = size - 1;
-
-    /* 
-       The idea here is to create a simple but non-contig datatype,
-       perform an irecv with it, free it, and then create 
-       many new datatypes.  While not a complete test, if the datatype
-       was freed and the space was reused, this test may detect 
-       that error 
-       A similar test for sends might work by sending a large enough message
-       to force the use of rendezvous send. 
-    */
-    MPI_Type_vector( VEC_NELM, 1, VEC_STRIDE, MPI_INT, &strideType );
-    MPI_Type_commit( &strideType );
+    source = 0;
+    dest = size - 1;
+
+    /*
+     * The idea here is to create a simple but non-contig datatype,
+     * perform an irecv with it, free it, and then create
+     * many new datatypes.  While not a complete test, if the datatype
+     * was freed and the space was reused, this test may detect
+     * that error
+     * A similar test for sends might work by sending a large enough message
+     * to force the use of rendezvous send.
+     */
+    MPI_Type_vector(VEC_NELM, 1, VEC_STRIDE, MPI_INT, &strideType);
+    MPI_Type_commit(&strideType);
 
     if (rank == dest) {
-       buf = (int *)malloc( VEC_NELM * VEC_STRIDE * sizeof(int) );
-       for (i=0; i<VEC_NELM*VEC_STRIDE; i++) buf[i] = -i;
-       MPI_Irecv( buf, 1, strideType, source, 0, comm, &req );
-       MPI_Type_free( &strideType );
-
-       for (i=0; i<1024; i++) {
-           MPI_Type_vector( VEC_NELM, 1, 1, MPI_INT, &tmpType[i] );
-           MPI_Type_commit( &tmpType[i] );
-       }
-
-       MPI_Sendrecv( NULL, 0, MPI_INT, source, 1,
-                     NULL, 0, MPI_INT, source, 1, comm, &status );
-
-       MPI_Wait( &req, &status );
-       for (i=0; i<VEC_NELM; i++) {
-           if (buf[VEC_STRIDE*i] != i) {
-               errs++;
-               if (errs < 10) {
-                   printf( "buf[%d] = %d, expected %d\n", VEC_STRIDE*i, 
-                           buf[VEC_STRIDE*i], i );
-               }
-           }
-       }
-       for (i=0; i<1024; i++) {
-           MPI_Type_free( &tmpType[i] );
-       }
-       free( buf );
+        buf = (int *) malloc(VEC_NELM * VEC_STRIDE * sizeof(int));
+        for (i = 0; i < VEC_NELM * VEC_STRIDE; i++)
+            buf[i] = -i;
+        MPI_Irecv(buf, 1, strideType, source, 0, comm, &req);
+        MPI_Type_free(&strideType);
+
+        for (i = 0; i < 1024; i++) {
+            MPI_Type_vector(VEC_NELM, 1, 1, MPI_INT, &tmpType[i]);
+            MPI_Type_commit(&tmpType[i]);
+        }
+
+        MPI_Sendrecv(NULL, 0, MPI_INT, source, 1, NULL, 0, MPI_INT, source, 1, comm, &status);
+
+        MPI_Wait(&req, &status);
+        for (i = 0; i < VEC_NELM; i++) {
+            if (buf[VEC_STRIDE * i] != i) {
+                errs++;
+                if (errs < 10) {
+                    printf("buf[%d] = %d, expected %d\n", VEC_STRIDE * i, buf[VEC_STRIDE * i], i);
+                }
+            }
+        }
+        for (i = 0; i < 1024; i++) {
+            MPI_Type_free(&tmpType[i]);
+        }
+        free(buf);
     }
     else if (rank == source) {
-       buf = (int *)malloc( VEC_NELM * sizeof(int) );
-       for (i=0; i<VEC_NELM; i++) buf[i] = i;
-       /* Synchronize with the receiver */
-       MPI_Sendrecv( NULL, 0, MPI_INT, dest, 1,
-                     NULL, 0, MPI_INT, dest, 1, comm, &status );
-       MPI_Send( buf, VEC_NELM, MPI_INT, dest, 0, comm );
-       free( buf );
+        buf = (int *) malloc(VEC_NELM * sizeof(int));
+        for (i = 0; i < VEC_NELM; i++)
+            buf[i] = i;
+        /* Synchronize with the receiver */
+        MPI_Sendrecv(NULL, 0, MPI_INT, dest, 1, NULL, 0, MPI_INT, dest, 1, comm, &status);
+        MPI_Send(buf, VEC_NELM, MPI_INT, dest, 0, comm);
+        free(buf);
     }
 
     /* Clean up the strideType */
     if (rank != dest) {
-       MPI_Type_free( &strideType );
+        MPI_Type_free(&strideType);
     }
 
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
index 76432d7..b631ba1 100644 (file)
@@ -15,159 +15,157 @@ static char MTEST_Descrip[] = "Test of type_match_size";
 
 /*
  * type match size is part of the extended Fortran support, and may not
- * be present in 
+ * be present in
  */
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0, err;
     int dsize;
-    MPI_Datatype  newtype;
+    MPI_Datatype newtype;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     /* Check the most likely cases.  Note that it is an error to
-       free the type returned by MPI_Type_match_size.  Also note
-       that it is an error to request a size not supported by the compiler,
-       so Type_match_size should generate an error in that case */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * free the type returned by MPI_Type_match_size.  Also note
+     * that it is an error to request a size not supported by the compiler,
+     * so Type_match_size should generate an error in that case */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
-    err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(float), &newtype );
+    err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(float), &newtype);
     if (err) {
-       errs++;
-       MTestPrintErrorMsg( "Float: ", err );
+        errs++;
+        MTestPrintErrorMsg("Float: ", err);
     }
     else {
-       err = MPI_Type_size( newtype, &dsize );
-       if (err) {
-           errs++;
-           MTestPrintErrorMsg( "Float type: ", err );
-       }
-       else {
-           if (dsize != sizeof(float)) {
-               errs++;
-               printf( "Unexpected size for float (%d != %d)\n", 
-                       dsize, (int) sizeof(float) );
-           }
-       }
+        err = MPI_Type_size(newtype, &dsize);
+        if (err) {
+            errs++;
+            MTestPrintErrorMsg("Float type: ", err);
+        }
+        else {
+            if (dsize != sizeof(float)) {
+                errs++;
+                printf("Unexpected size for float (%d != %d)\n", dsize, (int) sizeof(float));
+            }
+        }
     }
 
-    err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(double), &newtype );
+    err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(double), &newtype);
     if (err) {
-       errs++;
-       MTestPrintErrorMsg( "Double: ", err );
+        errs++;
+        MTestPrintErrorMsg("Double: ", err);
     }
     else {
-       MPI_Type_size( newtype, &dsize );
-       if (dsize != sizeof(double)) {
-           errs++;
-           printf( "Unexpected size for double\n" );
-       }
+        MPI_Type_size(newtype, &dsize);
+        if (dsize != sizeof(double)) {
+            errs++;
+            printf("Unexpected size for double\n");
+        }
     }
 #ifdef HAVE_LONG_DOUBLE
-    err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(long double), &newtype );
+    err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(long double), &newtype);
     if (err) {
-       errs++;
-       MTestPrintErrorMsg( "Long double: ", err );
+        errs++;
+        MTestPrintErrorMsg("Long double: ", err);
     }
     else {
-       MPI_Type_size( newtype, &dsize );
-       if (dsize != sizeof(long double)) {
-           errs++;
-           printf( "Unexpected size for long double\n" );
-       }
+        MPI_Type_size(newtype, &dsize);
+        if (dsize != sizeof(long double)) {
+            errs++;
+            printf("Unexpected size for long double\n");
+        }
     }
 #endif
-    
-    err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(short), &newtype );
+
+    err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(short), &newtype);
     if (err) {
-       errs++;
-       MTestPrintErrorMsg( "Short: ", err );
+        errs++;
+        MTestPrintErrorMsg("Short: ", err);
     }
     else {
-       MPI_Type_size( newtype, &dsize );
-       if (dsize != sizeof(short)) {
-           errs++;
-           printf( "Unexpected size for short\n" );
-       }
+        MPI_Type_size(newtype, &dsize);
+        if (dsize != sizeof(short)) {
+            errs++;
+            printf("Unexpected size for short\n");
+        }
     }
 
-    err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(int), &newtype );
+    err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(int), &newtype);
     if (err) {
-       errs++;
-       MTestPrintErrorMsg( "Int: ", err );
+        errs++;
+        MTestPrintErrorMsg("Int: ", err);
     }
     else {
-       MPI_Type_size( newtype, &dsize );
-       if (dsize != sizeof(int)) {
-           errs++;
-           printf( "Unexpected size for int\n" );
-       }
+        MPI_Type_size(newtype, &dsize);
+        if (dsize != sizeof(int)) {
+            errs++;
+            printf("Unexpected size for int\n");
+        }
     }
 
-    err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(long), &newtype );
+    err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(long), &newtype);
     if (err) {
-       errs++;
-       MTestPrintErrorMsg( "Long: ", err );
+        errs++;
+        MTestPrintErrorMsg("Long: ", err);
     }
     else {
-       MPI_Type_size( newtype, &dsize );
-       if (dsize != sizeof(long)) {
-           errs++;
-           printf( "Unexpected size for long\n" );
-       }
+        MPI_Type_size(newtype, &dsize);
+        if (dsize != sizeof(long)) {
+            errs++;
+            printf("Unexpected size for long\n");
+        }
     }
 #ifdef HAVE_LONG_LONG
-    err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(long long), &newtype );
+    err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(long long), &newtype);
     if (err) {
-       errs++;
-       MTestPrintErrorMsg( "Long long: ", err );
+        errs++;
+        MTestPrintErrorMsg("Long long: ", err);
     }
     else {
-       MPI_Type_size( newtype, &dsize );
-       if (dsize != sizeof(long long)) {
-           errs++;
-           printf( "Unexpected size for long long\n" );
-       }
+        MPI_Type_size(newtype, &dsize);
+        if (dsize != sizeof(long long)) {
+            errs++;
+            printf("Unexpected size for long long\n");
+        }
     }
 #endif
 
     /* COMPLEX is a FORTRAN type.  The MPICH Type_match_size attempts
-       to give a valid datatype, but if Fortran is not available,
-       MPI_COMPLEX and MPI_DOUBLE_COMPLEX are not supported.  
-       Allow this case by testing for MPI_DATATYPE_NULL */
+     * to give a valid datatype, but if Fortran is not available,
+     * MPI_COMPLEX and MPI_DOUBLE_COMPLEX are not supported.
+     * Allow this case by testing for MPI_DATATYPE_NULL */
     if (MPI_COMPLEX != MPI_DATATYPE_NULL) {
-       err = MPI_Type_match_size( MPI_TYPECLASS_COMPLEX, 2*sizeof(float), &newtype );
-       if (err) {
-           errs++;
-           MTestPrintErrorMsg( "Complex: ", err );
-       }
-       else {
-           MPI_Type_size( newtype, &dsize );
-           if (dsize != 2*sizeof(float)) {
-               errs++;
-               printf( "Unexpected size for complex\n" );
-           }
-       }
+        err = MPI_Type_match_size(MPI_TYPECLASS_COMPLEX, 2 * sizeof(float), &newtype);
+        if (err) {
+            errs++;
+            MTestPrintErrorMsg("Complex: ", err);
+        }
+        else {
+            MPI_Type_size(newtype, &dsize);
+            if (dsize != 2 * sizeof(float)) {
+                errs++;
+                printf("Unexpected size for complex\n");
+            }
+        }
+    }
+
+    if (MPI_COMPLEX != MPI_DATATYPE_NULL && MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
+        err = MPI_Type_match_size(MPI_TYPECLASS_COMPLEX, 2 * sizeof(double), &newtype);
+        if (err) {
+            errs++;
+            MTestPrintErrorMsg("Double complex: ", err);
+        }
+        else {
+            MPI_Type_size(newtype, &dsize);
+            if (dsize != 2 * sizeof(double)) {
+                errs++;
+                printf("Unexpected size for double complex\n");
+            }
+        }
     }
 
-    if (MPI_COMPLEX != MPI_DATATYPE_NULL &&
-       MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
-       err = MPI_Type_match_size( MPI_TYPECLASS_COMPLEX, 2*sizeof(double), &newtype );
-       if (err) {
-           errs++;
-           MTestPrintErrorMsg( "Double complex: ", err );
-       }
-       else {
-           MPI_Type_size( newtype, &dsize );
-           if (dsize != 2*sizeof(double)) {
-               errs++;
-               printf( "Unexpected size for double complex\n" );
-           }
-       }
-    }
-    
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
index 71c7d4c..4448138 100644 (file)
@@ -15,6 +15,7 @@
 
 static int verbose = 0;
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 
 int main(int argc, char *argv[])
@@ -23,80 +24,68 @@ int main(int argc, char *argv[])
     int a[100][100], b[100][100];
     MPI_Datatype row, xpose;
     MPI_Aint sizeofint;
-       
-    int /* err, */ errs = 0;
+
+    int errs = 0;
     int bufsize, position = 0;
     void *buffer;
-  
+
     int i, j;
-  
+
     /* Initialize a to some known values. */
-    for(i = 0; i < 100; i++) {
-       for(j = 0; j < 100; j++) {
-           a[i][j] = i*1000+j;
-           b[i][j] = -1;
-       }
+    for (i = 0; i < 100; i++) {
+        for (j = 0; j < 100; j++) {
+            a[i][j] = i * 1000 + j;
+            b[i][j] = -1;
+        }
     }
-  
+
     /* Initialize MPI */
     MPI_Init(&argc, &argv);
     parse_args(argc, argv);
 
     MPI_Type_extent(MPI_INT, &sizeofint);
-       
+
     /* Create datatypes. */
     MPI_Type_vector(100, 1, 100, MPI_INT, &row);
     MPI_Type_hvector(100, 1, sizeofint, row, &xpose);
     MPI_Type_commit(&xpose);
-       
+
     /* Pack it. */
     MPI_Pack_size(1, xpose, MPI_COMM_WORLD, &bufsize);
     buffer = (char *) malloc((unsigned) bufsize);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
-
-    /* err = */ MPI_Pack(a,
-                  1,
-                  xpose,
-                  buffer,
-                  bufsize,
-                  &position,
-                  MPI_COMM_WORLD);
-       
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+
+    MPI_Pack(a, 1, xpose, buffer, bufsize, &position, MPI_COMM_WORLD);
+
     /* Unpack the buffer into b. */
     position = 0;
-    /* err = */ MPI_Unpack(buffer,
-                    bufsize,
-                    &position,
-                    b,
-                    100*100,
-                    MPI_INT,
-                    MPI_COMM_WORLD);
+    MPI_Unpack(buffer, bufsize, &position, b, 100 * 100, MPI_INT, MPI_COMM_WORLD);
 
     for (i = 0; i < 100; i++) {
-       for (j = 0; j < 100; j++) {
-           if(b[i][j] != a[j][i]) {
-               errs++;
-               if (verbose) fprintf(stderr, "b[%d][%d] = %d, should be %d\n",
-                                    i, j, b[i][j], a[j][i]);
-           }
-       }
+        for (j = 0; j < 100; j++) {
+            if (b[i][j] != a[j][i]) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "b[%d][%d] = %d, should be %d\n", i, j, b[i][j], a[j][i]);
+            }
+        }
     }
 
     MPI_Type_free(&xpose);
     MPI_Type_free(&row);
-    
+
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
-    MPI_Finalize();
     free(buffer);
+    MPI_Finalize();
     return 0;
 }
 
@@ -104,18 +93,18 @@ int main(int argc, char *argv[])
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index 7b8c97e..1c64d60 100644 (file)
 static char MTEST_Descrip[] = "Test of type resized";
 */
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0, i;
     int rank, size, source, dest;
-    int count; 
-    int *buf; 
-    MPI_Comm      comm;
-    MPI_Status    status;
-    MPI_Datatype  newtype;
+    int count;
+    int *buf;
+    MPI_Comm comm;
+    MPI_Status status;
+    MPI_Datatype newtype;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     comm = MPI_COMM_WORLD;
 
     /* Determine the sender and receiver */
-    MPI_Comm_rank( comm, &rank );
-    MPI_Comm_size( comm, &size );
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &size);
     source = 0;
-    dest   = size - 1;
-       
-    MPI_Type_create_resized( MPI_INT, 0, 3 * sizeof(int), &newtype );
-    MPI_Type_commit( &newtype );
+    dest = size - 1;
+
+    MPI_Type_create_resized(MPI_INT, 0, 3 * sizeof(int), &newtype);
+    MPI_Type_commit(&newtype);
     for (count = 1; count < 65000; count = count * 2) {
-       buf = (int *)malloc( count * 3 * sizeof(int) );
-       if (!buf) {
-           MPI_Abort( comm, 1 );
-            exit(1);
-       }
-       for (i=0; i<3*count; i++) buf[i] = -1;
-       if (rank == source) {
-           for (i=0; i<count; i++) buf[3*i] = i;
-           MPI_Send( buf, count, newtype, dest, 0, comm );
-           MPI_Send( buf, count, newtype, dest, 1, comm );
-       }
-       else if (rank == dest) {
-           MPI_Recv( buf, count, MPI_INT, source, 0, comm, &status );
-           for (i=0; i<count; i++) {
-               if (buf[i] != i) {
-                   errs++;
-                   if (errs < 10) {
-                       printf( "buf[%d] = %d\n", i, buf[i] );
-                   }
-               }
-           }
-           for (i=0; i<count*3; i++) buf[i] = -1;
-           MPI_Recv( buf, count, newtype, source, 1, comm, &status );
-           for (i=0; i<count; i++) {
-               if (buf[3*i] != i) {
-                   errs++;
-                   if (errs < 10) {
-                       printf( "buf[3*%d] = %d\n", i, buf[i] );
-                   }
-               }
-           }
-       }
+        buf = (int *) malloc(count * 3 * sizeof(int));
+        if (!buf) {
+            MPI_Abort(comm, 1);
+        }
+        for (i = 0; i < 3 * count; i++)
+            buf[i] = -1;
+        if (rank == source) {
+            for (i = 0; i < count; i++)
+                buf[3 * i] = i;
+            MPI_Send(buf, count, newtype, dest, 0, comm);
+            MPI_Send(buf, count, newtype, dest, 1, comm);
+        }
+        else if (rank == dest) {
+            MPI_Recv(buf, count, MPI_INT, source, 0, comm, &status);
+            for (i = 0; i < count; i++) {
+                if (buf[i] != i) {
+                    errs++;
+                    if (errs < 10) {
+                        printf("buf[%d] = %d\n", i, buf[i]);
+                    }
+                }
+            }
+            for (i = 0; i < count * 3; i++)
+                buf[i] = -1;
+            MPI_Recv(buf, count, newtype, source, 1, comm, &status);
+            for (i = 0; i < count; i++) {
+                if (buf[3 * i] != i) {
+                    errs++;
+                    if (errs < 10) {
+                        printf("buf[3*%d] = %d\n", i, buf[i]);
+                    }
+                }
+            }
+        }
+        free(buf);
     }
 
-    MPI_Type_free( &newtype );
-    free(buf);
-    MTest_Finalize( errs );
+    MPI_Type_free(&newtype);
+
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
index 2f5ec3e..7cbd3e3 100644 (file)
 static char MTEST_Descrip[] = "Test of type resized with non-zero LB";
 */
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0, i;
     int rank, size, source, dest;
-    int count; 
-    int *buf; 
-    MPI_Comm      comm;
-    MPI_Status    status;
-    MPI_Datatype  newtype;
+    int count;
+    int *buf;
+    MPI_Comm comm;
+    MPI_Status status;
+    MPI_Datatype newtype;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     comm = MPI_COMM_WORLD;
 
     /* Determine the sender and receiver */
-    MPI_Comm_rank( comm, &rank );
-    MPI_Comm_size( comm, &size );
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &size);
     source = 0;
-    dest   = size - 1;
+    dest = size - 1;
 
     /* Create an type that is "* INT * "
-       that is, there is a int-sized pad at the beginning of the type, 
-       and the extent is still 3 ints.  Note, however, that the INT
-       is still at displacement 0, so the effective pattern i*/
-    MPI_Type_create_resized( MPI_INT, -(int)sizeof(int), 3 * sizeof(int), &newtype ); 
-    MPI_Type_commit( &newtype );
+     * that is, there is a int-sized pad at the beginning of the type,
+     * and the extent is still 3 ints.  Note, however, that the INT
+     * is still at displacement 0, so the effective pattern i */
+    MPI_Type_create_resized(MPI_INT, -(int) sizeof(int), 3 * sizeof(int), &newtype);
+    MPI_Type_commit(&newtype);
     for (count = 1; count < 65000; count = count * 2) {
-       buf = (int *)malloc( count * 3 * sizeof(int) );
-       if (!buf) {
-           MPI_Abort( comm, 1 );
-            exit(1);
-       }
-       for (i=0; i<3*count; i++) buf[i] = -1;
-       if (rank == source) {
-           for (i=0; i<count; i++) buf[3*i] = i;
-           MPI_Send( buf, count, newtype, dest, 0, comm );
-           MPI_Send( buf, count, newtype, dest, 1, comm );
-       }
-       else if (rank == dest) {
-           MPI_Recv( buf, count, MPI_INT, source, 0, comm, &status );
-           for (i=0; i<count; i++) {
-               if (buf[i] != i) {
-                   errs++;
-                   if (errs < 10) {
-                       printf( "buf[%d] = %d\n", i, buf[i] );
-                   }
-               }
-           }
-           for (i=0; i<count*3; i++) buf[i] = -1;
-           MPI_Recv( buf, count, newtype, source, 1, comm, &status );
-           for (i=0; i<count; i++) {
-               if (buf[3*i] != i) {
-                   errs++;
-                   if (errs < 10) {
-                       printf( "buf[3*%d] = %d\n", i, buf[i] );
-                   }
-               }
-           }
-       }
+        buf = (int *) malloc(count * 3 * sizeof(int));
+        if (!buf) {
+            MPI_Abort(comm, 1);
+        }
+        for (i = 0; i < 3 * count; i++)
+            buf[i] = -1;
+        if (rank == source) {
+            for (i = 0; i < count; i++)
+                buf[3 * i] = i;
+            MPI_Send(buf, count, newtype, dest, 0, comm);
+            MPI_Send(buf, count, newtype, dest, 1, comm);
+        }
+        else if (rank == dest) {
+            MPI_Recv(buf, count, MPI_INT, source, 0, comm, &status);
+            for (i = 0; i < count; i++) {
+                if (buf[i] != i) {
+                    errs++;
+                    if (errs < 10) {
+                        printf("buf[%d] = %d\n", i, buf[i]);
+                    }
+                }
+            }
+            for (i = 0; i < count * 3; i++)
+                buf[i] = -1;
+            MPI_Recv(buf, count, newtype, source, 1, comm, &status);
+            for (i = 0; i < count; i++) {
+                if (buf[3 * i] != i) {
+                    errs++;
+                    if (errs < 10) {
+                        printf("buf[3*%d] = %d\n", i, buf[i]);
+                    }
+                }
+            }
+        }
+        free(buf);
     }
-    MPI_Type_free( &newtype );
+    MPI_Type_free(&newtype);
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
index dde6eda..3c460d0 100644 (file)
@@ -10,6 +10,8 @@
 #include "mpi.h"
 #include "mpitest.h"
 
+int main(int argc, char *argv[]);
+
 /* helper functions */
 int parse_args(int argc, char **argv);
 
@@ -21,65 +23,65 @@ int main(int argc, char *argv[])
     int a[100][100], b[100][100];
     int disp[100], block[100];
     MPI_Datatype ltype;
-       
+
     int bufsize, position = 0;
     void *buffer;
-       
+
     int i, j, errs = 0;
-       
+
     /* Initialize a to some known values and zero out b. */
-    for(i = 0; i < 100; i++) {
-       for(j = 0; j < 100; j++) {
-           a[i][j] = 1000*i + j;
-           b[i][j] = 0;
-       }
+    for (i = 0; i < 100; i++) {
+        for (j = 0; j < 100; j++) {
+            a[i][j] = 1000 * i + j;
+            b[i][j] = 0;
+        }
     }
-       
+
     /* Initialize MPI */
-    MTest_Init( &argc, &argv );
-  
+    MTest_Init(&argc, &argv);
+
     parse_args(argc, argv);
 
-    for(i = 0; i < 100; i++) {
-       /* Fortran version has disp(i) = 100*(i-1) + i and block(i) = 100-i. */
-       /* This code here is wrong. It compacts everything together,
-        * which isn't what we want.
-        * What we want is to put the lower triangular values into b and leave
-        * the rest of it unchanged, right?
-        */
-       block[i] = i+1;
-       disp[i] = 100*i;
+    for (i = 0; i < 100; i++) {
+        /* Fortran version has disp(i) = 100*(i-1) + i and block(i) = 100-i. */
+        /* This code here is wrong. It compacts everything together,
+         * which isn't what we want.
+         * What we want is to put the lower triangular values into b and leave
+         * the rest of it unchanged, right?
+         */
+        block[i] = i + 1;
+        disp[i] = 100 * i;
     }
-       
+
     /* Create datatype for lower triangular part. */
     MPI_Type_indexed(100, block, disp, MPI_INT, &ltype);
     MPI_Type_commit(&ltype);
-       
+
     /* Pack it. */
     MPI_Pack_size(1, ltype, MPI_COMM_WORLD, &bufsize);
     buffer = (void *) malloc((unsigned) bufsize);
-    MPI_Pack( a, 1, ltype, buffer, bufsize, &position, MPI_COMM_WORLD );
-       
+    MPI_Pack(a, 1, ltype, buffer, bufsize, &position, MPI_COMM_WORLD);
+
     /* Unpack the buffer into b. */
     position = 0;
     MPI_Unpack(buffer, bufsize, &position, b, 1, ltype, MPI_COMM_WORLD);
-       
-    for(i = 0; i < 100; i++) {
-       for(j = 0; j < 100; j++) {
-           if (j > i && b[i][j] != 0) {
-               errs++;
-               if (verbose) fprintf(stderr, "b[%d][%d] = %d; should be %d\n",
-                                    i, j, b[i][j], 0);
-           }
-           else if (j <= i && b[i][j] != 1000*i + j) {
-               errs++;
-               if (verbose) fprintf(stderr, "b[%d][%d] = %d; should be %d\n",
-                                    i, j, b[i][j], 1000*i + j);
-           }
-       }
+
+    for (i = 0; i < 100; i++) {
+        for (j = 0; j < 100; j++) {
+            if (j > i && b[i][j] != 0) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "b[%d][%d] = %d; should be %d\n", i, j, b[i][j], 0);
+            }
+            else if (j <= i && b[i][j] != 1000 * i + j) {
+                errs++;
+                if (verbose)
+                    fprintf(stderr, "b[%d][%d] = %d; should be %d\n", i, j, b[i][j], 1000 * i + j);
+            }
+        }
     }
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
@@ -88,13 +90,12 @@ int parse_args(int argc, char **argv)
 {
     int ret;
 
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
+    while ((ret = getopt(argc, argv, "v")) >= 0) {
+        switch (ret) {
+        case 'v':
+            verbose = 1;
+            break;
+        }
     }
     return 0;
 }
index 61fb7b5..aff7213 100644 (file)
@@ -7,20 +7,18 @@
 #include <mpi.h>
 #include "mpitest.h"
 
-void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, 
-        MPI_Datatype recvtype);
-void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, 
-        MPI_Datatype recvtype)
+void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, MPI_Datatype recvtype);
+void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, MPI_Datatype recvtype)
 {
     int blocks[2];
     MPI_Aint struct_displs[2];
     MPI_Datatype types[2], tmp_type;
 
     blocks[0] = 256;
-    MPI_Get_address( sendbuf, &struct_displs[0] );
+    MPI_Get_address(sendbuf, &struct_displs[0]);
     types[0] = sendtype;
     blocks[1] = 256;
-    MPI_Get_address( recvbuf, &struct_displs[1] );
+    MPI_Get_address(recvbuf, &struct_displs[1]);
     types[1] = MPI_BYTE;
 
     MPI_Type_create_struct(2, blocks, struct_displs, types, &tmp_type);
@@ -34,15 +32,15 @@ int main(int argc, char **argv)
 
     MTest_Init(&argc, &argv);
 
-    foo((void*) 0x1, MPI_FLOAT_INT, (void*) 0x2, MPI_BYTE);
-    foo((void*) 0x1, MPI_DOUBLE_INT, (void*) 0x2, MPI_BYTE);
-    foo((void*) 0x1, MPI_LONG_INT, (void*) 0x2, MPI_BYTE);
-    foo((void*) 0x1, MPI_SHORT_INT, (void*) 0x2, MPI_BYTE);
-    foo((void*) 0x1, MPI_2INT, (void*) 0x2, MPI_BYTE);
+    foo((void *) 0x1, MPI_FLOAT_INT, (void *) 0x2, MPI_BYTE);
+    foo((void *) 0x1, MPI_DOUBLE_INT, (void *) 0x2, MPI_BYTE);
+    foo((void *) 0x1, MPI_LONG_INT, (void *) 0x2, MPI_BYTE);
+    foo((void *) 0x1, MPI_SHORT_INT, (void *) 0x2, MPI_BYTE);
+    foo((void *) 0x1, MPI_2INT, (void *) 0x2, MPI_BYTE);
 #ifdef HAVE_LONG_DOUBLE
     /* Optional type may be NULL */
     if (MPI_LONG_DOUBLE_INT != MPI_DATATYPE_NULL) {
-       foo((void*) 0x1, MPI_LONG_DOUBLE_INT, (void*) 0x2, MPI_BYTE);
+        foo((void *) 0x1, MPI_LONG_DOUBLE_INT, (void *) 0x2, MPI_BYTE);
     }
 #endif
 
index 83a09dd..cb56941 100644 (file)
  * to turn on MPICH's internal memory checking.
  */
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     MPI_Datatype type;
 
-    MTest_Init( &argc, &argv );
-    MPI_Type_dup( MPI_INT, &type );
-    MPI_Type_free( &type );
-    MTest_Finalize( errs );
+    MTest_Init(&argc, &argv);
+    MPI_Type_dup(MPI_INT, &type);
+    MPI_Type_free(&type);
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
index 2dedadb..6698e64 100644 (file)
@@ -7,7 +7,7 @@
 #include "mpi.h"
 #include <stdio.h>
 
-int main( int argc, char **argv)
+int main(int argc, char **argv)
 {
     int blockcnt[2], rank;
     MPI_Aint offsets[2], lb, ub, extent;
@@ -19,34 +19,35 @@ int main( int argc, char **argv)
     blockcnt[1] = -1;
     offsets[1] = -1;
 
-    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
     if (rank == 0) {
-       blockcnt[0] = 1;
-       offsets[0] = 3;
-       MPI_Type_hindexed(1, blockcnt, offsets, MPI_BYTE, &tmp_type);
-       blockcnt[0] = 1;
-       offsets[0] = 1;
-       MPI_Type_hindexed(1, blockcnt, offsets, tmp_type, &newtype);
-       MPI_Type_commit(&newtype);
-       
-       MPI_Type_lb(newtype, &lb);
-       MPI_Type_extent(newtype, &extent);
-       MPI_Type_ub(newtype, &ub);
-       
-       /* Check that the results are correct */
+        blockcnt[0] = 1;
+        offsets[0] = 3;
+        MPI_Type_hindexed(1, blockcnt, offsets, MPI_BYTE, &tmp_type);
+        blockcnt[0] = 1;
+        offsets[0] = 1;
+        MPI_Type_hindexed(1, blockcnt, offsets, tmp_type, &newtype);
+        MPI_Type_commit(&newtype);
+
+        MPI_Type_lb(newtype, &lb);
+        MPI_Type_extent(newtype, &extent);
+        MPI_Type_ub(newtype, &ub);
+
+        /* Check that the results are correct */
 #ifdef DEBUG
-       printf("lb=%ld, ub=%ld, extent=%ld\n", lb, ub, extent);
-       printf("Should be lb=4, ub=5, extent=1\n");
+        printf("lb=%ld, ub=%ld, extent=%ld\n", lb, ub, extent);
+        printf("Should be lb=4, ub=5, extent=1\n");
 #endif
-       if (lb != 4 || ub != 5 || extent != 1) {
-         printf ("lb = %d (should be 4), ub = %d (should be 5) extent = %d should be 1\n", (int)lb, (int)ub, (int)extent) ;
-       }
-       else {
-           printf( " No Errors\n" );
-       }
-
-       MPI_Type_free(&tmp_type);
-       MPI_Type_free(&newtype);
+        if (lb != 4 || ub != 5 || extent != 1) {
+            printf("lb = %d (should be 4), ub = %d (should be 5) extent = %d should be 1\n",
+                   (int) lb, (int) ub, (int) extent);
+        }
+        else {
+            printf(" No Errors\n");
+        }
+
+        MPI_Type_free(&tmp_type);
+        MPI_Type_free(&newtype);
     }
 
     MPI_Finalize();
index 839b8fc..5d9134f 100644 (file)
@@ -9,7 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-/* Test sent in by Avery Ching to report a bug in MPICH. 
+/* Test sent in by Avery Ching to report a bug in MPICH.
    Adding it as a regression test. */
 
 /*
@@ -30,10 +30,11 @@ static void print_char_buf(char *buf_name, char *buf, int buf_len)
 }
 */
 
-char correct_buf[] = {'a', '_', 'b', 'c', '_', '_', '_', '_', 'd', '_', 
-                     'e', 'f', 'g', '_', 'h', 'i', 'j', '_', 'k', 'l',
-                     '_', '_', '_', '_', 'm', '_', 'n', 'o', 'p', '_',
-                     'q', 'r'};
+char correct_buf[] = { 'a', '_', 'b', 'c', '_', '_', '_', '_', 'd', '_',
+    'e', 'f', 'g', '_', 'h', 'i', 'j', '_', 'k', 'l',
+    '_', '_', '_', '_', 'm', '_', 'n', 'o', 'p', '_',
+    'q', 'r'
+};
 
 #define COUNT 2
 
@@ -46,8 +47,8 @@ int main(int argc, char **argv)
     int mem_dtype_sz = -1;
     int mem_buf_sz = -1, unpack_buf_sz = -1, buf_pos = 0;
 
-    int blk_arr[COUNT] = {1, 2};
-    int dsp_arr[COUNT] = {0, 2};
+    int blk_arr[COUNT] = { 1, 2 };
+    int dsp_arr[COUNT] = { 0, 2 };
     int errs = 0;
 
     MTest_Init(&argc, &argv);
@@ -55,55 +56,51 @@ int main(int argc, char **argv)
     MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
 
     /* Creating the datatype to use for unpacking */
-    MPI_Type_indexed(COUNT, blk_arr, dsp_arr,
-                     MPI_CHAR, &tmp_dtype);
+    MPI_Type_indexed(COUNT, blk_arr, dsp_arr, MPI_CHAR, &tmp_dtype);
     MPI_Type_commit(&tmp_dtype);
-    MPI_Type_indexed(COUNT, blk_arr, dsp_arr,
-                     tmp_dtype, &mem_dtype);
-    MPI_Type_free( &tmp_dtype );
+    MPI_Type_indexed(COUNT, blk_arr, dsp_arr, tmp_dtype, &mem_dtype);
+    MPI_Type_free(&tmp_dtype);
     MPI_Type_commit(&mem_dtype);
 
     MPI_Type_size(mem_dtype, &mem_dtype_sz);
     MPI_Type_extent(mem_dtype, &mem_dtype_ext);
 
-    mem_buf_sz    = 2 * mem_dtype_ext;
+    mem_buf_sz = 2 * mem_dtype_ext;
     unpack_buf_sz = 2 * mem_dtype_sz;
 
-    if ((mem_buf = (char *) malloc(mem_buf_sz)) == NULL)
-    {
-       fprintf(stderr, "malloc mem_buf of size %d failed\n", mem_buf_sz);
-       return -1;
+    if ((mem_buf = (char *) malloc(mem_buf_sz)) == NULL) {
+        fprintf(stderr, "malloc mem_buf of size %d failed\n", mem_buf_sz);
+        return -1;
     }
     memset(mem_buf, '_', mem_buf_sz);
 
-    if ((unpack_buf = (char *) malloc(unpack_buf_sz)) == NULL)
-    {
-       fprintf(stderr, "malloc unpack_buf of size %d failed\n", 
-               unpack_buf_sz);
-       return -1;
+    if ((unpack_buf = (char *) malloc(unpack_buf_sz)) == NULL) {
+        fprintf(stderr, "malloc unpack_buf of size %d failed\n", unpack_buf_sz);
+        return -1;
     }
-    
+
     for (i = 0; i < unpack_buf_sz; i++)
-       unpack_buf[i] = 'a' + i;
-    
+        unpack_buf[i] = 'a' + i;
+
     /* print_char_buf("mem_buf before unpack", mem_buf, 2 * mem_dtype_ext); */
 
-    MPI_Unpack(unpack_buf, unpack_buf_sz, &buf_pos,
-              mem_buf, 2, mem_dtype, MPI_COMM_SELF);
+    MPI_Unpack(unpack_buf, unpack_buf_sz, &buf_pos, mem_buf, 2, mem_dtype, MPI_COMM_SELF);
     /* Note: Unpack without a Pack is not technically correct, but should work
      * with MPICH. */
 
     /* print_char_buf("mem_buf after unpack", mem_buf, 2 * mem_dtype_ext);
-       print_char_buf("correct buffer should be", 
-                       correct_buf, 2 * mem_dtype_ext); */
+     * print_char_buf("correct buffer should be",
+     * correct_buf, 2 * mem_dtype_ext); */
 
     if (memcmp(mem_buf, correct_buf, 2 * mem_dtype_ext)) {
-       printf("Unpacked buffer does not match expected buffer\n");
-       errs++;
+        printf("Unpacked buffer does not match expected buffer\n");
+        errs++;
     }
 
     MPI_Type_free(&mem_dtype);
 
+    free(mem_buf);
+    free(unpack_buf);
     MTest_Finalize(errs);
     MPI_Finalize();
 
index 5844207..d783c75 100644 (file)
@@ -10,7 +10,7 @@
 #include <string.h>
 #include "mpi.h"
 
-/* 
+/*
    The default behavior of the test routines should be to briefly indicate
    the cause of any errors - in this test, that means that verbose needs
    to be set. Verbose should turn on output that is independent of error
@@ -18,6 +18,7 @@
 */
 static int verbose = 1;
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 int struct_negdisp_test(void);
 int vector_negstride_test(void);
@@ -25,7 +26,8 @@ int indexed_negdisp_test(void);
 int struct_struct_test(void);
 int flatten_test(void);
 
-int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_Datatype *datatype);
+int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend,
+                             MPI_Datatype * datatype);
 
 int main(int argc, char *argv[])
 {
@@ -36,35 +38,40 @@ int main(int argc, char *argv[])
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     err = struct_negdisp_test();
-    if (verbose && err) fprintf(stderr, "error in struct_negdisp_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in struct_negdisp_test\n");
     errs += err;
 
     err = vector_negstride_test();
-    if (verbose && err) fprintf(stderr, "error in vector_negstride_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in vector_negstride_test\n");
     errs += err;
 
     err = indexed_negdisp_test();
-    if (verbose && err) fprintf(stderr, "error in indexed_negdisp_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in indexed_negdisp_test\n");
     errs += err;
 
     err = struct_struct_test();
-    if (verbose && err) fprintf(stderr, "error in struct_struct_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in struct_struct_test\n");
     errs += err;
 
     err = flatten_test();
-    if (verbose && err) fprintf(stderr, "error in flatten_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in flatten_test\n");
     errs += err;
 
     /* print message and exit */
     if (errs) {
-       fprintf(stderr, "Found %d errors\n", errs);
+        fprintf(stderr, "Found %d errors\n", errs);
     }
     else {
-       printf(" No Errors\n");
+        printf(" No Errors\n");
     }
     MPI_Finalize();
     return 0;
@@ -82,80 +89,80 @@ int struct_negdisp_test(void)
     MPI_Request request;
     MPI_Status status;
 
-    MPI_Aint disps[2]     = { 0,       -1*((int) sizeof(int)) };
-    int blks[2]           = { 1,       1, };
+    MPI_Aint disps[2] = { 0, -1 * ((int) sizeof(int)) };
+    int blks[2] = { 1, 1, };
     MPI_Datatype types[2] = { MPI_INT, MPI_INT };
 
     err = MPI_Type_struct(2, blks, disps, types, &mystruct);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_struct returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_struct returned error\n");
+        }
     }
 
     MPI_Type_commit(&mystruct);
 
-    err = MPI_Irecv(recvbuf+1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
+    err = MPI_Irecv(recvbuf + 1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Irecv returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Irecv returned error\n");
+        }
     }
 
-    err = MPI_Send(sendbuf+2, 2, mystruct, 0, 0, MPI_COMM_SELF);
+    err = MPI_Send(sendbuf + 2, 2, mystruct, 0, 0, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Send returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Send returned error\n");
+        }
     }
 
     err = MPI_Wait(&request, &status);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Wait returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Wait returned error\n");
+        }
     }
 
     /* verify data */
     if (recvbuf[0] != -1) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
+        }
     }
     if (recvbuf[1] != 3) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
+        }
     }
     if (recvbuf[2] != 2) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
+        }
     }
     if (recvbuf[3] != 5) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
+        }
     }
     if (recvbuf[4] != 4) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
+        }
     }
     if (recvbuf[5] != -6) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
+        }
     }
 
     MPI_Type_free(&mystruct);
@@ -178,74 +185,74 @@ int vector_negstride_test(void)
 
     err = MPI_Type_vector(2, 1, -1, MPI_INT, &myvector);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_vector returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_vector returned error\n");
+        }
     }
 
     MPI_Type_commit(&myvector);
 
-    err = MPI_Irecv(recvbuf+1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
+    err = MPI_Irecv(recvbuf + 1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Irecv returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Irecv returned error\n");
+        }
     }
 
-    err = MPI_Send(sendbuf+2, 2, myvector, 0, 0, MPI_COMM_SELF);
+    err = MPI_Send(sendbuf + 2, 2, myvector, 0, 0, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Send returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Send returned error\n");
+        }
     }
 
     err = MPI_Wait(&request, &status);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Wait returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Wait returned error\n");
+        }
     }
 
     /* verify data */
     if (recvbuf[0] != -1) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
+        }
     }
     if (recvbuf[1] != 3) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
+        }
     }
     if (recvbuf[2] != 2) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
+        }
     }
     if (recvbuf[3] != 5) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
+        }
     }
     if (recvbuf[4] != 4) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
+        }
     }
     if (recvbuf[5] != -6) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
+        }
     }
 
     MPI_Type_free(&myvector);
@@ -266,79 +273,79 @@ int indexed_negdisp_test(void)
     MPI_Request request;
     MPI_Status status;
 
-    int disps[2]     = { 0, -1 };
-    int blks[2]           = { 1, 1 };
+    int disps[2] = { 0, -1 };
+    int blks[2] = { 1, 1 };
 
     err = MPI_Type_indexed(2, blks, disps, MPI_INT, &myindexed);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Type_indexed returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Type_indexed returned error\n");
+        }
     }
 
     MPI_Type_commit(&myindexed);
 
-    err = MPI_Irecv(recvbuf+1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
+    err = MPI_Irecv(recvbuf + 1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Irecv returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Irecv returned error\n");
+        }
     }
 
-    err = MPI_Send(sendbuf+2, 2, myindexed, 0, 0, MPI_COMM_SELF);
+    err = MPI_Send(sendbuf + 2, 2, myindexed, 0, 0, MPI_COMM_SELF);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Send returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Send returned error\n");
+        }
     }
 
     err = MPI_Wait(&request, &status);
     if (err != MPI_SUCCESS) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "MPI_Wait returned error\n");
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "MPI_Wait returned error\n");
+        }
     }
 
     /* verify data */
     if (recvbuf[0] != -1) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
+        }
     }
     if (recvbuf[1] != 3) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
+        }
     }
     if (recvbuf[2] != 2) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
+        }
     }
     if (recvbuf[3] != 5) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
+        }
     }
     if (recvbuf[4] != 4) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
+        }
     }
     if (recvbuf[5] != -6) {
-       errs++;
-       if (verbose) {
-           fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
-       }
+        errs++;
+        if (verbose) {
+            fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
+        }
     }
 
     MPI_Type_free(&myindexed);
@@ -380,39 +387,41 @@ int struct_struct_test(void)
      * arrays are row-major.  So we invert the order of dimensions. */
 #define N (2)
 #define M (4)
-    int array[N][M] =    { {-1, -1, -1, -1}, {-1, -1, -1, -1} };
-    int expected[N][M] = { {-1,  1,  2,  5}, {-1,  3,  4,  6} };
-    int seq_array[N*M];
+    int array[N][M] = { {-1, -1, -1, -1}, {-1, -1, -1, -1} };
+    int expected[N][M] = { {-1, 1, 2, 5}, {-1, 3, 4, 6} };
+    int seq_array[N * M];
     MPI_Aint astart, aend;
     MPI_Aint size_exp = 0;
 
     /* 1st section selects elements 1 and 2 out of 2nd dimension, complete 1st dim.
      * should receive the values 1, 2, 3, 4 */
     astart = 1;
-    aend   = 2;
+    aend = 2;
     err = build_array_section_type(M, astart, aend, &types[0]);
     if (err) {
         errs++;
-        if (verbose) fprintf(stderr, "build_array_section_type failed\n");
+        if (verbose)
+            fprintf(stderr, "build_array_section_type failed\n");
         return errs;
     }
     blens[0] = N;
     displ[0] = 0;
-    size_exp = size_exp + N * (aend-astart+1) * sizeof(int);
+    size_exp = size_exp + N * (aend - astart + 1) * sizeof(int);
 
     /* 2nd section selects last element of 2nd dimension, complete 1st dim.
      * should receive the values 5, 6 */
     astart = 3;
-    aend   = 3;
+    aend = 3;
     err = build_array_section_type(M, astart, aend, &types[1]);
     if (err) {
         errs++;
-        if (verbose) fprintf(stderr, "build_array_section_type failed\n");
+        if (verbose)
+            fprintf(stderr, "build_array_section_type failed\n");
         return errs;
     }
     blens[1] = N;
     displ[1] = 0;
-    size_exp = size_exp + N * (aend-astart+1) * sizeof(int);
+    size_exp = size_exp + N * (aend - astart + 1) * sizeof(int);
 
     /* create type */
     err = MPI_Type_create_struct(COUNT, blens, displ, types, &datatype);
@@ -424,14 +433,15 @@ int struct_struct_test(void)
     check_err(MPI_Type_size);
     if (dt_size != size_exp) {
         errs++;
-        if (verbose) fprintf(stderr, "unexpected type size\n");
+        if (verbose)
+            fprintf(stderr, "unexpected type size\n");
     }
 
 
     /* send the type to ourselves to make sure that the type describes data correctly */
-    for (i = 0; i < (N*M) ; ++i)
-        seq_array[i] = i + 1; /* source values 1..(N*M) */
-    err = MPI_Isend(&seq_array[0], dt_size/sizeof(int), MPI_INT, 0, 42, MPI_COMM_SELF, &req[0]);
+    for (i = 0; i < (N * M); ++i)
+        seq_array[i] = i + 1;   /* source values 1..(N*M) */
+    err = MPI_Isend(&seq_array[0], dt_size / sizeof(int), MPI_INT, 0, 42, MPI_COMM_SELF, &req[0]);
     check_err(MPI_Isend);
     err = MPI_Irecv(&array[0][0], 1, datatype, 0, 42, MPI_COMM_SELF, &req[1]);
     check_err(MPI_Irecv);
@@ -444,7 +454,8 @@ int struct_struct_test(void)
             if (array[i][j] != expected[i][j]) {
                 errs++;
                 if (verbose)
-                    fprintf(stderr, "array[%d][%d]=%d, should be %d\n", i, j, array[i][j], expected[i][j]);
+                    fprintf(stderr, "array[%d][%d]=%d, should be %d\n", i, j, array[i][j],
+                            expected[i][j]);
             }
         }
     }
@@ -477,7 +488,7 @@ int struct_struct_test(void)
      1D array   ###############################
      datatype   LB      ###########             UB
  */
-int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_Datatype *datatype)
+int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_Datatype * datatype)
 {
 #define COUNT (3)
     int err, errs = 0;
@@ -516,8 +527,7 @@ int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_
 
 /* start_idx is the "zero" point for the unpack */
 static int pack_and_check_expected(MPI_Datatype type, const char *name,
-                                   int start_idx, int size,
-                                   int *array, int *expected)
+                                   int start_idx, int size, int *array, int *expected)
 {
     int i;
     int err, errs = 0;
@@ -525,19 +535,21 @@ static int pack_and_check_expected(MPI_Datatype type, const char *name,
     int *pack_buf = NULL;
     int pos;
     int type_size = -1;
-    int sendbuf[8] = {0,1,2,3,4,5,6,7};
+    int sendbuf[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
 
     err = MPI_Type_size(type, &type_size);
     check_err(MPI_Type_size);
     assert(sizeof(sendbuf) >= type_size);
 
-    err = MPI_Pack_size(type_size/sizeof(int), MPI_INT, MPI_COMM_SELF, &pack_size);
+    err = MPI_Pack_size(type_size / sizeof(int), MPI_INT, MPI_COMM_SELF, &pack_size);
     check_err(MPI_Pack_size);
     pack_buf = malloc(pack_size);
-    assert(pack_buf!=NULL);
+    assert(pack_buf);
 
     pos = 0;
-    err = MPI_Pack(&sendbuf[0], type_size/sizeof(int), MPI_INT, pack_buf, pack_size, &pos, MPI_COMM_SELF);
+    err =
+        MPI_Pack(&sendbuf[0], type_size / sizeof(int), MPI_INT, pack_buf, pack_size, &pos,
+                 MPI_COMM_SELF);
     check_err(MPI_Pack);
     pos = 0;
     err = MPI_Unpack(pack_buf, pack_size, &pos, &array[start_idx], 1, type, MPI_COMM_SELF);
@@ -564,8 +576,8 @@ int flatten_test(void)
 #define ARR_SIZE (9)
     /* real indices              0  1  2  3  4  5  6  7  8
      * indices w/ &array[3]     -3 -2 -1  0  1  2  3  4  5 */
-    int array[ARR_SIZE]      = {-1,-1,-1,-1,-1,-1,-1,-1,-1};
-    int expected[ARR_SIZE]   = {-1, 0, 1,-1, 2,-1, 3,-1, 4};
+    int array[ARR_SIZE] = { -1, -1, -1, -1, -1, -1, -1, -1, -1 };
+    int expected[ARR_SIZE] = { -1, 0, 1, -1, 2, -1, 3, -1, 4 };
     MPI_Datatype idx_type = MPI_DATATYPE_NULL;
     MPI_Datatype blkidx_type = MPI_DATATYPE_NULL;
     MPI_Datatype combo = MPI_DATATYPE_NULL;
@@ -582,9 +594,9 @@ int flatten_test(void)
      * different blens to prevent optimization into a blockindexed
      */
     blens[0] = 2;
-    displ[0] = -2; /* elements, puts byte after block end at 0 */
+    displ[0] = -2;      /* elements, puts byte after block end at 0 */
     blens[1] = 1;
-    displ[1] = 1; /*elements*/
+    displ[1] = 1;       /*elements */
 
     err = MPI_Type_indexed(COUNT, blens, displ, MPI_INT, &idx_type);
     check_err(MPI_Type_indexed);
@@ -606,13 +618,13 @@ int flatten_test(void)
      * II_I_B_B  (I=idx_type, B=blkidx_type)
      * 21012345  <-- pos (left of 0 is neg)
      */
-    blens[0]  = 1;
-    adispl[0] = 0; /*bytes*/
-    types[0]  = idx_type;
+    blens[0] = 1;
+    adispl[0] = 0;      /*bytes */
+    types[0] = idx_type;
 
-    blens[1]  = 1;
-    adispl[1] = 4 * sizeof(int); /* bytes */
-    types[1]  = blkidx_type;
+    blens[1] = 1;
+    adispl[1] = 4 * sizeof(int);        /* bytes */
+    types[1] = blkidx_type;
 
     /* must be a struct in order to trigger flattening code */
     err = MPI_Type_create_struct(COUNT, blens, adispl, types, &combo);
@@ -630,23 +642,24 @@ int flatten_test(void)
     return errs;
 #undef COUNT
 }
+
 #undef check_err
 
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }
index cfe0733..50bac85 100644 (file)
 /* Inspired by the Intel MPI_Type_vector_blklen test.
    Added to include a test of a dataloop optimization that failed.
 */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     MPI_Datatype ot, ot2, newtype;
     int position, psize, insize, outsize;
-    signed char *inbuf=0, *outbuf=0, *pbuf=0, *p;
-    int  i, j, k;
-    int  errs = 0;
-    int  veccount=16, stride=16;
+    signed char *inbuf = 0, *outbuf = 0, *pbuf = 0, *p;
+    int i, j, k;
+    int errs = 0;
+    int veccount = 16, stride = 16;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
     /*
      * Create a type with some padding
      */
-    MPI_Type_contiguous( 59, MPI_CHAR, &ot );
-    MPI_Type_create_resized( ot, 0, 64, &ot2 );
+    MPI_Type_contiguous(59, MPI_CHAR, &ot);
+    MPI_Type_create_resized(ot, 0, 64, &ot2);
     /*
-      Use a vector type with a block size equal to the stride - thus
-      tiling the target memory with copies of old type.  This is not
-      a contiguous copy since oldtype has a gap at the end.
-    */
-    MPI_Type_vector( veccount, stride, stride, ot2, &newtype );
-    MPI_Type_commit( &newtype );
+     * Use a vector type with a block size equal to the stride - thus
+     * tiling the target memory with copies of old type.  This is not
+     * a contiguous copy since oldtype has a gap at the end.
+     */
+    MPI_Type_vector(veccount, stride, stride, ot2, &newtype);
+    MPI_Type_commit(&newtype);
 
     insize = veccount * stride * 64;
     outsize = insize;
-    inbuf = (char *)malloc( insize );
-    outbuf = (char *)malloc( outsize );
-    for (i=0; i<outsize; i++) {
+    inbuf = (char *) malloc(insize);
+    outbuf = (char *) malloc(outsize);
+    for (i = 0; i < outsize; i++) {
         inbuf[i] = i % 64;
         outbuf[i] = -1;
     }
 
-    MPI_Pack_size( 1, newtype, MPI_COMM_WORLD, &psize );
-    pbuf = (char *)malloc( psize );
+    MPI_Pack_size(1, newtype, MPI_COMM_WORLD, &psize);
+    pbuf = (char *) malloc(psize);
 
     position = 0;
-    MPI_Pack( inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD );
-    psize    = position;
+    MPI_Pack(inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD);
+    psize = position;
     position = 0;
-    MPI_Unpack( pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD );
+    MPI_Unpack(pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD);
 
 
     /* Check the output */
     p = outbuf;
-    for (i=0; i<veccount; i++) {
-        for (j=0; j<stride; j++) {
-            for (k=0; k<59; k++) {
+    for (i = 0; i < veccount; i++) {
+        for (j = 0; j < stride; j++) {
+            for (k = 0; k < 59; k++) {
                 if (*p != k % 64) {
                     errs++;
-                    fprintf( stderr, "[%d,%d,%d]expected %d but saw %d\n",
-                             i, j, k, (k%64), *p );
+                    fprintf(stderr, "[%d,%d,%d]expected %d but saw %d\n", i, j, k, (k % 64), *p);
                 }
                 p++;
             }
-            for (k=59; k<64; k++) {
+            for (k = 59; k < 64; k++) {
                 if (*p != -1) {
                     errs++;
-                    fprintf( stderr, "[%d,%d,%d]expected -1 but saw %d\n",
-                             i, j, k, *p );
+                    fprintf(stderr, "[%d,%d,%d]expected -1 but saw %d\n", i, j, k, *p);
                 }
                 p++;
             }
         }
     }
 
-    free( pbuf );
-    free( inbuf );
-    free( outbuf );
+    free(pbuf);
+    free(inbuf);
+    free(outbuf);
 
-    MPI_Type_free( &ot );
-    MPI_Type_free( &ot2 );
-    MPI_Type_free( &newtype );
-    MTest_Finalize( errs );
+    MPI_Type_free(&ot);
+    MPI_Type_free(&ot2);
+    MPI_Type_free(&newtype);
+    MTest_Finalize(errs);
     MPI_Finalize();
 
     return 0;
index ce51f19..ff1e123 100644 (file)
@@ -3,36 +3,34 @@
  *
  *  (C) 2003 by Argonne National Laboratory.
  *      See COPYRIGHT in top-level directory.
- */     
+ */
 
 #include <mpi.h>
 #include <stdio.h>
-int main(int argc, charargv[])
+int main(int argc, char *argv[])
 {
-       int iam, np;
-       int m = 2, n = 0, lda = 1;
-       double A[2];
-       MPI_Comm comm = MPI_COMM_WORLD;
-       MPI_Datatype type = MPI_DOUBLE, vtype;
+    int iam, np;
+    int m = 2, n = 0, lda = 1;
+    double A[2];
+    MPI_Comm comm = MPI_COMM_WORLD;
+    MPI_Datatype type = MPI_DOUBLE, vtype;
 
-       MPI_Init(&argc,&argv);
-       MPI_Comm_size(comm, &np);
-       MPI_Comm_rank(comm, &iam);
-       if (np < 2) {
-               printf( "Should be at least 2 processes for the test\n");
-        } else {
-               MPI_Type_vector(n, m, lda, type, &vtype);
-               MPI_Type_commit(&vtype);
-               A[0] = -1.0-0.1*iam;
-               A[1] = 0.5+0.1*iam;
-               printf("In process %i of %i before Bcast: A = %f,%f\n",
-                      iam, np, A[0], A[1] );
-               MPI_Bcast(A, 1, vtype, 0, comm);
-               printf("In process %i of %i after Bcast: A = %f,%f\n",
-                      iam, np, A[0], A[1]);
-               MPI_Type_free(&vtype);
-       }
+    MPI_Init(&argc, &argv);
+    MPI_Comm_size(comm, &np);
+    MPI_Comm_rank(comm, &iam);
+    if (np < 2) {
+        printf("Should be at least 2 processes for the test\n");
+    }
+    else {
+        MPI_Type_vector(n, m, lda, type, &vtype);
+        MPI_Type_commit(&vtype);
+        A[0] = -1.0 - 0.1 * iam;
+        A[1] = 0.5 + 0.1 * iam;
+        printf("In process %i of %i before Bcast: A = %f,%f\n", iam, np, A[0], A[1]);
+        MPI_Bcast(A, 1, vtype, 0, comm);
+        printf("In process %i of %i after Bcast: A = %f,%f\n", iam, np, A[0], A[1]);
+        MPI_Type_free(&vtype);
+    }
 
-       MPI_Finalize();
-   return(0);
+    MPI_Finalize();
 }
index 0c5d390..c9ed61f 100644 (file)
@@ -7,7 +7,7 @@
 #include "mpi.h"
 #include "mpitest.h"
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     int position, pack_size, i;
@@ -17,13 +17,13 @@ int main( int argc, char *argv[] )
     int recv_buffer[60];
     int pack_buffer[1000];
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     /* Initialize data in the buffers */
-    for (i=0; i<60; i++) {
-       send_buffer[i] = i;
-       recv_buffer[i] = -1;
-       pack_buffer[i] = -2;
+    for (i = 0; i < 60; i++) {
+        send_buffer[i] = i;
+        recv_buffer[i] = -1;
+        pack_buffer[i] = -2;
     }
 
     /* Create an indexed type with an empty first block */
@@ -37,32 +37,28 @@ int main( int argc, char *argv[] )
     MPI_Type_commit(&type);
 
     position = 0;
-    MPI_Pack( send_buffer, 1, type, pack_buffer, sizeof(pack_buffer), 
-             &position, MPI_COMM_WORLD );
+    MPI_Pack(send_buffer, 1, type, pack_buffer, sizeof(pack_buffer), &position, MPI_COMM_WORLD);
     pack_size = position;
     position = 0;
-    MPI_Unpack( pack_buffer, pack_size, &position, recv_buffer, 1, type, 
-               MPI_COMM_WORLD );
+    MPI_Unpack(pack_buffer, pack_size, &position, recv_buffer, 1, type, MPI_COMM_WORLD);
 
     /* Check that the last 40 entries of the recv_buffer have the corresponding
-       elements from the send buffer */
-    for (i=0; i<20; i++) {
-       if (recv_buffer[i] != -1) {
-           errs++;
-           fprintf( stderr, "recv_buffer[%d] = %d, should = -1\n", i, 
-                    recv_buffer[i] );
-       }
+     * elements from the send buffer */
+    for (i = 0; i < 20; i++) {
+        if (recv_buffer[i] != -1) {
+            errs++;
+            fprintf(stderr, "recv_buffer[%d] = %d, should = -1\n", i, recv_buffer[i]);
+        }
     }
-    for (i=20; i<60; i++) {
-       if (recv_buffer[i] != i) {
-           errs++;
-           fprintf( stderr, "recv_buffer[%d] = %d, should = %d\n", i, 
-                    recv_buffer[i], i );
-       }
+    for (i = 20; i < 60; i++) {
+        if (recv_buffer[i] != i) {
+            errs++;
+            fprintf(stderr, "recv_buffer[%d] = %d, should = %d\n", i, recv_buffer[i], i);
+        }
     }
-    MPI_Type_free( &type );
+    MPI_Type_free(&type);
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 
index 2ad786f..ecb212a 100644 (file)
@@ -7,31 +7,29 @@
 
 #include <stdio.h>
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     MPI_Datatype newtype;
     int b[1], d[1];
 
-    MPI_Init( &argc, &argv );
+    MPI_Init(&argc, &argv);
 
-    /* create a legitimate type to see that we don't 
+    /* create a legitimate type to see that we don't
      * emit spurious errors.
      */
-    MPI_Type_hvector( 0, 1, 10, MPI_DOUBLE, &newtype );
-    MPI_Type_commit( &newtype );
-    MPI_Type_free( &newtype );
+    MPI_Type_hvector(0, 1, 10, MPI_DOUBLE, &newtype);
+    MPI_Type_commit(&newtype);
+    MPI_Type_free(&newtype);
 
-    MPI_Type_indexed( 0, b, d, MPI_DOUBLE, &newtype );
-    MPI_Type_commit( &newtype );
+    MPI_Type_indexed(0, b, d, MPI_DOUBLE, &newtype);
+    MPI_Type_commit(&newtype);
 
-    MPI_Sendrecv( b, 1, newtype, 0, 0, 
-                 d, 0, newtype, 0, 0, 
-                 MPI_COMM_WORLD, MPI_STATUS_IGNORE );
+    MPI_Sendrecv(b, 1, newtype, 0, 0, d, 0, newtype, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
 
-    printf( " No Errors\n" );
+    printf(" No Errors\n");
+
+    MPI_Type_free(&newtype);
 
-    MPI_Type_free( &newtype );
-    
     MPI_Finalize();
 
     return 0;