<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta content="text/html; charset=utf-8">
</head>
<body>
<div id="compose-container" itemscope="" itemtype="https://schema.org/EmailMessage" style="direction:ltr">
<span itemprop="creator" itemscope="" itemtype="https://schema.org/Organization"><span itemprop="name"></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><br>
</div>
<div style="direction:ltr">Thanks,</div>
<div style="direction:ltr">Yuyun</div>
<div><br>
</div>
<div class="acompli_signature">Get <a href="https://aka.ms/o0ukef">Outlook for iOS</a></div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matthew Knepley <knepley@gmail.com><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.; petsc-users@mcs.anl.gov<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">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_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_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_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_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_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_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>
</body>
</html>