[petsc-users] Reading in a matrix from ASCII file

Jed Brown jed at jedbrown.org
Thu Oct 5 16:10:02 CDT 2017


http://www.mcs.anl.gov/petsc/documentation/faq.html#sparse-matrix-ascii-format

Better, read it using Python on MATLAB and write it (using the provided
PETSc scripts) in PETSc binary format.  Parallel IO with ASCII files is
a dead end.

Storm Weiner <stormweiner at berkeley.edu> writes:

> Hey there,
>
> I'm working through some basic examples, and I want to read in a test
> matrix I have stored in a (row, column, value) ASCII file.   How can I read
> this in using PETSc?
>
>
> I found the routine PetscViewerASCIIOpen and PetscViewerASCIIRead  but I'm
> not sure how to tell it that what I have is actually a matrix.  In this
> example, I know the matrix, so I can specify how many entries to read, but
> is there a way to just read "the whole file"?
>
> What's the preferred PETSc way to do this?
>
> I'm using F90 by the way.
>
>
> -Storm


More information about the petsc-users mailing list