Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Leftover bytes in a Direct Accessed file

WSinc
New Contributor I
590 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
590 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