include "mpiSim.f90" PROGRAM NoDeadlock include "useSim.f90" ! INCLUDE 'mpif.h' ! ! This example is from: ! "Introduction to MPI" – created by the PACS Training Group INTEGER myrank, ierr, status(MPI_STATUS_SIZE) REAL a(100), b(100) a=3 b=4 ! Initialize MPI: call MPI_INIT(ierr) ! Get my rank: call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr) ! Process 1 receives and sends; process 0 sends and receives if( myrank.eq.0 )then call MPI_RECV( b, 100, MPI_REAL, 1, 19, MPI_COMM_WORLD, status, ierr ) call MPI_SEND( a, 100, MPI_REAL, 1, 17, MPI_COMM_WORLD, ierr) else if ( myrank.eq.1 )then call MPI_SEND( a, 100, MPI_REAL, 0, 19, MPI_COMM_WORLD, ierr ) call MPI_RECV( b, 100, MPI_REAL, 0, 17, MPI_COMM_WORLD, status, ierr ) endif ! Wrap up call MPI_FINALIZE(ierr) write(*,*) "No Deadlock is all done." END PROGRAM NoDeadlock