title: How to read numeric data from a string in Fortran
body: <p>I have a character string array in Fortran as ' results: CI- Energies ---  th= 89  ph=120'. How do I extract the characters '120' from the string and store into a real variable?</p>
  <p>The string is written in the file 'input.DAT'. I have written the Fortran code as:</p>
  <pre><code>implicit real*8(a-h,o-z)
  character(39)  line
  open(1,file='input.DAT',status='old')
  read(1,'(A)') line,phi
  write(*,'(A)') line
  write(*,*)phi
  end
  </code></pre>
  <p>Upon execution it shows:</p>
  <pre><code>At line 5 of file string.f (unit = 1, file = 'input.dat')
  Fortran runtime error: End of file
  </code></pre>
  <p>I have given '39' as the dimension of the character array as there are 39 characters including 'spaces' in the string upto '120'.</p>