program main include 'mpif.h' integer ierr, rank real sendbuf(10) real recvbuf(10) integer count, tag call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) count = 10 tag = 0 if (rank == 0) then print *, 'Hello world! I am proc ', rank, 1 ', waiting for message from proc 1' call MPI_RECV(recvbuf, count, MPI_REAL, 1 1, tag, MPI_COMM_WORLD, status, ierr) call MPI_SEND(sendbuf, count, MPI_REAL, 1 1, tag, MPI_COMM_WORLD, ierr) else if (rank == 1) then print *, 'Hello world! I am proc ', rank, 1 ', waiting for message for proc 0' call MPI_RECV(recvbuf, count, MPI_REAL, 1 0, tag, MPI_COMM_WORLD, status, ierr) call MPI_SEND(sendbuf, count, MPI_REAL, 1 0, tag, MPI_COMM_WORLD, ierr) endif print *, 'Proc ', rank, ' finished!!' call MPI_FINALIZE(ierr) end