Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28632 Discussions

How to read the record length of unformatted sequential file

tlillys
Beginner
287 Views
Hello all,
A post-processing code I am updating was written for Open Watcom 1.1 and makes use of the fnextrecl function to process an unformatted, sequential file. The function (I'm guessing) reads the first 4 bytes of the file to determine the record length and then some decision work is performed based on that length.
I am looking for a way to do the same thing in CVF 6.6c: determine the length of the next record and read the record based upon the returned length. A two step work around is fine, too (e.g., read and store the length of each record, rewind, and process).
thanks in advance
tlillys
0 Kudos
1 Reply
Steven_L_Intel1
Employee
287 Views
The way I would handle this is to open the file FORM="BINARY" and read the length words directly as an integer. There is a 32-bit integer length preceding and following the data. See the Programmer's Guide for details on the layout.
0 Kudos
Reply