2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Fri Mar 17 2000 */
3 /* no-error.c -- do some MPI calls without any errors */
13 main (int argc, char **argv)
17 char processor_name[128];
24 int graph_index[] = { 2, 3, 4, 6 };
25 int graph_edges[] = { 1, 3, 0, 3, 0, 2 };
28 MPI_Init (&argc, &argv);
29 MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
30 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
31 MPI_Get_processor_name (processor_name, &namelen);
32 printf ("(%d) is alive on %s\n", rank, processor_name);
35 MPI_Barrier (MPI_COMM_WORLD);
38 printf ("not enough tasks\n");
41 /* create the graph on p.268 MPI: The Complete Reference... */
42 MPI_Graph_create (MPI_COMM_WORLD, GRAPH_SZ,
43 graph_index, graph_edges, 1, &comm);
45 if (comm != MPI_COMM_NULL) {
46 MPI_Comm_size (comm, &dnprocs);
47 MPI_Comm_rank (comm, &drank);
51 memset (buf0, 0, buf_size);
53 MPI_Recv (buf1, buf_size, MPI_INT, 1, 0, comm, &status);
55 MPI_Send (buf0, buf_size, MPI_INT, 1, 0, comm);
57 else if (drank == 1) {
58 memset (buf1, 1, buf_size);
60 MPI_Recv (buf0, buf_size, MPI_INT, 0, 0, comm, &status);
62 MPI_Send (buf1, buf_size, MPI_INT, 0, 0, comm);
66 printf ("(%d) Derived communicator too small (size = %d)\n",
70 MPI_Comm_free (&comm);
73 printf ("(%d) Got MPI_COMM_NULL\n", rank);
77 MPI_Barrier (MPI_COMM_WORLD);
80 printf ("(%d) Finished normally\n", rank);