Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / teshsuite / smpi / isp / umpire / abort3.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Tue Oct 29 2002 */
3 /* abort3.c -- call MPI abort in task one... */
4
5
6 #include <stdio.h>
7 #include "mpi.h"
8
9
10 int
11 main (int argc, char **argv)
12 {
13   int nprocs = -1;
14   int rank = -1;
15   char processor_name[128];
16   int namelen = 128;
17
18   /* init */
19   MPI_Init (&argc, &argv);
20   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
21   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
22   MPI_Get_processor_name (processor_name, &namelen);
23   printf ("(%d) is alive on %s\n", rank, processor_name);
24   fflush (stdout);
25
26   MPI_Barrier (MPI_COMM_WORLD);
27
28   if (nprocs < 3) {
29     /* ensure that we have a non-manager that doesn't abort... */
30     printf ("not enough tasks\n");
31   }
32   else {
33     if (rank == 1) {
34       printf ("(%d) Aborting\n", rank);
35       MPI_Abort (MPI_COMM_WORLD, -1);
36     }
37   }
38
39   MPI_Barrier (MPI_COMM_WORLD);
40   MPI_Finalize ();
41   printf ("(%d) Finished normally\n", rank);
42 }
43
44 /* EOF */