title: How to use command line arguments in Fortran?
body: <p>GCC version 4.6</p>
  
  <p><strong>The Problem:</strong> To find a way to feed in parameters to the executable, say <code>a.out</code>, from the command line - more specifically feed in an array of double precision numbers.</p>
  
  <p><strong>Attempt:</strong> Using the <code>READ(*,*)</code> command, which is older in the standard:
  Program <code>test.f</code> -  </p>
  
  <pre><code>PROGRAM MAIN  
       REAL(8)    :: A,B  
       READ(*,*) A,B
       PRINT*, A+B, COMMAND_ARGUMENT_COUNT()
  END PROGRAM MAIN
  </code></pre>
  
  <p>The execution -  </p>
  
  <pre><code>$ gfortran test.f
  $ ./a.out 3.D0 1.D0
  </code></pre>
  
  <p>This did not work. On a bit of soul-searching, found that  </p>
  
  <pre><code>$./a.out
  3.d0,1.d0
     4.0000000000000000                0
  </code></pre>
  
  <p>does work, but the second line is an input prompt, and the objective of getting this done in one-line is not achieved. Also the <code>COMMAND_ARGUMENT_COUNT()</code> shows that the numbers fed into the input prompt don't really count as 'command line arguments', unlike PERL. </p>