[mpich-discuss] How to use MPI functions under subroutines?

Zhangping Wei zhangping_wei at yahoo.com
Wed Jul 27 10:45:37 CDT 2011


Hello Sreenivas,
 
Thanks very much for your advice, I guess you are right, I did not pass the communicator and index correctly into the subroutine, now I am working on it to see what will happen.
 
Regards,
 
Zhangping Wei

From: "vvvnew at umich.edu" <vvvnew at umich.edu>
To: Zhangping Wei <zhangping_wei at yahoo.com>; mpich-discuss at mcs.anl.gov
Sent: Tuesday, July 26, 2011 4:00 PM
Subject: Re: [mpich-discuss] How to use MPI functions under subroutines?


Hi,
   I dont know if i understood your question right, but if you want to use mpi in your subroutines, pass all the relevant information (the communicator,numprocs,etc) and also include mpi in the subroutine.  Your mpi is already initialized in the main prog and so you just have to pass the relevant variables.
Sreenivas

On Tue, 26 Jul 2011 13:09:27 -0700 (PDT), Zhangping Wei <zhangping_wei at yahoo.com> wrote:
Dear all,
>
>I have a question about MPI programming skills; right now I am working on a FORTRAN program which has many subroutines, and I have not yet figure out a good way to use MPI functions inside those subroutines.
>
>Usually, we set up the processes number (say, numprocs) and the corresponding process indices (myid) at the beginning of the main program, however, if we call some subroutines, and we want to use some function, for example, MPI_GATER, under that subroutine, we have to use their indices and MPI_COMM_WORLD or other statements, then I found lots of errors were incurred in my Visual Studio.
>
>Does someone have some programming experience like this? any advice and information will be greatly appreciated.
>
>Regards,
>
>Zhangping Wei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20110727/a76db9f4/attachment.htm>


More information about the mpich-discuss mailing list