Hi ..
Im new to Fortran and MPI...
Matrix addition Programme...
After compiling.. i got error like
forrtl: severe (24): end-of-file during read, unit -4, file stdin
include 'mpif.h'
Integer rank, size, ierr, status(MPI_STATUS_SIZE)
Integer npoc, init, final
real a(200), b(200), c(200)
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nproc, ierr)
print *, 'Enter Size of array:'
read *, size
if (rank .eq. 0 ) then
print *, 'Enter values to A:'
read *,(a(i), i=1,size)
print *, 'Enter values to B:'
read *,(b(i), i=1,size)
end if
blocksize= size/nproc
if ( rank .EQ. 0) then
do i=0, (nproc-1)
call MPI_Send(a(i*blocksize+1), blocksize, MPI_REAL, i, 1,
& MPI_COMM_WORLD, ierr)
call MPI_Send(b, blocksize, MPI_REAL, i, 1,
& MPI_COMM_WORLD, ierr)
end do
else
call MPI_Recv(a((rank-1)*blocksize+1),blocksize,MPI_REAL,0,1,
& MPI_COMM_WORLD,status,ierr)
call MPI_Recv(b, size, MPI_REAL, 0, 1,
& MPI_COMM_WORLD, status, ierr)
end if
if(rank .eq. 0) then
init= blocksize * (nproc - 1)+1;
final = size;
else
init= blocksize * (rank - 1)+1;
final= blocksize * rank;
end if
c(i)=0.
do i= 1, size
c(i)=a(i)+b(i)
end do
if ( rank .eq. 0) then
do i=1, size
call MPI_Recv(c,size,MPI_REAL,i,1,MPI_COMM_WORLD,status,ierr)
end do
do i=1, size
print *, c(i)
end do
else
call MPI_Send(c((rank-1)*blocksize),size,MPI_REAL,0,1,
& MPI_COMM_WORLD,status,ierr)
end if
call MPI_Finalize(ierr)
stop
end
thanks in advance...
Im new to Fortran and MPI...
Matrix addition Programme...
After compiling.. i got error like
forrtl: severe (24): end-of-file during read, unit -4, file stdin
include 'mpif.h'
Integer rank, size, ierr, status(MPI_STATUS_SIZE)
Integer npoc, init, final
real a(200), b(200), c(200)
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nproc, ierr)
print *, 'Enter Size of array:'
read *, size
if (rank .eq. 0 ) then
print *, 'Enter values to A:'
read *,(a(i), i=1,size)
print *, 'Enter values to B:'
read *,(b(i), i=1,size)
end if
blocksize= size/nproc
if ( rank .EQ. 0) then
do i=0, (nproc-1)
call MPI_Send(a(i*blocksize+1), blocksize, MPI_REAL, i, 1,
& MPI_COMM_WORLD, ierr)
call MPI_Send(b, blocksize, MPI_REAL, i, 1,
& MPI_COMM_WORLD, ierr)
end do
else
call MPI_Recv(a((rank-1)*blocksize+1),blocksize,MPI_REAL,0,1,
& MPI_COMM_WORLD,status,ierr)
call MPI_Recv(b, size, MPI_REAL, 0, 1,
& MPI_COMM_WORLD, status, ierr)
end if
if(rank .eq. 0) then
init= blocksize * (nproc - 1)+1;
final = size;
else
init= blocksize * (rank - 1)+1;
final= blocksize * rank;
end if
c(i)=0.
do i= 1, size
c(i)=a(i)+b(i)
end do
if ( rank .eq. 0) then
do i=1, size
call MPI_Recv(c,size,MPI_REAL,i,1,MPI_COMM_WORLD,status,ierr)
end do
do i=1, size
print *, c(i)
end do
else
call MPI_Send(c((rank-1)*blocksize),size,MPI_REAL,0,1,
& MPI_COMM_WORLD,status,ierr)
end if
call MPI_Finalize(ierr)
stop
end
thanks in advance...