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.
13 static char MTEST_Descrip[] = "Test MPI_Exscan (simple test)";
16 int main(int argc, char *argv[])
20 int sendbuf[1], recvbuf[1];
23 MTest_Init(&argc, &argv);
25 comm = MPI_COMM_WORLD;
26 MPI_Comm_rank(comm, &rank);
27 MPI_Comm_size(comm, &size);
32 MPI_Exscan(sendbuf, recvbuf, 1, MPI_INT, MPI_SUM, comm);
34 /* Check the results. rank 0 has no data. Input is
35 * 0 1 2 3 4 5 6 7 8 ...
37 * - 0 1 3 6 10 15 21 28 36
38 * (scan, not counting the contribution from the calling process)
41 int result = (((rank) * (rank - 1)) / 2);
42 /* printf("%d: %d\n", rank, result); */
43 if (recvbuf[0] != result) {
45 fprintf(stderr, "Error in recvbuf = %d on %d, expected %d\n", recvbuf[0], rank, result);
48 else if (recvbuf[0] != -2) {
50 fprintf(stderr, "Error in recvbuf on zero, is %d\n", recvbuf[0]);