Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Ignore stdout/stderr of the umpire tests
[simgrid.git] / teshsuite / smpi / isp / umpire / no-error-probe.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Thu Jan 3 2002 */
3 /* no-error-probe.c -- do some MPI calls without any errors */
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   int i, j;
18   double x;
19   MPI_Status status;
20
21   /* init */
22   MPI_Init (&argc, &argv);
23   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
24   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
25   MPI_Get_processor_name (processor_name, &namelen);
26   printf ("(%d) is alive on %s\n", rank, processor_name);
27   fflush (stdout);
28
29   MPI_Barrier (MPI_COMM_WORLD);
30
31   if (nprocs < 2)
32     {
33       printf ("not enough tasks\n");
34     }
35   else if (rank == 0)
36     {
37       i = 0;
38
39       MPI_Send (&i, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
40
41       MPI_Probe (1, 0, MPI_COMM_WORLD, &status);
42       
43       MPI_Recv (&x, 1, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD, &status);
44     }
45   else if (rank == 1)
46     {
47       x = 1.0;
48
49       MPI_Probe (0, 0, MPI_COMM_WORLD, &status);
50
51       MPI_Recv (&i, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
52
53       MPI_Send (&x, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
54     }
55       
56   MPI_Barrier (MPI_COMM_WORLD);
57
58   MPI_Finalize ();
59   printf ("(%d) Finished normally\n", rank);
60 }
61
62 /* EOF */