program hello
  implicit none
  include 'mpif.h'
  
  integer ierr,me,nprocs,left,right
  integer status(MPI_STATUS_SIZE)

!  integer,parameter :: ndata = 1000
  integer,parameter :: ndata = 1000000 ! e cosi', funziona!

  real :: a(ndata)
  real :: b(ndata)

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

  a = me
  b = -1

  right = mod(me + 1 , nprocs)
  left =  mod(me - 1 + nprocs , nprocs)

  call MPI_SENDRECV(a,ndata,MPI_REAL,right,0, &
       b,ndata,MPI_REAL,left,0,MPI_COMM_WORLD,status,ierr)

  print *,'I am proc ',me,' and I have received b(1) = ',b(1)
  call MPI_FINALIZE(ierr)
  
end program hello
