7 int main(
int narg,
char **arg)
10 MPI_Comm comm = MPI_COMM_WORLD;
13 MPI_Comm_rank(comm, &me);
14 MPI_Comm_size(comm, &np);
17 int *ids =
new int[np/2+1];
18 for (
int i = 0; i < np/2+1; i++) ids[i] = i;
20 for (
int i = 0; i < niter; i++) {
23 MPI_Comm_group(comm, &cgrp);
24 MPI_Group_incl(cgrp, np/2+1, ids, &agrp);
26 MPI_Comm_create(comm, agrp, &a);
28 MPI_Group_free(&agrp);
29 MPI_Group_free(&cgrp);
31 if (a != MPI_COMM_NULL) {
33 MPI_Comm_size(a, &anp);
34 std::cout << me <<
" Iteration " << i <<
" New comm has " << anp <<
" ranks"
39 std::cout << me <<
" not in new communicator" << std::endl;
44 std::cout <<
"PASS" << std::endl;
int main(int argc, char *argv[])