<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Just read all variables from a file. I don't see how you can read from stdin on every proc anyways. </div><div>
<br></div><div>Jeff<br><br>Sent from my iPhone</div><div><br>On Sep 15, 2013, at 4:48 AM, Mahesh Doijade <<a href="mailto:maheshdoijade@gmail.com">maheshdoijade@gmail.com</a>> wrote:<br><br></div><blockquote type="cite">
<div><div dir="ltr"><div class="">

        <p>I am trying to write MPI code with scanf which will take 
input for all process individually, but only one process taking the 
input from user and others assign garbage value to that variable. The 
program is as below</p>

<pre style class=""><code><span class="">#include</span><span class=""> </span><span class=""><stdlib.h></span><span class="">
</span><span class="">#include</span><span class=""> </span><span class=""><stdio.h></span><span class="">
</span><span class="">#include</span><span class=""> </span><span class="">"mpi.h"</span><span class="">
</span><span class="">#include</span><span class=""><string.h></span><span class="">

</span><span class="">int</span><span class=""> main</span><span class="">(</span><span class="">int</span><span class=""> argc</span><span class="">,</span><span class=""> </span><span class="">char</span><span class="">*</span><span class=""> argv</span><span class="">[])</span><span class=""> 
</span><span class="">{</span><span class="">
</span><span class="">int</span><span class=""> i</span><span class="">,</span><span class=""> size</span><span class="">,</span><span class=""> rank</span><span class="">;</span><span class="">
</span><span class="">int</span><span class=""> arr</span><span class="">;</span><span class="">
MPI_Init</span><span class="">(&</span><span class="">argc</span><span class="">,</span><span class=""> </span><span class="">&</span><span class="">argv</span><span class="">);</span><span class="">
MPI_Comm_size</span><span class="">(</span><span class="">MPI_COMM_WORLD</span><span class="">,</span><span class=""> </span><span class="">&</span><span class="">size</span><span class="">);</span><span class="">
MPI_Comm_rank</span><span class="">(</span><span class="">MPI_COMM_WORLD</span><span class="">,</span><span class=""> </span><span class="">&</span><span class="">rank</span><span class="">);</span><span class="">
printf</span><span class="">(</span><span class="">"Enter the number\n"</span><span class="">);</span><span class="">
scanf</span><span class="">(</span><span class="">"%d"</span><span class="">,&</span><span class="">i</span><span class="">);</span><span class="">

printf</span><span class="">(</span><span class="">"%d\n"</span><span class="">,</span><span class="">i</span><span class="">);</span><span class="">
MPI_Finalize</span><span class="">();</span><span class="">
exit</span><span class="">(</span><span class="">0</span><span class="">);</span><span class="">
</span><span class="">}</span></code></pre>

    </div><br clear="all"><br>-- <br><br>Regards,<br>-- Mahesh Doijade<br><br><br><br>
                                                                           <br>
</div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>discuss mailing list     <a href="mailto:discuss@mpich.org">discuss@mpich.org</a></span><br><span>To manage subscription options or unsubscribe:</span><br>
<span><a href="https://lists.mpich.org/mailman/listinfo/discuss">https://lists.mpich.org/mailman/listinfo/discuss</a></span></div></blockquote></body></html>