LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Fortran unformatted file conversion from Solaris to linux (http://www.linuxquestions.org/questions/programming-9/fortran-unformatted-file-conversion-from-solaris-to-linux-151644/)

SenorPedo 02-28-2004 03:53 PM

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.

jailbait 02-28-2004 06:49 PM

"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

rnturn 02-29-2004 11:13 PM

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


All times are GMT -5. The time now is 12:11 AM.