Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix [#17799] : have mpi_group_range_incl and mpi_group_range_excl better test some...
[simgrid.git] / teshsuite / smpi / mpich3-test / topo / cartcreates.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 size, rank;
15     int dims[2], periods[2];
16     MPI_Comm comm;
17
18     MTest_Init( &argc, &argv );
19
20     /* Create a new cartesian communicator in a subset of the processes */
21     MPI_Comm_size( MPI_COMM_WORLD, &size );
22     MPI_Comm_rank( MPI_COMM_WORLD, &rank );
23     if (size < 2) {
24         fprintf( stderr, "This test needs at least 2 processes\n" );
25         MPI_Abort( MPI_COMM_WORLD, 1 );
26     }
27     dims[0]    = size-1;
28     periods[0] = 1;
29     MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm );
30
31     if (comm != MPI_COMM_NULL) {
32         int csize;
33         MPI_Comm_size( comm, &csize );
34         if (csize != dims[0]) {
35             errs++;
36             fprintf( stderr, 
37              "Sizes is wrong in cart communicator.  Is %d, should be %d\n", 
38              csize, dims[0] ); 
39         }
40         MPI_Barrier( comm );
41
42         MPI_Comm_free( &comm );
43     } 
44     else if (rank < dims[0]) {
45         errs++;
46         fprintf( stderr, "Communicator returned is null!" );
47     }
48
49     MTest_Finalize( errs );
50
51     MPI_Finalize();
52
53     return 0;
54 }