Sorry, I still don't understand how to use FortranFile ...
============
The fortran code
============
program writeArray
implicit none
integer,parameter:: nx=2,ny=5
real(4),dimension(nx,ny):: ux,uy,p
integer :: i,j
do i = 1,nx
do j = 1,ny
ux(i,j) = 100. + j+(i-1.)*10.
uy(i,j) = 200. + j+(i-1.)*10.
p(i,j) = 300. + j+(i-1.)*10.
enddo
enddo
open(11,file='uxuyp.bin',form='unformatted')
write(11) ux,uy
write(11) p
close(11)
end program writeArray
=============
The Python script
=============
from fortranfile import FortranFile
f = FortranFile('uxuyp.bin')
x = f.readReals()
=============
The output
=============
Traceback (most recent call last):
File "readArray.py", line 5, in <module>
x = f.readReals()
File
"/home/users/redone/file2/froger/travail/codes/lib/Tests/fortranread/fortranfile.py",
line 181, in readReals
data_str = self.readRecord()
File
"/home/users/redone/file2/froger/travail/codes/lib/Tests/fortranread/fortranfile.py",
line 128, in readRecord
raise IOError('Could not read enough data')
IOError: Could not read enough dat
=> How to read the file 'uxuyp.bin' ?
2009/5/28 David Froger <[email protected]>
> Thank you very much :-)
>
> 2009/5/28 Neil Martinsen-Burrell <[email protected]>
>
>> On 2009-05-28 09:32 , David Froger wrote:
>>
>>> Hy Neil Martinsen-Burrell,
>>>
>>> I'm trying the FortranFile class,
>>> http://www.scipy.org/Cookbook/FortranIO/FortranFile
>>>
>>> It looks like there are some bug in the last revision (7):
>>>
>>> * There are errors cause by lines 60,61,63 in
>>>
>>> * There are indentation errors on lines 97 and 113.
>>>
>>
>> There seem to have been some problems in putting the file on the wiki
>> ("Proxy-Connection: keep-alive\nCache-Control: max-age=0" seems to come from
>> an HTML communication). I've attached my current version of the file to
>> this email. Let me know if you have problems with this. I will try to get
>> the working version up on the wiki. Peace,
>>
>> -Neil
>>
>> _______________________________________________
>> Numpy-discussion mailing list
>> [email protected]
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion