<div dir="ltr"><div dir="ltr">On Fri, Apr 5, 2019 at 10:27 AM Yuyun Yang <<a href="mailto:yyang85@stanford.edu">yyang85@stanford.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div>
<div id="gmail-m_-1057452859644155007compose-container" style="direction:ltr">
<span><span></span></span>
<div>
<div style="direction:ltr">Hmm ok. Then should I use this function or not when I'm reading the input? It's probably still going to give me the same error and unable to proceed?</div>
<div><br>
</div>
<div style="direction:ltr">I'd like to know if I should use something else to work around this problem.</div></div></div></div></blockquote><div><br></div><div>No, what you do is</div><div><br></div><div>  if (!rank) {</div><div>    PetscViewerASCIIRead();</div><div>    MPI_Bcast();</div><div>  } else {</div><div>    MPI_Bcast();</div><div>  }</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="gmail-m_-1057452859644155007compose-container" style="direction:ltr"><div>
<div style="direction:ltr">Thanks,</div>
<div style="direction:ltr">Yuyun</div>
<div><br>
</div>
<div class="gmail-m_-1057452859644155007acompli_signature">Get <a href="https://aka.ms/o0ukef" target="_blank">Outlook for iOS</a></div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-1057452859644155007divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
<b>Sent:</b> Friday, April 5, 2019 5:16:12 AM<br>
<b>To:</b> Yuyun Yang<br>
<b>Cc:</b> Smith, Barry F.; <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] ASCIIRead error for multiple processors</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Thu, Apr 4, 2019 at 10:56 PM Yuyun Yang <<a href="mailto:yyang85@stanford.edu" target="_blank">yyang85@stanford.edu</a>> wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div id="gmail-m_-1057452859644155007gmail-m_3507937107883218719compose-container" style="direction:ltr"><span><span></span></span>
<div>
<div style="direction:ltr">So do I call MPI_Bcast right after I call PetscViewerASCIIRead? Is that going to prevent the other processors from trying to read the same file but were unable to?</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>No, all this does is replicate data from process 0 on the other processes.</div>
<div><br>
</div>
<div>   Matt</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div id="gmail-m_-1057452859644155007gmail-m_3507937107883218719compose-container" style="direction:ltr">
<div>
<div style="direction:ltr">Thanks,</div>
<div style="direction:ltr">Yuyun</div>
<div><br>
</div>
<div class="gmail-m_-1057452859644155007gmail-m_3507937107883218719acompli_signature">Get <a href="https://aka.ms/o0ukef" target="_blank">
Outlook for iOS</a></div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-1057452859644155007gmail-m_3507937107883218719divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
<b>Sent:</b> Thursday, April 4, 2019 7:30:20 PM<br>
<b>To:</b> Yuyun Yang<br>
<b>Cc:</b> Smith, Barry F.; <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">
petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] ASCIIRead error for multiple processors</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Thu, Apr 4, 2019 at 9:19 PM Yuyun Yang via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>
<div id="gmail-m_-1057452859644155007gmail-m_3507937107883218719gmail-m_3375576340609698688x_compose-container" style="direction:ltr">
<span><span></span></span>
<div>
<div style="direction:ltr">We are probably not going to use hundreds of processors, but i think it would be good to just have processor 0 read the input and broadcast that to all the other processors. Would that be a possible fix? And what would you suggest
 to work around this problem for now?</div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Explicitly call MPI_Bcast().</div>
<div><br>
</div>
<div>   Matt</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>
<div id="gmail-m_-1057452859644155007gmail-m_3507937107883218719gmail-m_3375576340609698688x_compose-container" style="direction:ltr">
<div>
<div style="direction:ltr">Thanks!</div>
<div style="direction:ltr">Yuyun</div>
<div><br>
</div>
<div class="gmail-m_-1057452859644155007gmail-m_3507937107883218719gmail-m_3375576340609698688x_acompli_signature">
Get <a href="https://aka.ms/o0ukef" target="_blank">Outlook for iOS</a></div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-1057452859644155007gmail-m_3507937107883218719gmail-m_3375576340609698688x_divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>><br>
<b>Sent:</b> Thursday, April 4, 2019 3:07:37 PM<br>
<b>To:</b> Yuyun Yang<br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] ASCIIRead error for multiple processors</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:11pt">
<div class="gmail-m_-1057452859644155007gmail-m_3507937107883218719gmail-m_3375576340609698688PlainText"><br>
   Currently PetscViewerFileSetName_ASCII() only opens the file on process 0 (for read or write) thus when you call PetscViewerASCIIRead() from any process but the first it will be reading from an fd that has not been set and you could get unpredictable results.
<br>
<br>
   The implementation and documentation for PetscViewerASCIIRead() is buggy.<br>
<br>
   There are two possible fixes we could make<br>
<br>
1) have PetscViewerFileSetName_ASCII()  open the file for reading on all processes or<br>
2) have PetscViewerASCIIRead() generate an error if the process is not rank == 0<br>
<br>
   Barry<br>
<br>
Note that using PetscViewerASCIIRead() from a handful of processes is probably fine but having hundreds or thousands of processes open the same ASCII file and reading from it will likely not be scalable.<br>
<br>
<br>
<br>
<br>
> On Apr 4, 2019, at 3:15 PM, Yuyun Yang via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
> <br>
> Hello team,<br>
>  <br>
> I’m trying to use PetscViewerASCIIRead() to read in a single interger/scalar value from an input file. It works for one processor. However, when running on multiple processors, I’m getting the below error:<br>
>  <br>
> [1]PETSC ERROR: Invalid argument<br>
> [1]PETSC ERROR: Insufficient data, read only 0 < 1 items<br>
> [1]PETSC ERROR: #1 PetscViewerASCIIRead() line 1054 in /usr/local/CLAB-2/petsc-3.6/src/sys/classes/viewer/impls/ascii/filev.c<br>
>  <br>
> Is there something wrong with how I’m implementing this, or ASCIIRead does not work with multiple processors?<br>
>  <br>
> Thanks,<br>
> Yuyun<br>
<br>
</div>
</span></font></div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail-m_-1057452859644155007gmail-m_3507937107883218719gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail-m_-1057452859644155007gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>