c********************************************************************** c c This program deadlocks using MPI/F c M.G.N. 2001 c c**********************************************************************/ program main include 'mpif.h' implicit none integer ierr,whoami,npes,status double precision a,b C C Initialize environment C call mpi_init(ierr) call mpi_comm_rank(MPI_COMM_WORLD, whoami, ierr) call mpi_comm_size(MPI_COMM_WORLD, npes, ierr) if (npes .ne. 2) then write(*,*) 'Run on two processors only!' goto 555 endif a = 999.999 if (whoami.eq.0) then call MPI_send(a, 1, MPI_DOUBLE_PRECISION, 1, 1, > MPI_COMM_WORLD, status, ierr) call MPI_recv(b, 1, MPI_DOUBLE_PRECISION, 1, 2, > MPI_COMM_WORLD, status, ierr) write(*,*) 'Processor 0 got ',b,' from Processor 1' else call MPI_send(a, 1, MPI_DOUBLE_PRECISION, 0, 1, > MPI_COMM_WORLD, status, ierr) call MPI_recv(b, 1, MPI_DOUBLE_PRECISION, 0, 2, > MPI_COMM_WORLD, status, ierr) write(*,*) 'Processor 1 got ',b,' from Processor 0' endif 555 call mpi_finalize(ierr) ! Shut down and clean up MPI END