Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge remote-tracking branch 'origin/libdw2'
[simgrid.git] / teshsuite / smpi / mpich3-test / group / groupnullincl.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include "mpi.h"
8 #include <stdio.h>
9 #include "mpitest.h"
10
11 int main( int argc, char *argv[] )
12 {
13     int errs = 0;
14     int rc, result;
15     int ranks[1];
16     MPI_Group group, outgroup;
17     MPI_Comm comm;
18
19     MTest_Init( &argc, &argv );
20     /* To improve reporting of problems about operations, we
21        change the error handler to errors return */
22     MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
23
24     while (MTestGetComm( &comm, 1 )) {
25         if (comm == MPI_COMM_NULL) continue;
26
27         MPI_Comm_group( comm, &group );
28         rc = MPI_Group_incl( group, 0, 0, &outgroup );
29         if (rc) {
30             errs++;
31             MTestPrintError( rc );
32             printf( "Error in creating an empty group with (0,0)\n" );
33             
34             /* Some MPI implementations may reject a null "ranks" pointer */
35             rc = MPI_Group_incl( group, 0, ranks, &outgroup );
36             if (rc) {
37                 errs++;
38                 MTestPrintError( rc );
39                 printf( "Error in creating an empty group with (0,ranks)\n" );
40             }
41         }
42
43         if (outgroup != MPI_GROUP_EMPTY) {
44             /* Is the group equivalent to group empty? */
45             rc = MPI_Group_compare( outgroup, MPI_GROUP_EMPTY, &result );
46             if (result != MPI_IDENT) {
47                 errs++;
48                 MTestPrintError( rc );
49                 printf( "Did not create a group equivalent to an empty group\n" );
50             }
51         }
52         rc = MPI_Group_free( &group );
53         if (rc) {
54             errs++;
55             MTestPrintError( rc );
56         }           
57         if (outgroup != MPI_GROUP_NULL) {
58             rc = MPI_Group_free( &outgroup );
59             if (rc) {
60                 errs++;
61                 MTestPrintError( rc );
62             }
63         }
64
65         MTestFreeComm( &comm );
66     }
67     
68     MTest_Finalize( errs );
69     MPI_Finalize();
70     return 0;
71   
72 }