program example6 include 'mpif.h' integer ierr, size, rank, 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 = rank b = -1 if(mod(rank, 2) .eq. 0) then if(rank+1 .lt. size) then C посылают все процессы, кроме последнего call MPI_Send(a, 1, MPI_INTEGER, rank+1, 5, & MPI_COMM_WORLD, ierr); end if else call MPI_Recv(b, 1, MPI_INTEGER, rank-1, 5, & MPI_COMM_WORLD, status, ierr); end if print *, 'process ', rank,' a = ', a, ', b = ', b call MPI_FINALIZE(ierr) end