1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Test comm split";
16 int main( int argc, char *argv[] )
19 int rank, size, color, srank;
22 MTest_Init( &argc, &argv );
24 MPI_Comm_dup( MPI_COMM_WORLD, &comm );
26 MPI_Comm_rank( comm, &rank );
27 MPI_Comm_size( comm, &size );
30 fprintf( stderr, "This test requires at least four processes." );
31 MPI_Abort( MPI_COMM_WORLD, 1 );
34 color = MPI_UNDEFINED;
35 if (rank < 2) color = 1;
36 MPI_Comm_split( comm, color, size - rank, &scomm );
39 /* Check that the ranks are ordered correctly */
40 MPI_Comm_rank( scomm, &srank );
41 if (srank != 1 - rank) {
44 MPI_Comm_free( &scomm );
47 if (scomm != MPI_COMM_NULL) {
51 MPI_Comm_free( &comm );
52 MTest_Finalize( errs );