<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<div id="x_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">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><br>
</div>
<div style="direction:ltr">Thanks!</div>
<div style="direction:ltr">Yuyun</div>
<div><br>
</div>
<div class="x_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="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Smith, Barry F. <bsmith@mcs.anl.gov><br>
<b>Sent:</b> Thursday, April 4, 2019 3:07:37 PM<br>
<b>To:</b> Yuyun Yang<br>
<b>Cc:</b> petsc-users@mcs.anl.gov<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="PlainText"><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 <petsc-users@mcs.anl.gov> 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>
</body>
</html>