I am a newbie in fortran.
I made a program using the Microsoft Developer Studio 4.0 to create a binary file. I open it as follows:
OPEN(2,FILE='output_bin.bin',FORM='UNFORMATTED')
I write in it an array INTEGER*2 IHIST(30), right now filled with numbers from 0 to 29. The writing is done with:
DO 351 J=0,29
WRITE(2) IHIST(J)
351 CONTINUE
In Windows I can read the binary file produced. I can recover the array.
Then I want to read it in Ubuntu. Here, is where I get my problem:
I get Fortran runtime error: End of file, when I do the following:
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
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.
I am using GNU Fortran (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 to compile in Ubuntu 12.04.