On Tue, Aug 30, 2011 at 3:43 AM, khalid ashraf <span dir="ltr">&lt;<a href="mailto:khalid_eee@yahoo.com">khalid_eee@yahoo.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div style="color:#000;background-color:#fff;font-family:arial, helvetica, sans-serif;font-size:12pt"><div><div>Hi, </div><div>I am trying to load a vector that I saved as PetscBinary file. </div><div>On a single processor, I have to put an initial PetscBinaryRead command &amp; put the subsequent reads in the loop. Then I get the correct answer. I don&#39;t understand why an initial PetscBinaryRead is required. Anyway, with this, the code works fine on single processor.</div>
<div><br></div><div>However, on multiple processors, the input file and the vector after reading are not in the same order. I think that somehow I have to pass the information to each processor as to which part of the binary file to read. Please tell me how to do this.</div>
</div></div></div></blockquote><div><br></div><div>Is there a reason you are not using VecLoad, <a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Vec/VecLoadIntoVector.html">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Vec/VecLoadIntoVector.html</a> ?</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;"><div><div style="color:#000;background-color:#fff;font-family:arial, helvetica, sans-serif;font-size:12pt">
<div><div>Thanks.</div><div><br></div><div>Khalid</div><div><br></div><div><br></div><div>Here is the
 code:</div><div><br></div><div><div>PetscViewerBinaryOpen(appctx-&gt;comm,&quot;Pxbin_10.out&quot;,FILE_MODE_READ,&amp;viewer);</div><div>PetscViewerBinaryGetDescriptor(viewer,&amp;fd);</div><div>PetscBinaryRead(fd,header,1,PETSC_SCALAR);</div>
<div><br></div></div><div> for (k=zs; k&lt;zs+zm; k++) {</div><div>  for (j=ys; j&lt;ys+ym; j++) {</div><div>  for (i=xs; i&lt;xs+xm; i++) {</div><div>PetscBinaryRead(fd,header,1,PETSC_SCALAR);<br></div><div>    u_localptr[k][j][i] = header[0];<br>
</div><div>  }<br></div><div>  }</div><div>  }</div><div><br></div></div></div></div></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<br>