- /* Check the results. rank 0 has no data */
- if (rank > 0) {
- int result;
- for (i=0; i<count; i++) {
- result = rank * i * size + ((rank) * (rank-1))/2;
- if (recvbuf[i] != result) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "Error in recvbuf[%d] = %d on %d, expected %d\n",
- i, recvbuf[i], rank, result );
- }
- }
- }
- }
+ for (i = 0; i < count; i++) {
+ sendbuf[i] = rank + i * size;
+ recvbuf[i] = -1;
+ }
+
+ MPI_Exscan(sendbuf, recvbuf, count, MPI_INT, MPI_SUM, comm);
+
+ /* Check the results. rank 0 has no data */
+ if (rank > 0) {
+ int result;
+ for (i = 0; i < count; i++) {
+ result = rank * i * size + ((rank) * (rank - 1)) / 2;
+ if (recvbuf[i] != result) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "Error in recvbuf[%d] = %d on %d, expected %d\n",
+ i, recvbuf[i], rank, result);
+ }
+ }
+ }
+ }