Hmm, it shouldn't hang but should crash if the file does not exist.

  If you want the code to continue running with or without the file you can use 
PetscTestFile() to see if the file exists
and do something else if it does not exist.

   Barry


> On Feb 13, 2018, at 11:10 AM, Michael Povolotskyi <mpovo...@purdue.edu> wrote:
> 
> Dear Petsc developers,
> 
> I'm reading a matrix from a file like this:
> 
> PetscViewer viewer;
> PetscErrorCode ierr;
> 
> MatCreate(comm,&matrix);
> 
> MatSetType(matrix,MATDENSE);
> 
> ierr = PetscViewerBinaryOpen(comm,file_name,FILE_MODE_READ,&viewer);
> ierr = MatLoad(matrix,viewer);
> 
> 
> Sometimes the file that is needed is not present and the code execution 
> becomes frozen.
> 
> Is it possible to catch this situation looking at the ierr variable?
> 
> Thank you,
> 
> Michael.
> 

Reply via email to