corrected wrong byte offset when reading thru 2^31-1-8 four-byte limit
This commit is contained in:
parent
26c6063a2c
commit
28e9b483ad
|
@ -232,22 +232,19 @@ class MPIEspectral_result: # mimic py_post result object
|
||||||
|
|
||||||
def element_scalar(self,e,idx):
|
def element_scalar(self,e,idx):
|
||||||
fourByteLimit = 2**31 -1 -8
|
fourByteLimit = 2**31 -1 -8
|
||||||
incStart = self.dataOffset\
|
incStart = self.dataOffset \
|
||||||
+ self.position*(( 1\
|
+ self.position*8*( 1 + self.N_elements*self.N_element_scalars*8//fourByteLimit \
|
||||||
+ self.N_elements*self.N_element_scalars\
|
+ self.N_elements*self.N_element_scalars)
|
||||||
+(self.N_elements*self.N_element_scalars*8)//fourByteLimit\
|
# header & footer + extra header and footer for 4 byte int range (Fortran)
|
||||||
)*8)
|
|
||||||
# header and footer
|
|
||||||
# values
|
# values
|
||||||
# extra header and footer for 4 byte int range (Fortran)
|
|
||||||
where = (e*self.N_element_scalars + idx)*8
|
where = (e*self.N_element_scalars + idx)*8
|
||||||
try:
|
try:
|
||||||
if where%fourByteLimit + 8 >= fourByteLimit: # danger of reading into fortran record footer at 4 byte limit
|
if where%fourByteLimit + 8 >= fourByteLimit: # danger of reading into fortran record footer at 4 byte limit
|
||||||
data=''
|
data=''
|
||||||
for i in xrange(8):
|
for i in xrange(8):
|
||||||
where+= 1
|
|
||||||
self.file.seek(incStart+where+(where//fourByteLimit)*8+4)
|
self.file.seek(incStart+where+(where//fourByteLimit)*8+4)
|
||||||
data+=self.file.read(1)
|
data += self.file.read(1)
|
||||||
|
where += 1
|
||||||
value = struct.unpack('d',data)[0]
|
value = struct.unpack('d',data)[0]
|
||||||
else:
|
else:
|
||||||
self.file.seek(incStart+where+(where//fourByteLimit)*8+4)
|
self.file.seek(incStart+where+(where//fourByteLimit)*8+4)
|
||||||
|
|
Loading…
Reference in New Issue