- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to read a binary file in LINUX IA64 which was written by a fortran compilerin SGI, anybody knows how to reada binary file in linux ia64transferred from SGI? THANKS.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With SGI, there are several possibilities. Their Fortran supports either a C compatible sequential form, or Fortran sequential or direct access. I believe all of the binary file formatsare big-endian,same asother Unix platforms, even though the hardware is not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks, but I am still confused. eg. I write a real*8 variable in a binary file using fortran in SGI, how can I read it correctly using fortran in linux ia64? thanks.in In SGI,
u=1.2d-5
open(1,FILE=filename,FORM='UNFORAMTTED',ACTION='WRITE')
write(1) u
And then in Linux IA64,
open(1,FILE=filename,FORM='BINARY',ACTIONON='READ')
read(1) u
.but I can not get the value correctly, what is the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If SGI machines are indeed big endian (I don't know), then
compile your code on the ia64 box with '-convert big_endian'.
This will tell the compiler to read/write the files as
big_endian instead of the the default little_endian.
Craig
compile your code on the ia64 box with '-convert big_endian'.
This will tell the compiler to read/write the files as
big_endian instead of the the default little_endian.
Craig
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
'BINARY' is a non-standard Fortran format which is more compatible with C. If you want to use that on the Intel side, you should use the equivalent on the SGI side (not standard Fortran unformatted). It may be called 'binary' there too; my memory isn't that good. You still have to reverse the byte order within each data item. There are options in Intel Fortran to open the file as a big-endian file, which should do the job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think Craig has the right idea. You can now use CONVERT='BIG_ENDIAN' in OPEN as well. This will properly interpret the record lengths and do the byte swap of integer and real data. The caveat is that you have to list the variables directly in the I/O list - you can't use a record or derived type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, after I add CONVERT='BIG_ENDIAN', it works. thank you, guys, this is the first time I ask questions in this forum, and I really appreciate your help.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page