16 int main(
int narg,
char **arg)
18 MPI_Init(&narg, &arg);
19 MPI_Comm comm = MPI_COMM_WORLD;
22 MPI_Comm_rank(comm, &me);
23 MPI_Comm_size(comm, &np);
26 int *ids =
new int[np/2+1];
27 for (
int i = 0; i < np/2+1; i++) ids[i] = i;
29 for (
int i = 0; i < niter; i++) {
32 MPI_Comm_group(comm, &cgrp);
33 MPI_Group_incl(cgrp, np/2+1, ids, &agrp);
35 MPI_Comm_create(comm, agrp, &a);
37 MPI_Group_free(&agrp);
38 MPI_Group_free(&cgrp);
40 if (a != MPI_COMM_NULL) {
42 MPI_Comm_size(a, &anp);
43 std::cout << me <<
" Iteration " << i <<
" New comm has " << anp <<
" ranks"
48 std::cout << me <<
" not in new communicator" << std::endl;
53 std::cout <<
"PASS" << std::endl;
int main(int argc, char *argv[])