[petsc-users] reading petsc binary vec in python.

Ataollah Mesgarnejad amesga1 at tigers.lsu.edu
Mon Jul 18 17:56:05 CDT 2011


Thanks Ethan,

I did as you said but when I try to read the file using:

petsc_objs = PetscBinaryRead.readBinaryFile('V-018.bin')

I get the following error:

Traceback (most recent call last):
  File "./petscvec.py", line 4, in <module>
    petsc_objs = PetscBinaryRead.readBinaryFile('V-018.bin')
  File "/Users/ataollahmesgarnejad/Software/petsc-3.1/bin/python/PetscBinaryRead.py", line 118, in readBinaryFile
    header = np.fromfile(fid, dtype=IntType, count=1)[0]
IndexError: index out of bounds

Which is peculiar since when I try to read the header myself using:

header=numpy.fromfile('V-018.bin',dtype='>i4',count=1) 
print header[0]

I get:

1211214

which is a Vec identifier.

Any thoughts on what goes wrong?

Best,
Ata


More information about the petsc-users mailing list