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

Home » Public Forums » archive » Re: Fortran unformatted data: Big or little endian
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: Fortran unformatted data: Big or little endian [message #34956 is a reply to message #34955] Wed, 30 April 2003 06:30 Go to previous messageGo to previous message
Michael Schroeter is currently offline  Michael Schroeter
Messages: 5
Registered: January 2002
Junior Member
David Fanning wrote:
> Michael Schroeter (schroeter@muk.uni-hannover.de) writes:
>
>
>> I have a problem reading Fortran unformatted data in IDL. I have a file
>> containing data of well known size (e.g., an array of 100 x 100 single
>> precision floating point values). Unfortunately, I don't know something
>> about the machine (big or little endian machine) on which the file has
>> been produced. Is there a way to get this information on the fly by IDL
>> in order to open the file automatically in the correctly (using the
>> /SWAP_ENDIAN option or not). The way I used so far was trial and error.
>> But since I have many of those files I'm searching for a solution
>> without recompiling my source code.
>>
>> Do you have any ideas?
>
>
> Here is an article with some ideas:
>
> http://www.dfanning.com/tips/endian_machines.html
>
> Cheers,
>
> David
>

Hi David,

the problem is that I don't know the "endian nature" of the machine that
created the data.

In the meanwhile I tried using error catching, like shown in this
code-snippet:

array = FLTARR(100,100)
OPENR, lun, data_file, /F77_UNFORMATTED, /GET_LUN

CATCH, error_status
IF error_status NE 0 THEN BEGIN
PRINT, 'Error index: ', error_status
PRINT, 'Error message: ', !ERROR_STATE.MSG
FREE_LUN, lun
OPENR, lun, data_file, /SWAP_ENDIAN, /F77_UNFORMATTED, /GET_LUN
READU, lun, array
CATCH, /CANCEL
ENDIF ELSE BEIN
READU, array
ENDELSE

and it works (up to now ;-)).

Anyway, thanks and best regards

Michael
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fortran unformatted data: Big or little endian
Next Topic: Re: WIDGET_TEXT - HOW TO NOT CHANGE VALUE OF TEXT WHILE EDITING FIELD?

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

Current Time: Sat Oct 11 12:00:16 PDT 2025

Total time taken to generate the page: 0.72006 seconds