program example4 include 'mpif.h' integer BUFSIZE parameter (BUFSIZE = 4 + MPI_BSEND_OVERHEAD) byte buf(BUFSIZE) integer rank, ierr, ibufsize, rbuf integer status(MPI_STATUS_SIZE) call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) if(rank .eq. 0) then call MPI_BUFFER_ATTACH(buf, BUFSIZE, ierr) call MPI_BSEND(rank, 1, MPI_INTEGER, 1, 5, & MPI_COMM_WORLD, ierr) call MPI_BUFFER_DETACH(buf, ibufsize, ierr) end if if(rank .eq. 1) then call MPI_RECV(rbuf, 1, MPI_INTEGER, 0, 5, & MPI_COMM_WORLD, status, ierr) print *, 'Process 1 received ', rbuf, ' from process ', & status(MPI_SOURCE) end if call MPI_FINALIZE(ierr) end