[petsc-users] How to dump the nonzero entries of matrix into a file?

Barry Smith bsmith at mcs.anl.gov
Wed Dec 30 12:36:05 CST 2009


   You are using the wrong calling sequence for PetscViewerASCIIOpen().

    Also if you want to read the file in matlab you will do better to  
use the binary viewer. It will be much faster to save the file and  
read the file, plus the file will be smaller.

    Use bin/matlab/PetscBinaryRead.m to read in the binary file to  
Matlab

    Barry

On Dec 30, 2009, at 12:17 PM, hxie at umn.edu wrote:

> Hi,
> Thanks. But if I try to dump it into an ascii file  using the  
> following:
> ---
>      call  
> PetscViewerASCIIOpen 
> (PETSC_COMM_WORLD,"matrix.dat",FILE_MODE_WRITE,viewer,pterr)
>       call  
> PetscViewerSetFormat(viewer,PETSC_VIEWER_ASCII_MATLAB,pterr)
>       call MatView(ptMat,viewer,pterr)
> ---
>
> It gives some errors:
> [0]PETSC ERROR: Caught signal number 10 BUS: Bus Error, possibly  
> illegal memory access
>
>
> Bests,
> Hui
>



More information about the petsc-users mailing list