MPI_SEND, MPI_ISEND, MPI_RECV, MPI_IRECV, MPI_WAIT

Di seguito mostro la sintassi delle funzioni di comunicazione punto a punto:

MPI_SEND(variabile, quanti, tipo, destinazione, tag, comunicatore, ierr)

MPI_ISEND(variabile, quanti, tipo, destinazione, tag, comunicatore, richiesta, ierr)

MPI_RECV(variabile, quanti, tipo, sorgente, tag, comunicatore, stato, ierr)

MPI_IRECV(variabile, quanti, tipo, sorgente, tag, comunicatore, richiesta, ierr)

MPI_WAIT(richiesta, stato, ierr)

dove:

Le funzioni bloccanti e non bloccanti possono essere tranquillamente usate anche in modo incrociato come vedremo ad esempio nella descrizione delle comunicazioni unidirezionali.
Il processo ricevente va incontro ad un errore (buffer overflow) se gli viene spedito un quantitativo di dati superiore a quello che si aspetta, mentre non protesta se il quantitativo è inferiore alle aspettative.
Qui di seguito si riporta un esempio di utilizzo delle funzioni bloccanti:
 
      program esempio6
      include 'mpif.h' 
      integer nprocs, mype, ierr, itag, imesg
      integer istatus
      dimension istatus(MPI_STATUS_SIZE) 

      call MPI_INIT(ierr) 
      call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierr) 
      call MPI_COMM_RANK(MPI_COMM_WORLD, mype, ierr) 

      itag = 1
      imesg = mype
      if(mype.eq.1) then
      call MPI_SEND(imesg,1,MPI_INTEGER,0,itag,MPI_COMM_WORLD,ierr)
      elseif(mype.eq.0) then
      call MPI_RECV(imesg,1,MPI_INTEGER,1,itag,MPI_COMM_WORLD,
     +              istatus,ierr)
      write(6,*) 'messaggio = ', imesg
      endif

      call MPI_FINALIZE(ierr) 
      end