Hi MPIers,
I have written a test MPI code which is a prototype of
my actual code. But it did not work even I tried it
different ways. In my actual code I have to call
different subroutines inside the function "func".
Those subroutines receive the value sent inside the
function "func" and do some calculation and send it
back inside the function "func". Could you please tell
where I did mistake. Thank you very much for your
help.
#################################################
implicit double precision(a-z)
include 'mpif.h'
integer myid, numprocs, ierr
external func
call MPI_INIT( ierr )
call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
if(myid .eq. 0)then
call rout(func,20)
endif
call MPI_FINALIZE(ierr)
end
c-----------------------------------------
double precision function func(x)
implicit double precision(a-z)
include 'mpif.h'
integer myid, numprocs, ierr
call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
call MPI_SEND(x, 1, MPI_DOUBLE_PRECISION, 1, 16,
& MPI_COMM_WORLD,ierr)
if(myid .eq. 1)then
call MPI_RECV(x, 1, MPI_DOUBLE_PRECISION, 0, 16,
& MPI_COMM_WORLD, status, ierr)
call MPI_SEND(x, 1, MPI_DOUBLE_PRECISION, 0, 17,
& MPI_COMM_WORLD,ierr)
endif
call MPI_RECV(x, 1, MPI_DOUBLE_PRECISION, 1, 17,
& MPI_COMM_WORLD, status, ierr)
print*,x
func = x
return
end
c--------------------------------------------------
subroutine rout(func,n)
implicit double precision(a-z)
integer n
do 10 x = 1, n
y = func(x)
10 continue
end
########################################
Manojg
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|