problem in reading unformatted data from a FORTRAN file [message #91244] |
Mon, 22 June 2015 06:48  |
DK
Messages: 12 Registered: June 2015
|
Junior Member |
|
|
The output in the FORTRAN file wrote like this:
-------------------------
real, x(10, 722, 144)
open(21, file='result.dat', form='unformatted')
...(some calculation about x)
write(21) x
close(21)
-------------------------
and reading program in IDL is like this:
----------------------------------
data=fltarr(10,722,144)
openr, lun, 'result.dat', /get_lun, /f77_unformatted
readu, lun, data
free_lun,lun
--------------------------------
But it looks like these code cannot read the file "result.dat" into the array "data". Where is the problem? Thanks!
|
|
|
Re: problem in reading unformatted data from a FORTRAN file [message #91246 is a reply to message #91244] |
Mon, 22 June 2015 07:23   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
What error did you get?
On 06/22/15 09:48, DK wrote:
> The output in the FORTRAN file wrote like this:
>
> -------------------------
>
> real, x(10, 722, 144)
>
> open(21, file='result.dat', form='unformatted')
> ...(some calculation about x)
> write(21) x
> close(21)
>
> -------------------------
>
>
> and reading program in IDL is like this:
>
> ----------------------------------
>
> data=fltarr(10,722,144)
> openr, lun, 'result.dat', /get_lun, /f77_unformatted
> readu, lun, data
> free_lun,lun
>
> --------------------------------
>
>
> But it looks like these code cannot read the file "result.dat" into
the array "data". Where is the problem? Thanks!
>
>
>
>
>
|
|
|
Re: problem in reading unformatted data from a FORTRAN file [message #91247 is a reply to message #91246] |
Mon, 22 June 2015 07:36  |
DK
Messages: 12 Registered: June 2015
|
Junior Member |
|
|
在 2015年6月22日星期一 UTC+8下午10:23:37,Paul van Delst写道:
> What error did you get?
>
>
> On 06/22/15 09:48, DK wrote:
>> The output in the FORTRAN file wrote like this:
>>
>> -------------------------
>>
>> real, x(10, 722, 144)
>>
>> open(21, file='result.dat', form='unformatted')
>> ...(some calculation about x)
>> write(21) x
>> close(21)
>>
>> -------------------------
>>
>>
>> and reading program in IDL is like this:
>>
>> ----------------------------------
>>
>> data=fltarr(10,722,144)
>> openr, lun, 'result.dat', /get_lun, /f77_unformatted
>> readu, lun, data
>> free_lun,lun
>>
>> --------------------------------
>>
>>
>> But it looks like these code cannot read the file "result.dat" into
> the array "data". Where is the problem? Thanks!
>>
>>
>>
>>
>>
No error. Just could not read the data in. There "0.000000" in the array "data" except the last part "data[*,*,143]". However, when the array was set to 2-Dimension in the FORTRAN file, the results will be OK.
|
|
|