1
Hello, I need to make a program that reads from an input file that has lines of text written in specific formats and processes the read information in order to create an output file with some data of interest. I know all the formats used to write the input file (they are described in a format file), but the data itself is written in it by another program, in a "random" way. Some lines are easy to identify (table end headers and markings, etc.) others are not. It would be much easier if somehow FORTRAN was able to identify the format in which each line read from the input file was written (e.g.: '(1X,I5,3F8.1,2(5A,1X))'). So I could just compare the format of the line with one of the formats of the list I have and extract almost directly the necessary data, for example knowing that the format of the line read and stored in the variable LINE is described in the variable FORMAT, could do something like:
IF (FORMATO='(1X,I5,3F8.1,2(5A,1X))') THEN
READ(LINHA,'(6X,F8.1)') minha_variavel
END IF
Because there may be another read line format such as:
'(6A, 2F8.1, F8.6,2 (6A))'
That if I use the same READ command above, I will have a F8.1 variable written in "variable", but this will not be the value I wanted.
Does anyone know if FORTRAN has a function that does something similar (get the format in which a line of text file was written)? If yes, what is the function?
More details on the Stack conversation in English: https://stackoverflow.com/questions/48563865/is-there-a-way-to-compare-the-format-in-which-a-line-of-a-text-file-was-written/48572692#48572692
– Bruno Fonseca