program wave_spmd
C Learn number of tasks and taskid
call initialize task
call get task identification and information
C Identify left and right neighbors
C Get program parameters
read tpoints, nsteps
C Divide data amongst processes
read values
C Update values for each point along string
do t = 1, nsteps
C Send to left, receive from right
call send left endpoint to left neighbor
call receive left endpoint from right neighbor
C Send to right, receive from left
call send right endpoint to right neighbor
call receive right endpoint from left neighbor
C Update points along line
do i = 1, npoints
newval(i) = (2.0 * values(i)) - oldval(i)
& + (sqtau * (values(i-1) - (2.0 * values(i))
+ values(i+1)))
end do
end do
C Write results out to file
write values
call terminate parallel environment
Click here for a more fully-developed
pseudo code using MPI calls.
Click here for the complete program.