comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » problem in reading unformatted data from a FORTRAN file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
problem in reading unformatted data from a FORTRAN file [message #91244] Mon, 22 June 2015 06:48 Go to next message
DK is currently offline  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 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  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 Go to previous message
DK is currently offline  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.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: size(/dimen) that automatically fills in extra dimensions
Next Topic: Inconsistency in the position of the text() function

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:33:00 PDT 2025

Total time taken to generate the page: 0.00488 seconds