2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) */
4 /* errhandler-no-error.c -- construct some MPI_Errhandlers and free them */
8 "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/errhandler-no-error.c,v 1.1 2002/05/29 16:09:47 bronis Exp $";
15 /* multiple instances of same errhandler to exercise more Umpire code... */
16 #define ERRHANDLER_COUNT 5
21 myErrhandler (MPI_Comm *comm, int *errorcode, ...)
23 char buf[MPI_MAX_ERROR_STRING];
27 fprintf (stderr, "Caught an MPI Error! Time to abort!\n");
29 /* get and print MPI error message... */
30 MPI_Error_string (*(errorcode), buf, &error_strlen);
31 fprintf (stderr, "%s\n", buf);
33 MPI_Abort (*comm, *errorcode);
40 main (int argc, char **argv)
44 int comm = MPI_COMM_WORLD;
46 char processor_name[128];
48 MPI_Errhandler newerrhandler[ERRHANDLER_COUNT];
49 MPI_Errhandler newerrhandler2[ERRHANDLER_COUNT];
52 MPI_Init (&argc, &argv);
53 MPI_Comm_size (comm, &nprocs);
54 MPI_Comm_rank (comm, &rank);
55 MPI_Get_processor_name (processor_name, &namelen);
56 printf ("(%d) is alive on %s\n", rank, processor_name);
61 for (i = 0; i < ERRHANDLER_COUNT; i++)
62 MPI_Errhandler_create (myErrhandler, &newerrhandler[i]);
64 for (i = 0; i < ERRHANDLER_COUNT; i++)
65 MPI_Errhandler_free (&newerrhandler[i]);
69 /* now with an alias... */
71 for (i = 0; i < ERRHANDLER_COUNT; i++)
72 MPI_Errhandler_create (myErrhandler, &newerrhandler[i]);
74 for (i = 0; i < ERRHANDLER_COUNT; i++) {
75 newerrhandler2[i] = newerrhandler[i];
76 MPI_Errhandler_free (&newerrhandler2[i]);
81 printf ("(%d) Finished normally\n", rank);