LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 02-28-2004, 03:53 PM   #1
SenorPedo
Member
 
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
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, SolydK 2013
Posts: 7,434

Rep: Reputation: 134Reputation: 134
"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.

http://www.cs.umass.edu/~verts/cs32/endian.html

http://www.codeproject.com/cpp/endianness.asp

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.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 02-29-2004, 11:13 PM   #3
rnturn
Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0), SuSE (10.x, 11.x, 12.2), Solaris (8-10), Tru64
Posts: 889

Rep: Reputation: 45
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,

Rick
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 01:13 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration