Blocking send and receive

 


c     This program sends isbuf of process 0 to irbuf of process 1

      PROGRAM SEND
      INCLUDE 'mpif.h'
      INTEGER istatus(MPI_STATUS_SIZE)

      CALL MPI_INIT(IERR)
      CALL MPI_COMM_SIZE(MPI_COMM_WORLD, mprocs, ierr)
      CALL MPI_COMM_RANK(mpi_COMM_WORLD, myrank, ierr)

      itag = 1
      IF (myrank == 0) THEN
        isbuf =9
        CALL MPI_SEND(isbuf, 1, MPI_INTEGER, 1, itag,
     +                 MPI_COMM_WORLD, ierr)
      ELSEIF (myrank == 1) THEN
        CALL MPI_RECV( irbuf, 1, MPI_INTEGER, 0, itag,
     +                 MPI_COMM_WORLD, istatus, ierr)
        PRINT*, ' I RECEIVED irbuf =', irbuf
      ENDIF

      CALL MPI_FINALIZE(ierr)

      END