All pastes #758657 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-02 13:06 UTC
rendered paste body
Program test
      USE MPI

      real,target ::vector (100)
      integer status (MPI_STATUS_SIZE)
      integer p, my_rank, ierr
      integer i, src, dst, count, tag

      pointer point(:)
      point => vector
      do i = 1, 100
         vector = i
      enddo
!      vector = 30
      call MPI_INIT(ierr)
      call MPI_COMM_rank(MPI_COMM_WORLD,my_rank,ierr)
      call MPI_COMM_size(MPI_COMM_WORLD,p,ierr)
      src = 0
      tag = 47
      count = 50
      if (my_rank == 0) then
         dst = 1
         src = 1
         call MPI_SEND(point, count, MPI_REAL, dst, tag, MPI_COMM_WORLD, ierr)
         call MPI_RECV(point, count, MPI_REAL, src, tag, MPI_COMM_WORLD, status, ierr)
      do i = 1, 100
        write (*,*) vector(i), point(i)
      enddo
      else
         dst = 0
         call MPI_RECV(point, count, MPI_REAL, src, tag, MPI_COMM_WORLD, status, ierr)
         do i = 0, count
            point(i) = 15
         enddo
         call MPI_SEND(point, count, MPI_REAL, dst, tag, MPI_COMM_WORLD, ierr)
      endif
      call MPI_Finalize(ierr)
       
      END