2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Wed Oct 30 2002 */
3 /* no-error-probe-any_tag.c -- do some MPI calls without any errors */
11 main (int argc, char **argv)
15 char processor_name[128];
20 MPI_Request req0, req1;
23 MPI_Init (&argc, &argv);
24 MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
25 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
26 MPI_Get_processor_name (processor_name, &namelen);
27 printf ("(%d) is alive on %s\n", rank, processor_name);
30 MPI_Barrier (MPI_COMM_WORLD);
32 /* use probe to guarantee msg has arrived when blocking recv is called */
35 printf ("not enough tasks\n");
42 MPI_Isend (&i, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req0);
44 MPI_Isend (&x, 1, MPI_DOUBLE, 1, 1, MPI_COMM_WORLD, &req1);
46 MPI_Wait (&req1, &status);
48 MPI_Wait (&req0, &status);
52 for (j = 0; j < 2; j++) {
53 MPI_Probe (0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
55 if (status.MPI_TAG == 0)
56 MPI_Recv (&i, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
58 MPI_Recv (&x, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &status);
62 MPI_Barrier (MPI_COMM_WORLD);
65 printf ("(%d) Finished normally\n", rank);