program main !---Testing wether messages are buffered on the current platform. ! (if messages are NOT buffered this program will deadlock) implicit none !--Include the mpi header file include 'mpif.h' integer ierr,myid,numprocs integer irc,tag1,tag2 integer status(MPI_STATUS_SIZE) real a,b !--Initialize MPI call MPI_INIT( ierr ) !--Who am I? --- get my rank=myid call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr ) !--How many processes in the global group? call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr ) print *, "Process ", myid, " of ", numprocs, " is alive" if (myid == 0) then a=0. b=1. else a=1. b=0. end if !--Exchange messages if (myid == 0) then call mpi_send(a,1,mpi_real,1,tag1,MPI_COMM_WORLD,ierr) call mpi_recv(b,1,mpi_real,1,tag2,MPI_COMM_WORLD,status,ierr) elseif (myid == 1) then call mpi_send(b,1,mpi_real,0,tag2,MPI_COMM_WORLD,ierr) call mpi_recv(a,1,mpi_real,0,tag1,MPI_COMM_WORLD,status,ierr) end if !--Finilize MPI call MPI_FINALIZE(irc) stop end