- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hallo
I am suposed to open large binary data files on the machine of a super computing center using a FORTRAN77 code. Before they exchanged their machine, the file could be opened and read by
open (iinp,file=filinp,status='unknown',form='unformatted')
read(iinp) timee,Ree,alpe,bete,a0e,mxe,mye,mze
...
where iinp = 2.
Now on the new machine (after getting the code compiled successfully) the code starts running but terminates before the line
read(iinp) timee,Ree,alpe,bete,a0e,mxe,mye,mze
with the logfile-output
...
forrtl: severe (39): error during read, unit 2, file
....
Has anyone any idea why the code is not able to read the data files on the new machine ?
The open-command before the read command is executed, I think. At least a log-file output placed before the read and after the open is generated successfully ....
Thankx
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are many possibilities. One is that the data file was written in a format incompatible with Intel Fortran. Most UNIX/Linux (and even Windows) compilers do write compatible files, but, for example, g77 on a 64-bit system does not. If this does not match, you could get such an error. However, "error during read" tends to indicate that the file system returned an unexpected error.
The first thing I would do is use "od" to dump the first hundred bytes or so of the file and look to see if the record length is in the first four bytes or first eight bytes. Intel Fortran wants four bytes (unless the record is larger than 2GB, in which case it is written in segments.)
Do you know what the file structure is supposed to be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your response!
The file was written unformatted (and I guess sequential) on a 64-bit BIG-endian machine as follows:
First record: Header consisting of four 8-Byte Reals followed by three 4-Byte Integers. Being the first record, the header is preceeded by 4 Bytes and followed by 4 Bytes
Following records: 3*384*384 Reals (8-Byte), preceeded and followed by 4 Bytes
3*384*384 Reals (8-Byte), preceeded and followed by 4 Bytes
3*384*384 Reals (8-Byte), preceeded and followed by 4 Bytes
and so on
In total there are 258 records, the first one is the header, the following ones as described above.
However, the machine I am trying to read the binary data file now, is a 64-bit LITTLE-endian machine (SGI Altix) and I think I do not correctly open or read the file respectively.
The lines
open(20,file='TestFile.bin',status='old',form='unformatted',access='direct',recl=4)
read(20,rec=1) head
where head is a variable containing 4 8-Byte Reals and 3 4-Byte Integers was resulting in numbers I did not expect at all, while
open(30,file='TestFile.bin',status='old',form='unformatted')
read(30) header
was resulting in run time error.
Unfortunatelly I also found the following on the web (http://wapedia.mobi/en/Endianness#6.):
"Fortran sequential unformatted files created with one endianness usually cannot be read on a system using the other endianness because Fortran usually implements a record (defined as the data written by a single Fortran statement) as data preceded and succeeded by count fields, which are integers equal to the number of bytes in the data. An attempt to read such file on a system of the other endianness then results in a run-time error, because the count fields are incorrect."
Is there any possibility to read a binary data file with the properties described above on a little endian machine anyway ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page