<div class="gmail_quote">On Tue, Jun 26, 2012 at 1:09 PM, Jin, Shuangshuang <span dir="ltr"><<a href="mailto:Shuangshuang.Jin@pnnl.gov" target="_blank">Shuangshuang.Jin@pnnl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div>
<font face="Calibri, sans-serif">
<div>Hello everyone, </div>
<div> </div>
<div>     I created a 4*3 matrix A in matlab, saved it to binary file “myA.dat” using PetscBinaryWrite(‘myA.dat’,sparse(A)). Everything seems fine to me because I can read the binary file ‘myA.dat’ by <font face="Courier New, monospace">PetscBinaryRead(</font><font face="Courier New, monospace" color="#A020F0">'myA.dat'</font><font face="Courier New, monospace">)correctly.</font></div>

<div><font face="Times New Roman, serif"> </font></div>
<div><font face="Courier New, monospace">A = [1     2     0;</font></div>
<div><font face="Courier New, monospace">     2     0     5;</font></div>
<div><font face="Courier New, monospace">     0     3     0;</font></div>
<div><font face="Courier New, monospace">     1     4     1]</font></div>
<div><font face="Courier New, monospace">PetscBinaryWrite(<font color="#A020F0">'myA.dat'</font>,sparse(A))</font></div>
<div><font face="Courier New, monospace">PetscBinaryRead(<font color="#A020F0">'myA.dat'</font>)</font></div>
<div><font face="Times New Roman, serif"> </font></div>
<div style="text-indent:9pt">However, when I tried to load the binary file “myA.dat” in PETSc using the example code “ex12.c” under “petsc-3.3-p0/src/mat/examples/tutorials”, I got error message below:</div>
<div style="text-indent:9pt"> </div>
<div style="text-indent:9pt">[d3m956@olympus tutorials]$ ./ex12 -f0 myA.dat</div></font></div></blockquote><div><br></div><div>This program expects a matrix followed by a vector in the file. You can use -rhs 0 to skip reading the right hand side vector from the file, it will use a vector of all ones.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><font face="Calibri, sans-serif">
<div style="text-indent:9pt">[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div>
<div style="text-indent:9pt"><font color="#FF0000">[0]PETSC ERROR: Read from file failed!</font></div>
<div style="text-indent:9pt"><font color="#FF0000">[0]PETSC ERROR: Read past end of file!</font></div>
<div style="text-indent:9pt">[0]PETSC ERROR: ------------------------------------------------------------------------</div>
<div style="text-indent:9pt">[0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 0, Tue Jun  5 14:20:42 CDT 2012</div>
<div style="text-indent:9pt">[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div>
<div style="text-indent:9pt">[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div>
<div style="text-indent:9pt">[0]PETSC ERROR: See docs/index.html for manual pages.</div>
<div style="text-indent:9pt">[0]PETSC ERROR: ------------------------------------------------------------------------</div>
<div style="text-indent:9pt">[0]PETSC ERROR: ./ex12 on a arch-linu named olympus.local by d3m956 Tue Jun 26 13:51:28 2012</div>
<div style="text-indent:9pt">[0]PETSC ERROR: Libraries linked from /pic/projects/mca/ss/PETSC/petsc-3.3-p0/arch-linux2-c-debug/lib</div>
<div style="text-indent:9pt">[0]PETSC ERROR: Configure run at Thu Jun 14 17:00:19 2012</div>
<div style="text-indent:9pt">[0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack --download-mpich</div>
<div style="text-indent:9pt">[0]PETSC ERROR: ------------------------------------------------------------------------</div>
<div style="text-indent:9pt">[0]PETSC ERROR: PetscBinaryRead() line 271 in src/sys/fileio/sysio.c</div>
<div style="text-indent:9pt">[0]PETSC ERROR: PetscBinarySynchronizedRead() line 558 in src/sys/fileio/sysio.c</div>
<div style="text-indent:9pt">[0]PETSC ERROR: PetscViewerBinaryRead() line 764 in src/sys/viewer/impls/binary/binv.c</div>
<div style="text-indent:9pt">[0]PETSC ERROR: PetscViewerBinaryReadVecHeader_Private() line 24 in src/vec/vec/utils/vecio.c</div>
<div style="text-indent:9pt">[0]PETSC ERROR: VecLoad_Binary() line 97 in src/vec/vec/utils/vecio.c</div>
<div style="text-indent:9pt">[0]PETSC ERROR: VecLoad_Default() line 348 in src/vec/vec/utils/vecio.c</div>
<div style="text-indent:9pt">[0]PETSC ERROR: VecLoad() line 1111 in src/vec/vec/interface/vector.c</div>
<div style="text-indent:9pt">[0]PETSC ERROR: main() line 92 in src/mat/examples/tutorials/ex12.c</div>
<div style="text-indent:9pt"> </div>
<div style="text-indent:9pt">It said “Read from file failed! Read past end of file!” Anything wrong? I was using the example code without changing anything. Please help me to figure out the problem.</div>
<div style="text-indent:9pt"> </div>
<div style="text-indent:9pt">Thanks,</div>
<div style="text-indent:9pt">Shuangshuang</div>
<div><font face="Times New Roman, serif"> </font></div>
<div><font face="Times New Roman, serif"> </font></div>
</font>
</div>

</blockquote></div><br>