Basic HTML version of Foils prepared 19 September 98

Foil 52 Example Fortran: Performing a Sum

From MPI Message Passing Interface Computational Science for Simulations -- Fall Semester 1998. by Geoffrey C. Fox, Nancy McCracken


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

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