Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into CRTP
[simgrid.git] / teshsuite / smpi / mpich3-test / errhan / errfatal.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2004 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <mpi.h>
7 #include <stdio.h>
8
9 /* FIXME: This behavior of this test is implementation specific. */
10
11 static int verbose = 0;
12
13 int main(int argc, char **argv)
14 {
15     int MY_ERROR_CLASS;
16     int MY_ERROR_CODE;
17     char MY_ERROR_STRING[10];
18
19     sprintf(MY_ERROR_STRING, "MY ERROR");
20
21     MPI_Init(&argc, &argv);
22
23     if (verbose)
24         printf("Adding My Error Class\n");
25     MPI_Add_error_class(&MY_ERROR_CLASS);
26     if (verbose)
27         printf("Adding My Error Code\n");
28     MPI_Add_error_code(MY_ERROR_CLASS, &MY_ERROR_CODE);
29     if (verbose)
30         printf("Adding My Error String\n");
31     MPI_Add_error_string(MY_ERROR_CODE, MY_ERROR_STRING);
32
33     if (verbose)
34         printf("Calling Error Handler\n");
35     MPI_Comm_call_errhandler(MPI_COMM_WORLD, MY_ERROR_CODE);
36
37     /* We should not get here, because the default error handler
38      * is ERRORS_ARE_FATAL.  This makes sure that the correct error
39      * handler is called and that no failure occured (such as
40      * a SEGV) in Comm_call_errhandler on the default
41      * error handler. */
42     printf("After the Error Handler Has Been Called\n");
43
44     MPI_Finalize();
45     return 0;
46 }