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.
29282 Discussions

quickly testing variable-length record sequential files?

gregfi04
Beginner
364 Views
The code I'm working on reads in large, variable-length sequential-access binary files. The files are read gradually throughout the execution of the code. Based on the user's input, the length of each record could be determined a priori.

I'd like to add a check to make sure the length of the file that the user has supplied is appropriate before the calculation starts. The idea is to prevent the user from burning hours of compute time only to discover that they supplied a bogus data file. Is there any way to quickly read each leading length field in the file?

Thanks,
Greg
0 Kudos
1 Reply
mecej4
Honored Contributor III
364 Views
IFort provides the routine GETFILEINFOQQ in module IFPORT, by calling which you can obtain the length of the file.

If, as you stated, you can find the length of each record based on user input, and if you can determine the numbers of records of each known length in the file, you can compute the expected file length from the user input and compare that to the file length returned by GETFILEINFOQQ.
0 Kudos
Reply