program example5 include 'mpif.h' integer ierr, size, rank real a, b integer status(MPI_STATUS_SIZE) call MPI_INIT(ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) a = 0.0 b = 0.0 if(rank .eq. 0) then b = 1.0 call MPI_SEND(b, 1, MPI_REAL, 1, 5, & MPI_COMM_WORLD, ierr); call MPI_RECV(a, 1, MPI_REAL, 1, 5, & MPI_COMM_WORLD, status, ierr); else if(rank .eq. 1) then a = 2.0 call MPI_RECV(b, 1, MPI_REAL, 0, 5, & MPI_COMM_WORLD, status, ierr); call MPI_SEND(a, 1, MPI_REAL, 0, 5, & MPI_COMM_WORLD, ierr); end if end if print *, 'process ', rank,' a = ', a, ', b = ', b call MPI_FINALIZE(ierr) end