<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><DIV style="RIGHT: auto" id=yiv521196927>
<DIV style="BACKGROUND-COLOR: #fff; FONT-FAMILY: times new roman, new york, times, serif; COLOR: #000; FONT-SIZE: 12pt">
<DIV id=yiv521196927yui_3_2_0_5_131168719139043><SPAN id=yiv521196927yui_3_2_0_5_131168719139068>Hello Sreenivas,</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV style="RIGHT: auto" id=yiv521196927yui_3_2_0_5_1311687191390861><SPAN style="RIGHT: auto" id=yiv521196927yui_3_2_0_5_1311687191390118>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.</SPAN></DIV>
<DIV id=yiv521196927yui_3_2_0_5_13116871913901732><SPAN></SPAN> </DIV>
<DIV style="RIGHT: auto" id=yiv521196927yui_3_2_0_5_13116871913901736><SPAN style="RIGHT: auto" id=yiv521196927yui_3_2_0_5_13116871913901622>Regards,<VAR id=yiv521196927yui-ie-cursor></VAR></SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN></SPAN> <VAR id=yui-ie-cursor></VAR></DIV>
<DIV style="RIGHT: auto" id=yiv521196927yui_3_2_0_5_13116871913901727><SPAN id=yiv521196927yui_3_2_0_5_13116871913901684>Zhangping Wei</DIV>
<DIV id=yiv521196927yui_3_2_0_5_131168719139043></SPAN></DIV>
<DIV><BR id=yiv521196927yui_3_2_0_5_131168719139045></DIV>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt" id=yiv521196927yui_3_2_0_5_131168719139047>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><FONT size=2 face=Arial>
<DIV style="BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; PADDING-BOTTOM: 0px; LINE-HEIGHT: 0; MARGIN: 5px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; HEIGHT: 0px; FONT-SIZE: 0px; BORDER-TOP: #ccc 1px solid; BORDER-RIGHT: #ccc 1px solid; PADDING-TOP: 0px" class="yiv521196927hr yiv521196927yui-non yiv521196927yui-skip"></DIV><B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> "vvvnew@umich.edu" <vvvnew@umich.edu><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Zhangping Wei <zhangping_wei@yahoo.com>; mpich-discuss@mcs.anl.gov<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Tuesday, July 26, 2011 4:00 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [mpich-discuss] How to use MPI functions under subroutines?<BR></FONT><BR>
<DIV style="RIGHT: auto" id=yiv521196927>
<DIV style="RIGHT: auto">Hi,</DIV>
<DIV> 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.</DIV>
<DIV id=yiv521196927yui_3_2_0_5_131168719139084>Sreenivas</DIV>
<DIV> </DIV>
<DIV>On Tue, 26 Jul 2011 13:09:27 -0700 (PDT), Zhangping Wei <zhangping_wei@yahoo.com> wrote:</DIV>
<BLOCKQUOTE style="BORDER-LEFT: #1010ff 2px solid; PADDING-LEFT: 5px; WIDTH: 100%; MARGIN-LEFT: 5px">
<DIV style="BACKGROUND-COLOR: #fff; FONT-FAMILY: times new roman, new york, times, serif; COLOR: #000; FONT-SIZE: 12pt">
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal>Dear all,</DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal> </DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal>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.</DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal> </DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal>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.</DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal> </DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal>Does someone have some programming experience like this? any advice and information will be greatly appreciated.</DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal> </DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal>Regards,</DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal> </DIV>
<DIV style="MARGIN: 0in 0in 0pt" class=yiv521196927MsoNormal>Zhangping Wei</DIV>
<DIV><VAR id=yiv521196927yui-ie-cursor></VAR></DIV></DIV></BLOCKQUOTE>
<DIV> </DIV></DIV><BR><BR></DIV></DIV></DIV></DIV></div></body></html>