title: Is there a way to compare the format in which a line of a text file was written in Fortran?
body: <p>I'm developing a Fortran program that must obtain some data from a text file and generate another text file using specific data from the first one.
  The input file have many lines written in several specific formats which I know of. Although I know the formats, the lines in this file are generated in a "random way".</p>
  
  <p>It would be much easier to generate the output file if I could compare the format in which each line was written, then I would know exactly what data I can get from that line of the input file to use it in the output file.</p>
  
  <p>What I need is something like, for example, knowing that the format of the line read and stored in the <code>LINHA</code> variable is described in the <code>FORMATO</code> variable, do something like:
      </p>
  
  <pre><code>IF (FORMATO = '(1X, 15,3F8.1,2 (5A, 1X))') THEN
    READ (LINHA, '(6X, F8.1)') my_variable
  END IF
  </code></pre>
  
  <p>Because there might be another format such as</p>
  
  <pre><code>'(6A, 2F8.1, F8.6,2 (6A))'
  </code></pre>
  
  <p>in which, if I use the same <code>READ</code> statement, I will read an <code>F8.1</code> variable in <code>my_variable</code>, however this value is not the correct one.</p>