Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the size of partial shared malloc tests.
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / simple-commit.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2001 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6
7 /* Tests that commit of a couple of basic types succeeds. */
8
9 #include "mpi.h"
10 #include <stdio.h>
11 #include "mpitestconf.h"
12 #ifdef HAVE_STRING_H
13 #include <string.h>
14 #endif
15
16 static int verbose = 0;
17
18 int parse_args(int argc, char **argv);
19
20 int main(int argc, char **argv)
21 {
22     int mpi_err, errs = 0;
23     MPI_Datatype type;
24
25     MPI_Init(&argc, &argv);
26     parse_args(argc, argv);
27
28     /* To improve reporting of problems about operations, we
29      * change the error handler to errors return */
30     MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
31
32     type = MPI_INT;
33     mpi_err = MPI_Type_commit(&type);
34     if (mpi_err != MPI_SUCCESS) {
35         if (verbose) {
36             fprintf(stderr, "MPI_Type_commit of MPI_INT failed.\n");
37         }
38         errs++;
39     }
40
41     type = MPI_FLOAT_INT;
42     mpi_err = MPI_Type_commit(&type);
43     if (mpi_err != MPI_SUCCESS) {
44         if (verbose) {
45             fprintf(stderr, "MPI_Type_commit of MPI_FLOAT_INT failed.\n");
46         }
47         errs++;
48     }
49
50     /* print message and exit */
51     if (errs) {
52         fprintf(stderr, "Found %d errors\n", errs);
53     }
54     else {
55         printf(" No Errors\n");
56     }
57     MPI_Finalize();
58     return 0;
59 }
60
61 int parse_args(int argc, char **argv)
62 {
63     /*
64      * int ret;
65      *
66      * while ((ret = getopt(argc, argv, "v")) >= 0)
67      * {
68      * switch (ret) {
69      * case 'v':
70      * verbose = 1;
71      * break;
72      * }
73      * }
74      */
75     if (argc > 1 && strcmp(argv[1], "-v") == 0)
76         verbose = 1;
77     return 0;
78 }