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[] = "Simple test of intercommunicator send and receive";
15 int main( int argc, char *argv[] )
18 int leftGroup, buf, rank, remote_size, i;
22 MTest_Init( &argc, &argv );
24 while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
25 if (comm == MPI_COMM_NULL) continue;
28 MPI_Comm_rank( comm, &rank );
30 MPI_Send( &buf, 1, MPI_INT, 0, 0, comm );
33 MPI_Comm_remote_size( comm, &remote_size );
34 MPI_Comm_rank( comm, &rank );
36 for (i=0; i<remote_size; i++) {
38 MPI_Recv( &buf, 1, MPI_INT, i, 0, comm, &status );
41 fprintf( stderr, "buf = %d, should be %d\n", buf, i );
46 /* Now, reverse it and send back */
48 MPI_Comm_rank( comm, &rank );
50 MPI_Send( &buf, 1, MPI_INT, 0, 0, comm );
53 MPI_Comm_remote_size( comm, &remote_size );
54 MPI_Comm_rank( comm, &rank );
56 for (i=0; i<remote_size; i++) {
58 MPI_Recv( &buf, 1, MPI_INT, i, 0, comm, &status );
61 fprintf( stderr, "buf = %d, should be %d\n", buf, i );
69 MTest_Finalize( errs );