[petsc-users] PETSc binary write format
Sajid Ali
sajidsyed2021 at u.northwestern.edu
Mon Dec 3 13:57:28 CST 2018
Apologies for the error on my part.
Does the vector binary format also work the same way : VEC_FILE_CLASSID
(32 bit int), num_elements (32 bit int) , value of the elements in double
(num_elements*64 bit double) ?
Are the doubles stored in IEEE_754 format ?
On Mon, Dec 3, 2018 at 1:43 PM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
>
> You saved a Vec to the file, not a Mat.
>
>
>
> > On Dec 3, 2018, at 1:38 PM, Sajid Ali via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
> >
> > Hi,
> >
> > I ran ex10 from /vec/examples/tutorials and saved the matrix in binary
> format.
> >
> > Looking at the matrix in binary using xxd, I see
> >
> > [sajid at xrm temp]$ xxd -b vector.dat
> > 0000000: 00000000 00010010 01111011 01001110 00000000 00000000 ..{N..
> > 0000006: 00000000 00010100 00000000 00000000 00000000 00000000 ......
> > 000000c: 00000000 00000000 00000000 00000000 00111111 11110000 ....?.
> > 0000012: 00000000 00000000 00000000 00000000 00000000 00000000 ......
> > 0000018: 01000000 00000000 00000000 00000000 00000000 00000000 @.....
> > 000001e: 00000000 00000000 01000000 00001000 00000000 00000000 .. at ...
> > 0000024: 00000000 00000000 00000000 00000000 01000000 00010000 .... at .
> > 000002a: 00000000 00000000 00000000 00000000 00000000 00000000 ......
> > 0000030: 01000000 00010100 00000000 00000000 00000000 00000000 @.....
> > 0000036: 00000000 00000000 01000000 00011000 00000000 00000000 .. at ...
> > 000003c: 00000000 00000000 00000000 00000000 01000000 00011100 .... at .
> > 0000042: 00000000 00000000 00000000 00000000 00000000 00000000 ......
> > 0000048: 01000000 00100000 00000000 00000000 00000000 00000000 @ ....
> > 000004e: 00000000 00000000 01000000 00100010 00000000 00000000 ..@"..
> > 0000054: 00000000 00000000 00000000 00000000 01000000 00100100 ....@$
> > 000005a: 00000000 00000000 00000000 00000000 00000000 00000000 ......
> > 0000060: 01000000 00100110 00000000 00000000 00000000 00000000 @&....
> > 0000066: 00000000 00000000 01000000 00101000 00000000 00000000 ..@(..
> > 000006c: 00000000 00000000 00000000 00000000 01000000 00101010 ....@*
> > 0000072: 00000000 00000000 00000000 00000000 00000000 00000000 ......
> > 0000078: 01000000 00101100 00000000 00000000 00000000 00000000 @,....
> > 000007e: 00000000 00000000 01000000 00101110 00000000 00000000 .. at ...
> > 0000084: 00000000 00000000 00000000 00000000 01000000 00110000 .... at 0
> > 000008a: 00000000 00000000 00000000 00000000 00000000 00000000 ......
> > 0000090: 01000000 00110001 00000000 00000000 00000000 00000000 @1....
> > 0000096: 00000000 00000000 01000000 00110010 00000000 00000000 .. at 2..
> > 000009c: 00000000 00000000 00000000 00000000 01000000 00110011 .... at 3
> > 00000a2: 00000000 00000000 00000000 00000000 00000000 00000000 ......
> >
> >
> > The format of the binary file is supposed to be
> > MAT_FILE_CLASSID, num_rows, num_cols, -1 followed by data.
> >
> > Converting the first 4 bytes (32 bits) of binary to int, the number
> > 00000000000100100111101101001110 becomes 1211214, but the value of
> MAT_FILE_CLASSID according to the header file petscmat.h is 1211216 (
> petsc at 3.10.2.1 built without complex support). What causes this
> discrepancy ?
> >
> > Also, what are the special characters at the end of every line ? Am i
> not reading the binary file correctly ?
> >
> >
> > Thank You,
> > Sajid Ali
> > Applied Physics
> > Northwestern University
>
>
--
Sajid Ali
Applied Physics
Northwestern University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181203/cc8ed26f/attachment-0001.html>
More information about the petsc-users
mailing list