[petsc-users] Skipping data when reading from binary file

Matthew Knepley knepley at gmail.com
Mon Oct 4 08:37:08 CDT 2021


On Mon, Oct 4, 2021 at 9:26 AM Peder Jørgensgaard Olesen via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hello
>
> 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.
>
There is header information you also have to skip for each object.

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
access is to use HDF5 and name the objects.

  Thanks,

     Matt

> Any suggestions as to what I'm doing wrong here?
>
>
> Best regards,
>
> Peder
>
>
> Peder Jørgensgaard Olesen
> PhD student
> Department of Mechanical Engineering
>
> pjool at mek.dtu.dk
> Koppels Allé
> Building 403, room 105
> 2800 Kgs. Lyngby
> www.dtu.dk/english
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20211004/6203cf97/attachment.html>


More information about the petsc-users mailing list