Dan,
Perhaps this forum isn’t the right place to ask for mods to standard fortran.
GENERAL RAMBLE
Subject to correction by someone who knows better, * formatting was invented for Fortran 77. I used a Fortran 66 (for ICL 1900/2900 series computers) that had a format 0 which was more or less the same thing. It also had formats such as I0 and F0.0 Nothing better has been introduced as far as I can see since, except maybe the wider adoption of list-directed i/o although I personally never use it as it doesn’t fit with the way I do things.
Some chums of mine once programmed a complete data description language which allowed for simple formulae as well as values (I’m sure it wasn’t unique) but you definitely needed to know in the program how many variables and their types you were expecting at any instant.
There shouldn’t be any problem in matching output from one fortran program with input to another as then you know what format it was written in, but Dan’s problem is that he doesn’t know how many data items he has in the file (or each line of the file), how they are delimited (or is this someone else’s insertion) nor what type they are. “You end up analysing the data” he says, and of course, there is no alternative, if you have no control over how the data stream is written in the first place. The problem is to parse the data stream, and that requires, I suspect, all the arts of the compiler writer.
If you have control over how that data set is written in the first place, you have more chance of being able to read it. If, for example, you wanted to read a list of numbers it would be simplest if they were output one-per-line, with a line containing some character(s) that might trigger an ERR= in the read statement. You could also hint at what type the data item was, maybe by putting something like the letter I in column 1 for an integer.
List directed input also assumes that you have control over the creation of the data set in the first place.
POSSIBLE SOLUTION?
If one has to “end up analysing the data”, then the FTN77 library routine READFA@ seems useful, as it finds the length of a line in characters as well as reading it into a CHARACTER*(*) variable to analyse, and that removes one of the problems in “analysing it”. You might need to open the file with OPENR@ (or OPENV@ if you understand the description of what it does!).
It occurs to me that if you used this string and the separators conformed to the rules for command lines, you could create a pseudo command line with SET_COMMAND_LINE@ and then use the FTN77 library command line processing functions to sort out the values. If the separators didn’t conform, you could always replace all the invalid characters with <space> in a preliminary pass. CMNARGS@ for instance will tell you how many arguments there are. There are also routines to get the ‘tokens’ off the command line in various ways.
However, you’ll never be able to determine if (say) 12345 is the integer value, or 12345.0
Eddie