!Homework 2 !Programmer: Chad Brewbaker !Email address: crb002@iastate.edu !Date: Febuary 11, 2004 !Machine used: hpc-class.iastate.edu (Intel Xenon cluster) !Compiler options used: program implicit none integer, parameter :: n=3 integer::i,ierror real*8,dimension(n)::A include "mpif.h" integer::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 do i=1,n A(i)=float(i) enddo do i=1,(p-1) call MPI_Send(A(1),n,MPI_REAL8,i,1,MPI_COMM_WORLD,ierror) enddo endif if(rank.ne.0)then call MPI_Recv(A(1),n,MPI_REAL8,MPI_ANY_SOURCE,1,MPI_COMM_WORLD,status,ierror) print *, 'On processor',rank,'A=',A(1),',',A(2),',',A(3) endif call MPI_Finalize(ierror) end program !!RESULTS !!$vincent% mpirun -np 3 ./hw2.exe !!$ On processor 1 A= 1.00000000000000 , 2.00000000000000 , !!$ On processor 2 A= 1.00000000000000 , 2.00000000000000 , !!$ 3.00000000000000 !!$ 3.00000000000000 !!$vincent% !!$ !!$vincent% mpirun -np 4 ./hw2.exe !!$ On processor 1 A= 1.00000000000000 , 2.00000000000000 , !!$ On processor 2 A= 1.00000000000000 , 2.00000000000000 , !!$ On processor 3 A= 1.00000000000000 , 2.00000000000000 , !!$ 3.00000000000000 !!$ 3.00000000000000 !!$ 3.00000000000000 !!$vincent%