4 #if defined(NEEDS_STDLIB_PROTOTYPES)
8 int main( int argc, char **argv )
10 int rank, size, i, len, actlen, expected_len;
16 MPI_Init( &argc, &argv );
17 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
18 MPI_Comm_size( MPI_COMM_WORLD, &size );
21 fprintf( stderr, "This test requires more than 2 proceses\n" );
27 MPI_Recv_init( data, len, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG,
28 MPI_COMM_WORLD, &rq );
29 for (i=1; i<size; i++) {
30 printf( "Receiving message %d\n", i );
32 MPI_Wait( &rq, &status );
33 if (status.MPI_SOURCE != status.MPI_TAG) {
34 printf( "Error in received message (source and tag)\n" );
35 printf( "Source was %d and tag was %d\n",
36 status.MPI_SOURCE, status.MPI_TAG );
38 MPI_Get_count( &status, MPI_DOUBLE, &actlen );
39 expected_len = (status.MPI_SOURCE < 10) ? status.MPI_SOURCE * 10 :
41 if (actlen != expected_len) {
42 printf( "Got %d words, expected %d words\n", actlen,
45 printf( "Received message %d\n", i );
47 MPI_Request_free( &rq );
48 printf( "Completed all receives\n" );
51 MPI_Send( data, (rank < 10) ? rank * 10 : 100,
52 MPI_DOUBLE, 0, rank, MPI_COMM_WORLD );