On Feb 17, 2006, at 4:34 PM, ew fgff wrote:
> Hi MPIers,
A request: when you send a message to the list, please do not reply
to a message on another thread -- compose a new mail to lam_at_lam-
mpi.org. Otherwise, mail clients (and the web archives) include your
mail in the original thread.
Thanks.
> 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.
I don't know what you mean "did not work" -- can you be more precise?
I do see a few logic errors that have nothing to do with MPI:
- only MPI_COMM_WORLD rank 0 is calling rout(), but rout() calls func
() which does some sending and receiving and checks whether its MCW
rank is 0 or 1 -- but rank 1 will never call that function
- in func(), you have some sending and receiving protected by an "if"
statement (i.e., only MCW rank 1 will do them), but then some other
sending and receiving that will be executed by anyone who calls the
function (e.g., even MCW rank 1 will send to itself, and will attempt
to receive from itself). I'm guessing you really meant to have those
protected by "if" statements as well...?
> #################################################
>
> 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
> _______________________________________________
> This list is archived at http://www.lam-mpi.org/MailArchives/lam/
--
{+} Jeff Squyres
{+} The Open MPI Project
{+} http://www.open-mpi.org/
|