> On Dec 3, 2018, at 1:57 PM, Sajid Ali <[email protected]> > wrote: > > 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) ? Yes. > > Are the doubles stored in IEEE_754 format ? I don't know the format. From the manual page for PetscBinaryRead() Notes: PetscBinaryRead() uses byte swapping to work on all machines; the files are written to file ALWAYS using big-endian ordering. > > On Mon, Dec 3, 2018 at 1:43 PM Smith, Barry F. <[email protected]> wrote: > > You saved a Vec to the file, not a Mat. > > > > > On Dec 3, 2018, at 1:38 PM, Sajid Ali via petsc-users > > <[email protected]> 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@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 ..@... > > 0000024: 00000000 00000000 00000000 00000000 01000000 00010000 ....@. > > 000002a: 00000000 00000000 00000000 00000000 00000000 00000000 ...... > > 0000030: 01000000 00010100 00000000 00000000 00000000 00000000 @..... > > 0000036: 00000000 00000000 01000000 00011000 00000000 00000000 ..@... > > 000003c: 00000000 00000000 00000000 00000000 01000000 00011100 ....@. > > 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 ..@... > > 0000084: 00000000 00000000 00000000 00000000 01000000 00110000 ....@0 > > 000008a: 00000000 00000000 00000000 00000000 00000000 00000000 ...... > > 0000090: 01000000 00110001 00000000 00000000 00000000 00000000 @1.... > > 0000096: 00000000 00000000 01000000 00110010 00000000 00000000 ..@2.. > > 000009c: 00000000 00000000 00000000 00000000 01000000 00110011 ....@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 > > ([email protected] 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
Re: [petsc-users] PETSc binary write format
Smith, Barry F. via petsc-users Mon, 03 Dec 2018 13:56:57 -0800
- [petsc-users] PETSc binary write format Sajid Ali via petsc-users
- Re: [petsc-users] PETSc binary write ... Smith, Barry F. via petsc-users
- Re: [petsc-users] PETSc binary wr... Sajid Ali via petsc-users
- Re: [petsc-users] PETSc binar... Smith, Barry F. via petsc-users
- Re: [petsc-users] PETSc b... Sajid Ali via petsc-users
- Re: [petsc-users] PE... Sajid Ali via petsc-users
- Re: [petsc-users... Mark Adams via petsc-users
- Re: [petsc-u... Sajid Ali via petsc-users
- Re: [petsc-u... Smith, Barry F. via petsc-users
- Re: [petsc-u... Sajid Ali via petsc-users
- Re: [petsc-u... Sajid Ali via petsc-users
- Re: [petsc-u... Smith, Barry F. via petsc-users
- Re: [petsc-u... Sajid Ali via petsc-users
- Re: [petsc-u... Sajid Ali via petsc-users
