+ ranks = (int *) malloc(size * sizeof(int));
+ for (i = 0; i < size; i++)
+ ranks[i] = i;
+
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ for (i = 0; i < n; i++) {
+ rc = MPI_Group_incl(world_group, n_ranks, ranks, group_array + i);
+ if (rc) {
+ fprintf(stderr, "Error when creating group number %d\n", i);
+ MPI_Error_string(rc, msg, &len);
+ fprintf(stderr, "%s\n", msg);
+ n = i + 1;
+ break;
+ }
+ else {
+ /* Check that the group was created (and that any errors were
+ * caught) */
+ rc = MPI_Group_size(group_array[i], &group_size);
+ if (group_size != size) {
+ fprintf(stderr, "Group number %d not correct (size = %d)\n", i, size);
+ n = i + 1;
+ break;
+ }
+ }