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];
23 MPI_Group world_group, dgroup;
25 int dims[TWOD], periods[TWOD];
29 MPI_Init (&argc, &argv);
30 MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
31 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
32 MPI_Get_processor_name (processor_name, &namelen);
33 printf ("(%d) is alive on %s\n", rank, processor_name);
36 MPI_Barrier (MPI_COMM_WORLD);
39 printf ("not enough tasks\n");
42 /* create a 2 X nprocs/2 torus topology, allow reordering */
45 periods[0] = periods[1] = 1;
46 MPI_Cart_create (MPI_COMM_WORLD, TWOD, dims, periods, 1, &comm);
48 if (comm != MPI_COMM_NULL) {
49 MPI_Comm_size (comm, &dnprocs);
50 MPI_Comm_rank (comm, &drank);
54 memset (buf0, 0, buf_size);
56 MPI_Recv (buf1, buf_size, MPI_INT, 1, 0, comm, &status);
58 MPI_Send (buf0, buf_size, MPI_INT, 1, 0, comm);
60 else if (drank == 1) {
61 memset (buf1, 1, buf_size);
63 MPI_Recv (buf0, buf_size, MPI_INT, 0, 0, comm, &status);
65 MPI_Send (buf1, buf_size, MPI_INT, 0, 0, comm);
69 printf ("(%d) Derived communicator too small (size = %d)\n",
73 MPI_Comm_free (&comm);
76 printf ("(%d) Got MPI_COMM_NULL\n", rank);
80 MPI_Barrier (MPI_COMM_WORLD);
83 printf ("(%d) Finished normally\n", rank);