3 /* stdlib.h Needed for malloc declaration */
7 int main( int argc, char **argv )
9 int i, n, n_goal = 2048, n_all, rc, n_ranks, *ranks, rank, size, len;
10 MPI_Group *group_array, world_group;
11 char msg[MPI_MAX_ERROR_STRING];
13 MPI_Init( &argc, &argv );
14 MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
15 MPI_Comm_size( MPI_COMM_WORLD, &size );
16 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
19 group_array = (MPI_Group *)malloc( n * sizeof(MPI_Group) );
21 MPI_Comm_group( MPI_COMM_WORLD, &world_group );
24 ranks = (int *)malloc( size * sizeof(int) );
25 for (i=0; i<size; i++) ranks[i] = i;
28 rc = MPI_Group_incl( world_group, n_ranks, ranks, group_array + i );
30 fprintf( stderr, "Error when creating group number %d\n", i );
31 MPI_Error_string( rc, msg, &len );
32 fprintf( stderr, "%s\n", msg );
40 rc = MPI_Group_free( group_array + i );
42 fprintf( stderr, "Error when freeing group number %d\n", i );
43 MPI_Error_string( rc, msg, &len );
44 fprintf( stderr, "%s\n", msg );
49 MPI_Group_free( &world_group );
51 MPI_Reduce( &n, &n_all, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD );
53 /* printf( "Completed test of %d type creations\n", n_all ); */
54 if (n_all != n_goal) {
56 "This MPI implementation limits the number of groups that can be created\n\
57 This is allowed by the standard and is not a bug, but is a limit on the\n\
61 printf( " No Errors\n" );