<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 22, 2014 at 11:20 AM, Likun Tan <span dir="ltr"><<a href="mailto:likunt@caltech.edu" target="_blank">likunt@caltech.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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<br>
</blockquote><div><br></div><div>Are you using PetscBinaryRead.m in Matlab? If so, send the code snippet for a small vector, all the output, and the binary file.</div><div><br></div><div>  Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

========================================<br>
PetscViewerBinaryOpen(PETSC_COMM_WORLD, NAME, FILE_MODE_WRITE, & view);<br>
for(step=0; step<STEP; step++)<br>
{<br>
       //compute M at current step<br>
       VecView(M, view);<br>
}<br>
PetscViewerDestroy(&view);<br>
=======================================<br>
<br>
I am not sure if there is any problem of my Petsc code. Your comment is well appreciated.<br>
<br>
> On May 22, 2014, at 11:07 AM, Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br>
><br>
> Likun Tan <<a href="mailto:likunt@caltech.edu">likunt@caltech.edu</a>> writes:<br>
><br>
>> Thanks for your suggestion.<br>
>> Using VecView or PetscViewerBinaryWrite will print the vec vertically, i.e.<br>
>> m1<br>
>> m2<br>
>> m3<br>
>> m4<br>
>> m5<br>
>> m6<br>
><br>
> The binary viewer writes a *binary* file.  No formatting or line breaks.<br>
><br>
>> But I prefer the form<br>
>><br>
>> m1 m2 m3<br>
>> m4 m5 m6<br>
>><br>
>> 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.<br>
><br>
> Use VecView to write a binary (not ASCII) file.  See<br>
> PetscViewerBinaryOpen().  You can look at it with python, matlab/octave,<br>
> etc.<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>