1 #include "mpi.h"
2 #include <stdio.h>
3
main(int argc,char * argv[])4 int main( int argc, char *argv[] )
5 {
6 int errs = 0;
7 int size, dims[2], periods[2], remain[2];
8 int result;
9 MPI_Comm comm, newcomm;
10
11 MPI_Init( &argc, &argv );
12
13 /* First, create a 1-dim cartesian communicator */
14 periods[0] = 0;
15 MPI_Comm_size( MPI_COMM_WORLD, &size );
16 dims[0] = size;
17 MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm );
18
19 /* Now, extract a communicator with no dimensions */
20 remain[0] = 0;
21 MPI_Cart_sub( comm, remain, &newcomm );
22
23 /* This should be congruent to MPI_COMM_SELF */
24 MPI_Comm_compare( MPI_COMM_SELF, newcomm, &result );
25 if (result != MPI_CONGRUENT) {
26 errs++;
27 printf( "cart sub to size 0 did not give self\n" );fflush(stdout);
28 }
29
30 /* Free the new communicator */
31 MPI_Comm_free( &newcomm );
32 MPI_Comm_free( &comm );
33
34 MPI_Finalize();
35 return 0;
36 }
37