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 int comm = MPI_COMM_WORLD;
21 char processor_name[128];
32 MPI_Init (&argc, &argv);
33 MPI_Comm_size (comm, &nprocs);
34 MPI_Comm_rank (comm, &rank);
35 MPI_Get_processor_name (processor_name, &namelen);
36 printf ("(%d) is alive on %s\n", rank, processor_name);
44 MPI_Comm_split (comm, color, key, &newcomm);
46 MPI_Comm_size (newcomm, &nsize);
47 MPI_Comm_rank (newcomm, &nrank);
48 printf ("world task %d/%d/%d maps to new comm task %d/%d/%d\n",
49 comm, nprocs, rank, newcomm, nsize, nrank);
54 /* after every comm constructor, fetch the rank translation from the
55 0 rank of that comm (assume that there is a 0). */
65 MPI_Comm_group (comm, &wcGroup);
66 MPI_Comm_group (newcomm, &ncGroup);
68 for (i = 0; i < nprocs; i++)
73 MPI_Group_translate_ranks (wcGroup, nprocs, wcRanks, ncGroup, ncRanks);
75 for (i = 0; i < nprocs; i++)
77 if (ncRanks[i] == MPI_UNDEFINED)
79 printf ("World rank %d ->\tUNDEFINED\n", wcRanks[i]);
83 printf ("World rank %d ->\t%d\n", wcRanks[i], ncRanks[i]);
90 printf ("(%d) Finished normally\n", rank);