<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 5, 2018 at 2:10 PM, Nelson David Rufus <span dir="ltr"><<a href="mailto:nelrufus@umich.edu" target="_blank">nelrufus@umich.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Thanks Matt. I will try to use a 32 bit integer to see if the problem goes away. I had a query about compatibility of while reading and writing files compiled with different int varaints. For example, in the past, I've noticed that a file written using an int32 petsc installation (using code similar to below) had trouble being read by an int64 petsc installation. Is this an issue?<br clear="all"></div><div class="gmail_extra"><div><div class="m_2204282683029294594gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><font color="#888888"><div><div><div><div><font color="#666666"></font></div></div></div></div></font></span></div></div></div></div></div></blockquote><div><br></div><div>Yes, definitely. What we write is not intraconvertible. We could write headers for things that have</div><div>the integer size, but right now we do not.</div><div><br></div><div>  Thanks,</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 dir="ltr"><div class="gmail_extra"><div><div class="m_2204282683029294594gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><font color="#888888"><div><div><div><div><font color="#666666">--<br>Nelson David Rufus<br></font></div><font color="#666666">PhD Student<br></font></div><font color="#666666">Computational Materials Physics Group<br></font></div><font color="#666666">Mechanical Engineering <br></font></div><font color="#666666">University of Michigan<br></font></font></span></div></div></div>
<br><div class="gmail_quote">On Mon, Mar 5, 2018 at 1:56 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Mar 5, 2018 at 1:52 PM, Nelson David Rufus <span dir="ltr"><<a href="mailto:nelrufus@umich.edu" target="_blank">nelrufus@umich.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hello,<br><br></div>I am writing a vector on a petsc binary file and subsequently reading the same in another part of the code.<br></div><div>This works well for smaller vector sizes but fails for a large vector (vectorsize=<span class="m_2204282683029294594m_7878935109856413704m_311304678640467433gmail-cwcot" id="m_2204282683029294594m_7878935109856413704m_311304678640467433gmail-cwos"><a href="tel:(204)%20800-0000" value="+12048000000" target="_blank">2048000000</a>; PetscScalar=PetscComplex). For a large vector, when the read vector is probed for values, I seems to me that it is populated with uninitialized values.<br></span></div></div></div></div></div></div></blockquote><div><br></div></span><div>The number of bytes written will not fit in a 32-bit integer. We do not exhaustively check for problems. I recommend</div><div>reconfiguring with 64-bit ints and retrying.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div><div class="m_2204282683029294594h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><span class="m_2204282683029294594m_7878935109856413704m_311304678640467433gmail-cwcot" id="m_2204282683029294594m_7878935109856413704m_311304678640467433gmail-cwos"></span></div><div><span class="m_2204282683029294594m_7878935109856413704m_311304678640467433gmail-cwcot" id="m_2204282683029294594m_7878935109856413704m_311304678640467433gmail-cwos">This size is close to the int32 limit (2^31 -1) but does not really breach it. Hence i am nt using 64 bit integer. Can you please help me figure out what might be going wrong here.? I'm appending with this mail snippets of the code which read wnd write the petsc file.<br></span></div><div>//****************************<wbr>******************************<wbr>******************************<wbr>******************************<wbr>***********************<br>//<br></div>// Snippet which writes v (a vector constructed using global size) to  the file. Note that this snippet is part of a parallel code<br>//<br>      PetscViewer viewer;<br>      error = PetscViewerBinaryOpen(PETSC_CO<wbr>MM_WORLD,fileName.c_str(),FILE<wbr>_MODE_WRITE,&viewer);<br>      checkPETScError(error, "unbale to open binary file");<br><br>      error = VecView(v,viewer);<br>      checkPETScError(error, "unable to use VecView");<br><br>      error = PetscViewerDestroy(&viewer);<br>      checkPETScError(error,"unable to destry viewer");<br><br>      //<br>      // cleanup<br>      //<br>      error = VecDestroy(&v);<br>      checkPETScError(error,"unable to destroy vector");<br><br>      <br>      error = PetscOptionsSetValue(NULL,"-vi<wbr>ewer_binary_mpiio","");<br>      checkPETScError(error, "error in PetscOptionsSetValue");<br><br>//****************************<wbr>******************************<wbr>******************************<wbr>******************************<wbr>*********<br>//<br></div>// Snippet which reads v (this is part of a serial code)<br>//<br></div>PetscViewer viewer;<br>  error = PetscViewerBinaryOpen(PETSC_CO<wbr>MM_WORLD,fileName.c_str(),FILE<wbr>_MODE_READ,&viewer);<br>  checkPETScError(error, "unbale to open binary file");<br><br>  error = VecLoad(v,viewer);<br>  checkPETScError(error, "unable to use VecView");<br><br>  error = PetscViewerDestroy(&viewer);<br>  checkPETScError(error,"unable to destry viewer");<br><br>   //<br>  // write to console<br>  //<br>  //error = VecView(v,PETSC_VIEWER_STDOUT_<wbr>WORLD);<br>  //checkPETScError(error, "unable to write to console"); <br><br>  //<br>  // copy petsc vec to stl vector<br>  //<br>  std::vector<std::complex<doubl<wbr>e> > dummy(vecSize);<br>  PetscScalar *pointerX;<br>  VecGetArray(v, &pointerX);<br>  std::copy(&(pointerX[0]),&(poi<wbr>nterX[vecSize]),dummy.begin())<wbr>;<br>  VecRestoreArray(v, &pointerX);<br><br></div>  // subsequently dummy is written to an stl vector.<br>//****************************<wbr>******************************<wbr>******************************<wbr>******************************<wbr>***********************<br></div><br><br>Thanks,<br><div><div><div><div><div><div><div><div><div class="m_2204282683029294594m_7878935109856413704m_311304678640467433gmail_signature"><div dir="ltr"><span><font color="#888888"><div><div><div><div><font color="#666666">-<br>Nelson David Rufus<br></font></div><font color="#666666">PhD Student<br></font></div><font color="#666666">Computational Materials Physics Group<br></font></div><font color="#666666">Mechanical Engineering <br></font></div><font color="#666666">University of Michigan<br></font></font></span></div></div></div>
</div></div></div></div></div></div></div></div>
</blockquote></div></div></div><span class="m_2204282683029294594HOEnZb"><font color="#888888"><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_2204282683029294594m_7878935109856413704gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~k<wbr>nepley/</a><br></div></div></div></div></div>
</font></span></font></span></div></div>
</blockquote></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div>
</div></div>