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

Home » Public Forums » archive » Reading in a binary file in IDL - based on fortran reader?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Reading in a binary file in IDL - based on fortran reader? [message #88901 is a reply to message #88900] Wed, 02 July 2014 06:34 Go to previous messageGo to previous message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Wednesday, July 2, 2014 2:17:18 PM UTC+1, Paul van Delst wrote:
> On 07/02/14 09:05, rjp23@le.ac.uk wrote:
>
>> I figured out reading the header in and the above seemed to work but I'm not sure how to progress on to a different record.
>
>>
>
>> The fortran code I have is similar to:
>
>>
>
>> READ(10,rec=1) a, b, c, d
>
>> READ(10,rec=5) data
>
>>
>
>> I've been able to read in all the header info from "rec1" but how do I then proceed on to rec5?
>
>
>
> Ah. A Fortran direct access file! IDL doesn't really have an equivalent
>
> - a regular OPENR will give you stream file (I think that's the correct
>
> term) just like C (or most anything else) would.
>
>
>
> In IDL, to proceed onto record #5 (skipping recs 2-4) you can use the
>
> POINT_LUN procedure. This will position the file pointer wherever you
>
> want it.
>
>
>
> Of course, you will have to know what the file record length is and
>
> compute the position accordingly.
>
>
>
> Note that the units of POINT_LUN are bytes. Some Fortran compilers
>
> assume words (4-bytes) as the record length unit, so make sure you take
>
> that into account if necessary. (And apologies if you already know this :o)
>
>
>
> cheers,
>
>
>
> paulv

Thanks, I knew the record length so could skip records by reading in that many bytes but I didn't know how far into the first record I was so didn't know how much to skip.

Using point_lun I managed to solve it and go directly to the start of the 5th record.

Thanks again for your help, you've just saved me several hours of head scratching :-)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: band selection
Next Topic: Label dots in a Ternary plot

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

Current Time: Wed Oct 08 19:02:06 PDT 2025

Total time taken to generate the page: 0.00565 seconds