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);
46 /* To improve reporting of problems about operations, we
47 * change the error handler to errors return */
48 MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
52 err = MPI_Send(MPI_BOTTOM, 1, newtype, dest, 0, comm);
56 printf("MPI_Send did not return MPI_SUCCESS\n");
59 else if (rank == dest) {
61 err = MPI_Recv(MPI_BOTTOM, 1, newtype, source, 0, comm, &status);
65 printf("MPI_Recv did not return MPI_SUCCESS\n");
69 printf("Received %d but expected %d\n", ii, 2);
73 MPI_Comm_set_errhandler(comm, MPI_ERRORS_ARE_FATAL);
75 MPI_Type_free(&newtype);