2 /* Creator: Jeffrey Vetter (vetter3@llnl.gov) Thu Feb 24 2000 */
6 "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/comm-translate-ranks.c,v 1.1.1.1 2000/08/23 17:28:26 vetter Exp $";
16 main (int argc, char **argv)
20 MPI_Comm comm = MPI_COMM_WORLD;
21 char processor_name[128];
31 MPI_Init (&argc, &argv);
32 MPI_Comm_size (comm, &nprocs);
33 MPI_Comm_rank (comm, &rank);
34 MPI_Get_processor_name (processor_name, &namelen);
35 printf ("(%d) is alive on %s\n", rank, processor_name);
43 MPI_Comm_split (comm, color, key, &newcomm);
45 MPI_Comm_size (newcomm, &nsize);
46 MPI_Comm_rank (newcomm, &nrank);
47 printf ("world task %p/%d/%d maps to new comm task %p/%d/%d\n",
48 comm, nprocs, rank, newcomm, nsize, nrank);
53 /* after every comm constructor, fetch the rank translation from the
54 0 rank of that comm (assume that there is a 0). */
64 MPI_Comm_group (comm, &wcGroup);
65 MPI_Comm_group (newcomm, &ncGroup);
67 for (i = 0; i < nprocs; i++)
72 MPI_Group_translate_ranks (wcGroup, nprocs, wcRanks, ncGroup, ncRanks);
74 for (i = 0; i < nprocs; i++)
76 if (ncRanks[i] == MPI_UNDEFINED)
78 printf ("World rank %d ->\tUNDEFINED\n", wcRanks[i]);
82 printf ("World rank %d ->\t%d\n", wcRanks[i], ncRanks[i]);
89 printf ("(%d) Finished normally\n", rank);