Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #181 from bcamus/master
[simgrid.git] / teshsuite / smpi / isp / umpire / errhandler-no-free.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) */
3
4 /* errhandler-no-error.c -- construct some MPI_Errhandlers and free them */
5
6 #ifndef lint
7 static char *rcsid =
8   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/errhandler-no-free.c,v 1.1 2002/05/29 16:09:48 bronis Exp $";
9 #endif
10
11 #include <stdio.h>
12 #include <string.h>
13 #include "mpi.h"
14
15 /* multiple instances of same errhandler to exercise more Umpire code... */
16 #define ERRHANDLER_COUNT  5
17
18
19
20 void
21 myErrhandler (MPI_Comm *comm, int *errorcode, ...)
22 {
23   char      buf[MPI_MAX_ERROR_STRING];
24   int       error_strlen;
25
26   /* print alert */
27   fprintf (stderr, "Caught an MPI Error! Time to abort!\n");
28
29   /* get and print MPI error message... */
30   MPI_Error_string (*(errorcode), buf, &error_strlen);
31   fprintf (stderr, "%s\n", buf);
32
33   MPI_Abort (*comm, *errorcode);
34
35   return;
36 }
37
38
39 int
40 main (int argc, char **argv)
41 {
42   int nprocs = -1;
43   int rank = -1;
44   MPI_Comm comm = MPI_COMM_WORLD;
45   int i;
46   char processor_name[128];
47   int namelen = 128;
48   MPI_Errhandler newerrhandler[ERRHANDLER_COUNT];
49
50   /* init */
51   MPI_Init (&argc, &argv);
52   MPI_Comm_size (comm, &nprocs);
53   MPI_Comm_rank (comm, &rank);
54   MPI_Get_processor_name (processor_name, &namelen);
55   printf ("(%d) is alive on %s\n", rank, processor_name);
56   fflush (stdout);
57
58   MPI_Barrier (comm);
59
60   for (i = 0; i < ERRHANDLER_COUNT; i++)
61     MPI_Errhandler_create (myErrhandler, &newerrhandler[i]);
62
63   MPI_Barrier (comm);
64
65   printf ("(%d) Finished normally\n", rank);
66   MPI_Finalize ();
67 }
68
69 /* EOF */