<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> To minimize code changes you could add a PETSc viewer format that caused skipping reading in an object. Then each object load would need a skip-read method that mimicked the reading but actually just skipped over the parts of the data of the object (using the correct sizes). For vectors this is trivial since you just skip the single known array. For sparse matrices it is not difficult but you will need to read in the number of nonzeros so you know how much to skip etc.<div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 4, 2021, at 9:58 AM, Peder Jørgensgaard Olesen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" class="">
<div class="">
<style type="text/css" style="display:none;" class=""><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" dir="ltr" class=""><p class="">Thank you for your quick reply.</p><p class=""><br class="">
</p><p class="">I've had to change away from HDF5 to Binary format at an earlier stage in my work due to the former not working well with what I needed, so I would prefer to stick with the binary format.</p><p class=""><span style="font-size: 12pt;" class="">I had a quick view at the code for some of the Viewer-routines, but </span><span style="font-size: 12pt;" class="">I'm not well versed in
</span><span style="font-size: 12pt;" class="">gleaning </span><span style="font-size: 12pt;" class="">information about header sizes
</span><span style="font-size: 12pt;" class="">from that. H</span><span style="font-size: 12pt;" class="">ints about what I'm looking for there would be appreciated.</span><span style="font-size: 12pt;" class=""> </span><br class="">
</p><p class=""><br class="">
</p><p class="">Best regards</p><p class="">Peder</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1" class="">
<div id="divRplyFwdMsg" dir="ltr" class=""><font face="Calibri, sans-serif" style="font-size:11pt" class=""><b class="">Fra:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>><br class="">
<b class="">Sendt:</b> 4. oktober 2021 15:37:08<br class="">
<b class="">Til:</b> Peder Jørgensgaard Olesen<br class="">
<b class="">Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a><br class="">
<b class="">Emne:</b> Re: [petsc-users] Skipping data when reading from binary file</font>
<div class=""> </div>
</div>
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">On Mon, Oct 4, 2021 at 9:26 AM Peder Jørgensgaard Olesen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" class="">
<div id="gmail-m_9165503901133771575divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" class=""><p class="">Hello</p><p class="">I have a binary file in which a mix of different objects is stored (Vecs, Mats, PetscInts). I can read each element just fine using VecLoad, MatLoad, and PetscIntView, provided they're read in the order in which they were put in the binary. What I would
like to do is to skip the reading of any unneeded element, instead proceeding directly to the next one. I tried using PetscBinarySeek() for this, as shown in the attached code. This produces segmentation faults, suggesting that the file pointer isn't going
where I want it to.</p>
</div>
</div>
</blockquote>
<div class="">There is header information you also have to skip for each object.</div>
<div class=""><br class="">
</div>
<div class="">We can go over the sizes for that (it is best just to look at the code), but that is fragile. A more robust way to achieve this random</div>
<div class="">access is to use HDF5 and name the objects.</div>
<div class=""><br class="">
</div>
<div class=""> Thanks,</div>
<div class=""><br class="">
</div>
<div class=""> Matt</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr" class="">
<div id="gmail-m_9165503901133771575divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" class=""><p class="">Any suggestions as to what I'm doing wrong here?</p><p class=""><br class="">
</p><p class="">Best regards,</p><p class="">Peder</p>
<div id="gmail-m_9165503901133771575Signature" class="">
<div id="gmail-m_9165503901133771575divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" class=""><p class=""><br class="">
</p><div class=""><br class="webkit-block-placeholder"></div>
<table style="font-family:"Times New Roman";padding:0px;width:400px" cellspacing="0" cellpadding="0" border="0" class="">
<tbody class="">
<tr class="">
<td style="width:400px" class="">
<table style="width:400px;font-family:Arial;font-size:11.5px;border-collapse:collapse" cellspacing="0" cellpadding="0" border="0" class="">
<tbody class="">
<tr class="">
<td style="width:50px;vertical-align:top" valign="top" class="">
<table style="width:50px;padding-top:4px" cellspacing="0" cellpadding="0" class="">
<tbody class="">
<tr class="">
<td style="width:50px;vertical-align:top" align="left" class=""><img width="36" height="53" src="http://www.dtu.dk/-/media/DTU_Generelt/Andet/mail-signature-logo.png" class=""></td>
</tr>
</tbody>
</table>
</td>
<td style="width:350px;vertical-align:top" valign="top" class="">
<table style="width:350px;border-collapse:collapse" cellspacing="0" cellpadding="0" border="0" class="">
<tbody class="">
<tr class="">
<td style="width:350px;font-size:16px;margin:0px;font-weight:bold;line-height:19.2px" class="">
Peder Jørgensgaard Olesen</td>
</tr>
<tr class="">
<td style="width:350px;margin:0px;line-height:17px" class="">PhD student<br class="">
Department of Mechanical Engineering</td>
</tr>
<tr class="">
<td style="width:350px;margin:0px;line-height:17px" class=""> </td>
</tr>
<tr class="">
<td style="width:350px;line-height:17px" class=""><a href="mailto:pjool@mek.dtu.dk" id="gmail-m_9165503901133771575LPNoLP" style="margin: 0px; line-height: 17px;" target="_blank" class="">pjool@mek.dtu.dk</a></td>
</tr>
<tr class="">
<td style="width:350px;margin:0px;line-height:17px" class="">Koppels Allé</td>
</tr>
<tr class="">
<td style="width:350px;margin:0px;line-height:17px" class="">Building 403, room 105</td>
</tr>
<tr class="">
<td style="width:350px;margin:0px;line-height:17px" class="">2800 Kgs. Lyngby</td>
</tr>
<tr class="">
<td style="width:350px;line-height:17px" class=""><a href="https://www.dtu.dk/english" id="gmail-m_9165503901133771575LPNoLP" style="margin: 0px; line-height: 17px;" target="_blank" class="">www.dtu.dk/english</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table><div class=""><span style="font-size:10pt;color:rgb(117,123,128)" class=""></span><br class="webkit-block-placeholder"></div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all" class="">
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">
-- Norbert Wiener</div>
<div class=""><br class="">
</div>
<div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></blockquote></div><br class=""></div></body></html>