Why does it do that stupid little thing when its writing binary data, tacking the extra integer on the beginning and the end?
I know the reason for it: any binary file in fortran has to be separated into records. On the other hand any record may contain any sequence of characters, thus no record separators (like the newline for formatted files) can be defined. One of the solutions (not encoded within the standard, so be careful when you want to read a binary fortran file from a new architecture) is putting an extra piece meta-information with the length of the line (usually a four bytes integer not belonging to the record itself).
Now you may want to ask: Why the length of the record is written both at the beginning and at the end of any record?
The reason for this is that the fortran code should be able to move both forward and backward of one record at a time.
Ones I bacame mad trying to discover these things... also consider that the extra bytes at the boundaries of the records are written with the endianesses of the machine you are using! That time I hated fortran too!
Bye,
An happy Fortran and C user
I know the reason for it: any binary file in fortran has to be separated into records. On the other hand any record may contain any sequence of characters, thus no record separators (like the newline for formatted files) can be defined. One of the solutions (not encoded within the standard, so be careful when you want to read a binary fortran file from a new architecture) is putting an extra piece meta-information with the length of the line (usually a four bytes integer not belonging to the record itself). Now you may want to ask: Why the length of the record is written both at the beginning and at the end of any record? The reason for this is that the fortran code should be able to move both forward and backward of one record at a time. Ones I bacame mad trying to discover these things