!Homework 3 !Programmer: Chad Brewbaker !Email address: crb002@iastate.edu !Date: Febuary 16, 2004 !Machine used: hpc-class.iastate.edu (Intel Xenon cluster) !Compiler options used: program implicit none integer, parameter :: n=3 real*8,dimension(:,:),allocatable::A real*8::B(n) include "mpif.h" integer::i,ierror,p,rank,status(mpi_status_size) call mpi_init(ierror) call mpi_comm_size(mpi_comm_world,p,ierror) call mpi_comm_rank(mpi_comm_world,rank,ierror) if(rank==0)then allocate(A(n,0:p-1)) call random_number(A) do i=1,(p-1) print *, 'On root processor',rank,'A=',A(1,i),',',A(2,i),',',A(3,i) enddo do i=1,(p-1) call MPI_Send(A(1,i),n,MPI_REAL8,i,1,MPI_COMM_WORLD,ierror) enddo deallocate(A) endif if(rank.ne.0)then call MPI_Recv(B(1),n,MPI_REAL8,MPI_ANY_SOURCE,1,MPI_COMM_WORLD,status,ierror) print *, 'On processor',rank,'B=',B(1),',',B(2),',',B(3) endif call MPI_Finalize(ierror) end program !!$vincent% mpirun -np 4 hw3.exe !!$ On root processor 0 A= 0.656714907139731 , !!$ On processor 1 B= 0.656714907139731 , 0.842055630151761 , !!$ 0.842055630151761 , 0.628580122014474 !!$ On root processor 0 A= 0.330478665894452 , !!$ 0.768815101108699 , 0.681063573564108 !!$ On root processor 0 A= 0.104431626409966 , !!$ 0.285990417481750 , 0.809037499810276 !!$ 0.628580122014474 !!$ On processor 3 B= 0.104431626409966 , 0.285990417481750 , !!$ On processor 2 B= 0.330478665894452 , 0.768815101108699 , !!$ 0.809037499810276 !!$ 0.681063573564108 !!$vincent%