[petsc-users] output vec

Matthew Knepley knepley at gmail.com
Thu May 22 11:26:14 CDT 2014


On Thu, May 22, 2014 at 11:20 AM, Likun Tan <likunt at caltech.edu> wrote:

> I am using VecView to output the vec in a binary file and tried to open it
> in Matlab. I define the precision to be double, but Matlab does not give
> reasonable values of my vec (almost extremely large or small or NaN
> values). Here is my code
>

Are you using PetscBinaryRead.m in Matlab? If so, send the code snippet for
a small vector, all the output, and the binary file.

  Matt


> ========================================
> PetscViewerBinaryOpen(PETSC_COMM_WORLD, NAME, FILE_MODE_WRITE, & view);
> for(step=0; step<STEP; step++)
> {
>        //compute M at current step
>        VecView(M, view);
> }
> PetscViewerDestroy(&view);
> =======================================
>
> I am not sure if there is any problem of my Petsc code. Your comment is
> well appreciated.
>
> > On May 22, 2014, at 11:07 AM, Jed Brown <jed at jedbrown.org> wrote:
> >
> > Likun Tan <likunt at caltech.edu> writes:
> >
> >> Thanks for your suggestion.
> >> Using VecView or PetscViewerBinaryWrite will print the vec vertically,
> i.e.
> >> m1
> >> m2
> >> m3
> >> m4
> >> m5
> >> m6
> >
> > The binary viewer writes a *binary* file.  No formatting or line breaks.
> >
> >> But I prefer the form
> >>
> >> m1 m2 m3
> >> m4 m5 m6
> >>
> >> Since in the end I will have about 1e+7 elements in the vec. If there
> is no way to output the vec in the second form, I will simply use VecView.
> Thanks.
> >
> > Use VecView to write a binary (not ASCII) file.  See
> > PetscViewerBinaryOpen().  You can look at it with python, matlab/octave,
> > etc.
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140522/9c6bcd3c/attachment.html>


More information about the petsc-users mailing list