program main use MPI integer n, myrank, npes, ipid, getpid, ierr real(kind=8) :: x real(kind=8), allocatable :: a(:) call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD,myrank,ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD,npes,ierr) ipid = getpid() allocate(a(npes+myrank)) call MPI_BARRIER(MPI_COMM_WORLD, ierr) ! fill arbitrary data n = npes + myrank if (myrank == npes/2) n = n + 1 ! 8-byte overwrite do i = 1, n a(i) = sqrt(real(i,8)) end do x = a(1) + a(n-1) call sleep_(mod(myrank+2,npes)) call MPI_BARRIER(MPI_COMM_WORLD, ierr) deallocate(a) ! postfree read !if (myrank == 1) x = x + a(2) call MPI_BARRIER(MPI_COMM_WORLD, ierr) write(*,*) 'mem-debug: x = ', x call MPI_BARRIER(MPI_COMM_WORLD, ierr) call MPI_FINALIZE(ierr) end