[petsc-users] Write binary to matrix

Florian Lindner mailinglists at xgm.de
Thu Sep 22 08:32:09 CDT 2016


Am 22.09.2016 um 12:53 schrieb Dave May:
> 
> 
> On Thursday, 22 September 2016, Florian Lindner <mailinglists at xgm.de
> <javascript:_e(%7B%7D,'cvml','mailinglists at xgm.de');>> wrote:
> 
>     Hello,
> 
>     I want to write a MATSBAIJ to a file in binary, so that I can load it later using MatLoad.
> 
>     However, I keep getting the error:
> 
>     [5]PETSC ERROR: No support for this operation for this object type!
>     [5]PETSC ERROR: Cannot get subcomm viewer for binary files or sockets unless SubViewer contains the rank 0 process
>     [6]PETSC ERROR: PetscViewerGetSubViewer_Binary() line 46 in
>     /data/scratch/lindnefn/software/petsc/src/sys/classes/viewer/impls/binary/binv.c
> 
>     The rank 0 is included, as you can see below, I use PETSC_COMM_WORLD and the matrix is also created like that.
> 
>     The code looks like:
> 
>     PetscErrorCode ierr = 0;
>     PetscViewer viewer;
>     PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename.c_str(), FILE_MODE_WRITE, &viewer); CHKERRV(ierr);
>     MatView(matrix, viewer); CHKERRV(ierr);
>     PetscViewerDestroy(&viewer);
> 
> 
> The code snippet looks weird.
> 
> The error could be related to your usage of the error checking macros, Eg the fact you set ierr to zero rather than
> assigning it to the return value of your petsc function calls.
> 
> You should  do
> ierr = petscfunc();CHQERRQ(ierr);
> 
> And why do you use CHQERRV and not CHKERRQ?

Hey,

sorry, I copied that code from different locations and edited it, incompletely.

Unfortunatly I was unable to reproduce the problem with a small snippet, see my other (coming) mail in this thread.

Best,
Florian


More information about the petsc-users mailing list