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)
29 MPI_Comm_rank(comm, &rank);
31 MPI_Send(&buf, 1, MPI_INT, 0, 0, comm);
34 MPI_Comm_remote_size(comm, &remote_size);
35 MPI_Comm_rank(comm, &rank);
37 for (i = 0; i < remote_size; i++) {
39 MPI_Recv(&buf, 1, MPI_INT, i, 0, comm, &status);
42 fprintf(stderr, "buf = %d, should be %d\n", buf, i);
47 /* Now, reverse it and send back */
49 MPI_Comm_rank(comm, &rank);
51 MPI_Send(&buf, 1, MPI_INT, 0, 0, comm);
54 MPI_Comm_remote_size(comm, &remote_size);
55 MPI_Comm_rank(comm, &rank);
57 for (i = 0; i < remote_size; i++) {
59 MPI_Recv(&buf, 1, MPI_INT, i, 0, comm, &status);
62 fprintf(stderr, "buf = %d, should be %d\n", buf, i);