One issue thats faced in trying to read formatted text files is determining the number of records (lines) in the file and the number of possible empty records prior to actually reading the file. The user is required to write their own loops and test for EOF and/or EOR conditions while keeping a count of the number of lines read and if a record is empty. This means the user has to loop through the file twice. To me counting the number of records in a formatted file and the number of empty records is something that should be done by INQUIRE since the compiler developers could (hopefully) write more efficient (faster) and safer code than the average user can. Therefore I propose adding two new optional arguments to INQUIRE that return the number of records and the number of empty records in formatted files. ie. something like
Note this would only apply to formatted text (although you might be able to use it for stream access if you write
your own EOR marks but that might be overcomplicating things). Since these are new options legacy code would not be affected.
One issue thats faced in trying to read formatted text files is determining the number of records (lines) in the file and the number of possible empty records prior to actually reading the file. The user is required to write their own loops and test for EOF and/or EOR conditions while keeping a count of the number of lines read and if a record is empty. This means the user has to loop through the file twice. To me counting the number of records in a formatted file and the number of empty records is something that should be done by INQUIRE since the compiler developers could (hopefully) write more efficient (faster) and safer code than the average user can. Therefore I propose adding two new optional arguments to INQUIRE that return the number of records and the number of empty records in formatted files. ie. something like
integer :: nrecs, nempty INQUIRE(file="myfile.txt", form="formatted", num_records=nrecs, num_empty_records=nempty)
Note this would only apply to formatted text (although you might be able to use it for stream access if you write your own EOR marks but that might be overcomplicating things). Since these are new options legacy code would not be affected.