This thread has strayed into the area of desirable attributes of datafiles, a particular interest of mine.
It seems to me that datafiles for Fortran programs can be either plain text or unformatted (binary) sequential files. There doesn’t seem to be much point in making the files direct access so that the records can be read in any order. If you are creating datafiles from scratch it seems sensible that they should be plain text, and I can see the merits of creating them in a text editor (like Notepad) or in a spreadsheet (like Excel) as in the latter you can generate some of the data according to rules.
Plain text has the advantage that you can create it very easily in the first place, and modify it later at will.
Now imagine that you have a Windows program, created say with FTN95 and Clearwin+, and where the datafile is not created as lists of numbers in an editor, but is derived from work in progress in the application itself, and this may be via some form of graphical input. We want to save the dataset, possibly to open and modify it at some future date, or at least to work with it. The problem now is not so clear cut.
If the basic file format for the program is a plain text file, then once again it is easy to open in an editor to modify it. However, user modification may create errors in the file that render it difficult to read back, or somehow inconsistent, i.e. invalid for the application. If it is saved as a binary file, then direct user modification is pretty much impossible, and when it comes to reading a file that the program created in the first place, it is (subject to the program actually working!) a foregone conclusion that the datafile is both valid and readable. Whatever validity checks are done, they can be much simpler if a binary format is chosen than if a plain text format is chosen.
Moreover, the binary format will preserve an appropriate number of decimal places of precision, whereas the precision is always somewhat compromised in the conversion to and from decimals.
Particularly in the case of binary files it is annoying to a user if a file of version 1 of the application cannot be opened in version 2 (well it is to me, my example being CorelDRAW where I created files in versions 1, 2, 3, 4 that are no longer readable without version 5 on the computer, and the current version is 17 – X7 – so you know that 5 isn’t going to work well under Windows 10, as version 5 was contemporary with Windows 98!). A plain text datafile continues to be readable with an editor, and presumably can be massaged into an appropriate format, whereas a binary file may not be, at least not without a lot of codebreaking skill.
Moreover, the convention in Windows is to identify a file by its extension, and to associate some extensions with certain applications via the Registry entries. This is all well and good for such universal extensions such as .FOR (etc), but may not be with your chosen default extension. So, for the unimaginative, one tries to open .DAT files and discovers that instead of the expected plain text input for a particular application, you have instead tried to open a virus scanner’s set of virus definitions – the people writing that being equally as unimaginative.
If in writing a datafile, the program name AND version number is embedded somewhere near the top, it is possible to verify at least that you have opened a file that is intended for your program, AND you can take the necessary steps to accommodate an earlier version layout or content of the data file. Discovering version info from the layout of a datafile without this help is difficult.
A particular peril of plain text is the assumption of the likely values that the variables might take. As an example I often operate on (x,y) coordinates in the range -200 to +200 m, accurate to 3 decimal places (mm). Some decades ago I got into the habit of writing them in a format F10.3. Circa 1990 I wrote a program in Fortran to run under DOS to store topographic coordinates in a 2000 x 1000m box. (continued)