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

Leftover bytes in a Direct Accessed file

WSinc
New Contributor I
560 Views
Suppose I have a file with 10039 bytes in it, and specify a record size of 100 bytes.

If I open it with ACCESS=DIRECT, then I can process 100 records OK, but how do I process the
leftover 39 bytes?

In other words, what is it supposed to do when I specify reading record no 101?
Does it read the leftover 39 bytes and give back an error message?

Of course, expecting the no of bytes to come out even would not be realistic.
The file size could even be a prime number.....
0 Kudos
1 Reply
Steven_L_Intel1
Employee
560 Views

What is supposed to happen is that you get an error. The fate of the 39 bytes is undefined.

I would suggest opening such a file for stream access, reading 100 bytes at a time and then you can read the remaining 39 bytes without much difficulty.
0 Kudos
Reply