title: fortran read binary files
body: <p>I am a newbie in fortran.</p>
  
  <p>I made a program using the Microsoft Developer Studio 4.0 to create a binary file.
  I open it as follows:</p>
  
  <pre><code>      OPEN(2,FILE='output_bin.bin',FORM='UNFORMATTED')
  </code></pre>
  
  <p>I write in it an array <code>INTEGER*2 IHIST(30)</code>, right now filled with numbers from 0 to 29. The writing is done with:</p>
  
  <pre><code>      DO 351 J=0,29
        WRITE(2) IHIST(J)
  351   CONTINUE
  </code></pre>
  
  <p>In Windows I can read the binary file produced. I can recover the array.</p>
  
  <p>Then I want to read it in Ubuntu. Here, is where I get my problem:
  I get <code>Fortran runtime error: End of file</code>, when I do the following:</p>
  
  <pre><code>     INTEGER*2 RBIN(30)
       WRITE(*,*)'Extracting data from binary file ', filename
       OPEN(3,FILE=filename,FORM='UNFORMATTED',ACTION='READ'
   +   ,STATUS='OLD')
  
       DO 17 I=0,29
       READ(3) RBIN(I)
  17   CONTINUE
  </code></pre>
  
  <p>Can someone explain to me how I can read a sequential, unformatted binary files. What am I doing wrong? I thought the starting position for the next reading would be the end of the later. </p>
  
  <p>I am using GNU Fortran (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 to compile in Ubuntu 12.04.</p>