2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) */
4 /* type-no-error-exhaustive.c -- use all group constructors correctly */
8 "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/remote_group-no-error.c,v 1.1 2002/07/30 21:34:43 bronis Exp $";
16 #define INTERCOMM_CREATE_TAG 666
20 main (int argc, char **argv)
24 MPI_Comm comm = MPI_COMM_WORLD;
25 char processor_name[128];
31 MPI_Comm intercomm = MPI_COMM_NULL;
34 MPI_Init (&argc, &argv);
35 MPI_Comm_size (comm, &nprocs);
36 MPI_Comm_rank (comm, &rank);
37 MPI_Get_processor_name (processor_name, &namelen);
38 printf ("(%d) is alive on %s\n", rank, processor_name);
44 printf ("requires at least 3 tasks\n");
47 /* create the groups */
48 /* need lots of stuff for this constructor... */
49 MPI_Comm_split (MPI_COMM_WORLD, rank % 3, nprocs - rank, &temp);
52 MPI_Intercomm_create (temp, 0, MPI_COMM_WORLD,
53 (((nprocs % 3) == 2) && ((rank % 3) == 2)) ?
54 nprocs - 1 : nprocs - (rank % 3) - (nprocs % 3),
55 INTERCOMM_CREATE_TAG, &intercomm);
57 MPI_Comm_remote_group (intercomm, &newgroup);
59 MPI_Comm_free (&intercomm);
62 MPI_Comm_group (temp, &newgroup);
65 MPI_Comm_free (&temp);
67 MPI_Group_free (&newgroup);
71 /* create the groups again and free with an alias... */
72 /* need lots of stuff for this constructor... */
73 MPI_Comm_split (MPI_COMM_WORLD, rank % 3, nprocs - rank, &temp);
76 MPI_Intercomm_create (temp, 0, MPI_COMM_WORLD,
77 (((nprocs % 3) == 2) && ((rank % 3) == 2)) ?
78 nprocs - 1 : nprocs - (rank % 3) - (nprocs % 3),
79 INTERCOMM_CREATE_TAG, &intercomm);
81 MPI_Comm_remote_group (intercomm, &newgroup);
83 MPI_Comm_free (&intercomm);
86 MPI_Comm_group (temp, &newgroup);
89 MPI_Comm_free (&temp);
92 MPI_Group_free (&newgroup2);
97 printf ("(%d) Finished normally\n", rank);