Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 02-28-2004, 03:53 PM   #1
Registered: Oct 2002
Location: Richmond, VA
Distribution: RH7.3 & RH9
Posts: 40

Rep: Reputation: 15
Fortran unformatted file conversion from Solaris to linux

I have a binary data file that was written on a 64-bit Solaris box, I believe, and I need to read it in on my linux box. I understand that my linux architecture is considered to be "little endian" while Solaris is "big endian", but I'm not sure what that really means. More importantly, I don't know if or how I can convert between the two. Any help or suggestions would be greatly appreciated.
Old 02-28-2004, 06:49 PM   #2
LQ Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,863

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
"I understand that my linux architecture is considered to be "little endian" while Solaris is "big endian", but I'm not sure what that really means. "

Here are two explanations of what little endian and big endian mean.

The other thing that you need to know is the format of the fields in the records on the binary data file that was written on a 64-bit Solaris box. Is each field a two byte binary number, a four byte binary number, or what? Do you have any floating point numbers which is a whole different kettle of fish?

Once you know the format of the Solaris fields you can probably convert each field by using modulo arithmetic. Or, alternatively, you could use Google to find a Fortran endian conversion routine.

Be prepared. Create a LifeBoat CD.

Steve Stites
Old 02-29-2004, 11:13 PM   #3
Senior Member
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,137

Rep: Reputation: 65
Knowing the layout of the numbers is critical. Assuming that you're talking about floating point, you'll need to know the number of bits in the mantissa and the exponent and what format each of these uses. (Caveat: I'm awfully rusty at this; it's been years since I've needed to do anything like this.) Somewhere in the Solaris documentation there should be a description of the floating point number format. There should be one available for whatever language you're using on Linux as well. If you're talking integer data, that should be a lot simpler and all you would have to do is swap the byte ordering appropriately. (You might find that the "swab" option of "dd" does the trick in this case.) Using a perl script you should be able to extract the different pieces of the data and swap or otherwise massage them into the Linux format. I'd probably choose Perl for this only because my C is getting pretty rusty too.

Good luck,



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
does linux fortran compiler in fedora 4 support VAX FORTRAN? terrence Programming 17 08-31-2005 08:59 AM
Cant find Fortran File unixfreak Linux - Newbie 21 09-03-2004 01:21 PM
installing linux on unformatted hard drive with no operating system gjhowar Linux - Newbie 4 08-18-2004 04:29 PM
Conversion of outlook .pst file into any Linux mail client format Mayuresh Linux - Software 1 08-09-2004 10:52 AM
how can I see a fortran file in linux tal Linux - Newbie 2 10-02-2003 11:48 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:38 PM.

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