LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2010, 10:49 AM   #1
kab
LQ Newbie
 
Registered: Feb 2009
Posts: 1

Rep: Reputation: 0
Trouble reading binary data files with Fortran 77 program on Linux box with gcc


Hi--

I have Linux Red Hat 3.4.6-10 with gcc 3.4.6.
I am trying to convert an old program written in Fortran 77 compiled under Solaris using SUNWspro/SC4.2 compiler. The program compiles with my gcc compiler, but chokes when I try to read a binary data file.

Here is one of the read statements in the program:
read(iounit, iostat=ios,rec=irc) idata

Is it possible to read a binary file with gcc 3.4.6? Or is there another version Gnu Fortran that would do the job?

thanks.
 
Old 02-04-2010, 11:13 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Yes, you can read binary data with f77.

There are lots of potential problems with binary data in ANY language, on ANY platform.

Two pitfalls come immediately to mind:

1) DOS CR/LF vs Linux NEWLINE
2) Little-endian vs Big-endian byte order

SUGGESTION:
Get out your favorite hex editor and try to figure out exactly what your program is "choking" on.

My guess is probably byte-ordering (you originally created the files on a SPARC workstation (big-endian), but you're trying to read them on an Intel PC (little-endian).

Good luck .. PSM

Last edited by paulsm4; 02-04-2010 at 11:16 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with reading back serial binary data esi-eric Linux - Software 15 10-03-2018 09:13 AM
how to Reading And Writing SAC (Seismic Analysis Code) Data Files in Fortran codes lengyue Linux - Software 2 12-03-2008 12:39 PM
Reading binary files on CDROM dwforslund Linux - General 2 09-29-2005 05:39 PM
Problem in reading/writing binary data in Linux esi-eric Linux - Hardware 3 07-20-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration