This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: how to read out binary data
- To: Bomin Sun <bsun at whoi dot edu>
- Subject: Re: how to read out binary data
- From: Ingo Krabbe <ikrabbe at earthling dot net>
- Date: Wed, 17 Jan 2001 16:19:31 +0100
- Cc: gcchelp <gcc-help at gcc dot gnu dot org>
- Organization: ASK (autmatische software komponenten)
- References: <3A650CE7.80E6B9AB@whoi.edu>
Am Mittwoch, 17. Januar 2001 04:09 schrieben Sie:
> hello,
>
> the linux system I am using is installed in the pc with intel III.
>
> I have a problem in reading binary data file (e.g., a binary file
> (integer*2) downloaded from a website) using a fortran program under my
> linux environment.
>
> The program (also was provided by those data people) to read the file
> is:
>
> integer*2 isea(100,100)
> open(1,file='seatemp.dat',form='unformatted')
> read(1) isea
> print*,isea(1,1)
> stop
> end
>
> I used g77 to compile that program. The output from that program is
> totally wrong.
> for example, the value of isea(1,1) is a very large integer number.
May this be a problem of byteorder ? On a PC for example the word order of
integers is different so that the lowest order byte written into a data file
by a SUN or other machine will go into the highest byte of the PC integer.
The effect of byteorder problems is exactly that small numbers will end up in
very large one. Please crosscheck that.