<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Jed, thanks for pointing out that the program expects a matrix followed by a vector in the file. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I created a new binary file “myAb.dat” in matlab by adding the b vector. <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>A = [1 2 0;</span><span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> 2 0 5;</span><span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> 0 3 0;</span><span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> 1 4 1]</span><span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>b = [1 2 3]'</span><span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>PetscBinaryWrite(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#A020F0'>'myAb.dat'</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>,sparse(A),b)</span><span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>[AA bb] = PetscBinaryRead(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#A020F0'>'myAb.dat'</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>The PETSc program works with this input file now:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>$ ./ex12 -f0 myAb.dat<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>Matrix Object: 1 MPI processes<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> type: seqaij<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 0: (0, 1) (1, 2)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 1: (0, 2) (2, 5)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 2: (1, 3)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 3: (0, 1) (1, 4) (2, 1)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>Matrix Object: 1 MPI processes<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> type: seqaij<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 0: (0, 1) (1, 2) (4, 1)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 1: (0, 2) (2, 5) (4, 2)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 2: (1, 3) (4, 3)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 3: (0, 1) (1, 4) (2, 1) (4, 2.22295e-319)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>row 4: (0, 1) (1, 2) (2, 3) (3, 2.22295e-319) (4, 3)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Shuangshuang<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> petsc-users-bounces@mcs.anl.gov [mailto:petsc-users-bounces@mcs.anl.gov] <b>On Behalf Of </b>Jed Brown<br><b>Sent:</b> Tuesday, June 26, 2012 4:02 PM<br><b>To:</b> PETSc users list<br><b>Subject:</b> Re: [petsc-users] Loading Binary file problem<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Tue, Jun 26, 2012 at 1:09 PM, Jin, Shuangshuang <<a href="mailto:Shuangshuang.Jin@pnnl.gov" target="_blank">Shuangshuang.Jin@pnnl.gov</a>> wrote:<o:p></o:p></p><div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif"'>Hello everyone, <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif"'> 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 </span><span style='font-family:"Courier New"'>PetscBinaryRead(<span style='color:#A020F0'>'myA.dat'</span>)correctly.</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal> <span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>A = [1 2 0;</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> 2 0 5;</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> 0 3 0;</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> 1 4 1]</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>PetscBinaryWrite(<span style='color:#A020F0'>'myA.dat'</span>,sparse(A))</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>PetscBinaryRead(<span style='color:#A020F0'>'myA.dat'</span>)</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal> <span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>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:<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[d3m956@olympus tutorials]$ ./ex12 -f0 myA.dat<o:p></o:p></span></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: --------------------- Error Message ------------------------------------<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif";color:red'>[0]PETSC ERROR: Read from file failed!</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif";color:red'>[0]PETSC ERROR: Read past end of file!</span><span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: ------------------------------------------------------------------------<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 0, Tue Jun 5 14:20:42 CDT 2012<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: See docs/changes/index.html for recent updates.<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: See docs/index.html for manual pages.<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: ------------------------------------------------------------------------<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: ./ex12 on a arch-linu named olympus.local by d3m956 Tue Jun 26 13:51:28 2012<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: Libraries linked from /pic/projects/mca/ss/PETSC/petsc-3.3-p0/arch-linux2-c-debug/lib<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: Configure run at Thu Jun 14 17:00:19 2012<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack --download-mpich<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: ------------------------------------------------------------------------<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: PetscBinaryRead() line 271 in src/sys/fileio/sysio.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: PetscBinarySynchronizedRead() line 558 in src/sys/fileio/sysio.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: PetscViewerBinaryRead() line 764 in src/sys/viewer/impls/binary/binv.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: PetscViewerBinaryReadVecHeader_Private() line 24 in src/vec/vec/utils/vecio.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: VecLoad_Binary() line 97 in src/vec/vec/utils/vecio.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: VecLoad_Default() line 348 in src/vec/vec/utils/vecio.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: VecLoad() line 1111 in src/vec/vec/interface/vector.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>[0]PETSC ERROR: main() line 92 in src/mat/examples/tutorials/ex12.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>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.<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>Thanks,<o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:9.0pt'><span style='font-family:"Calibri","sans-serif"'>Shuangshuang<o:p></o:p></span></p></div><div><p class=MsoNormal> <span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal> <span style='font-family:"Calibri","sans-serif"'><o:p></o:p></span></p></div></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></body></html>