Basic HTML version of Foils prepared August 29 98

Foil 31 Example: Performing a Sum

From Designing and Building Parallel Programs 3: MPI Message Passing System DoD Modernization Tutorial -- 1995-1998. by Ian Foster, Gina Goff, Ehtesham Hayder, Chuck Koelbel


1 rank = MPI_COMM_RANK( comm )
2 if (rank .eq. 0) then
3 read *, n
4 end if
5 call MPI_BCAST(n, 1, MPI_INTEGER, 0, comm )
6 lo = rank*n+1
7 hi = lo+n-1
8 sum = 0.0d0
9 do i = lo, hi
10 sum = sum + 1.0d0 / i
11 end do
12 call MPI_REDUCEALL( sum, sumout, 1, MPI_DOUBLE,
13 & MPI_ADD_DOUBLE, comm)

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Apr 11 1999