[petsc-users] ASCIIRead error for multiple processors

Smith, Barry F. bsmith at mcs.anl.gov
Thu Apr 4 17:07:37 CDT 2019

   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. 

   The implementation and documentation for PetscViewerASCIIRead() is buggy.

   There are two possible fixes we could make

1) have PetscViewerFileSetName_ASCII()  open the file for reading on all processes or
2) have PetscViewerASCIIRead() generate an error if the process is not rank == 0


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.

> On Apr 4, 2019, at 3:15 PM, Yuyun Yang via petsc-users <petsc-users at mcs.anl.gov> wrote:
> Hello team,
> 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:
> [1]PETSC ERROR: Invalid argument
> [1]PETSC ERROR: Insufficient data, read only 0 < 1 items
> [1]PETSC ERROR: #1 PetscViewerASCIIRead() line 1054 in /usr/local/CLAB-2/petsc-3.6/src/sys/classes/viewer/impls/ascii/filev.c
> Is there something wrong with how I’m implementing this, or ASCIIRead does not work with multiple processors?
> Thanks,
> Yuyun

More information about the petsc-users mailing list