LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Trouble reading binary data files with Fortran 77 program on Linux box with gcc (https://www.linuxquestions.org/questions/programming-9/trouble-reading-binary-data-files-with-fortran-77-program-on-linux-box-with-gcc-787008/)

kab 02-04-2010 10:49 AM

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.

paulsm4 02-04-2010 11:13 AM

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


All times are GMT -5. The time now is 04:06 AM.