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.
12 static char MTEST_Descrip[] = "Use of MPI_BOTTOM in communication";
15 int main( int argc, char *argv[] )
18 int rank, size, source, dest, len, ii;
21 MPI_Datatype newtype, oldtype;
24 MTest_Init( &argc, &argv );
26 MPI_Get_address( &ii, &disp );
30 MPI_Type_create_struct( 1, &len, &disp, &oldtype, &newtype );
31 MPI_Type_commit( &newtype );
33 comm = MPI_COMM_WORLD;
35 MPI_Comm_size( comm, &size );
36 MPI_Comm_rank( comm, &rank );
40 fprintf( stderr, "This test requires at least two processes\n" );
41 MPI_Abort( MPI_COMM_WORLD, 1 );
47 /* To improve reporting of problems about operations, we
48 change the error handler to errors return */
49 MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
53 err = MPI_Send( MPI_BOTTOM, 1, newtype, dest, 0, comm );
56 MTestPrintError( err );
57 printf( "MPI_Send did not return MPI_SUCCESS\n" );
60 else if (rank == dest) {
62 err = MPI_Recv( MPI_BOTTOM, 1, newtype, source, 0, comm, &status );
64 MTestPrintError( err );
66 printf( "MPI_Recv did not return MPI_SUCCESS\n" );
70 printf( "Received %d but expected %d\n", ii, 2 );
74 MPI_Comm_set_errhandler( comm, MPI_ERRORS_ARE_FATAL );
76 MPI_Type_free( &newtype );
78 MTest_Finalize( errs );