From: lumbot on
I am getting the following error:
Fortran runtime error: I/O past end of record on unformatted file

The codes are:
character(100)fin
real(4)a
fin='xx.bin'

open(unit=2,file=fin,status='old',ACCESS='SEQUENTIAL',FORM='UNFORMATTED')
read(2)a
write(*,*)a
close(2)

The file exists
>l xx.bin
-rw-r--r-- 1 -- staff 19353628 May 5 14:01 ./xx.bin

Any clue

From: Arjen Markus on
On 7 mei, 08:15, lumbot <lum...(a)gmail.com> wrote:
> I am getting the following error:
> Fortran runtime error: I/O past end of record on unformatted file
>
> The codes are:
> character(100)fin
> real(4)a
>         fin='xx.bin'
>
> open(unit=2,file=fin,status='old',ACCESS='SEQUENTIAL',FORM='UNFORMATTED')
> read(2)a
> write(*,*)a
> close(2)
>
> The file exists>l xx.bin
>
> -rw-r--r--  1 --  staff  19353628 May  5 14:01 ./xx.bin
>
> Any clue

The first record in the file (assuming the file is properly
structured
as an unformatted file) could be shorter than the number of bytes that
make up a single real.

While unformatted files can have any structure, depending on the
compiler
used for the program that created the file, most nowadays use the
following scheme:
- Each record starts with 4 bytes indicating the number of bytes of
data
- The same 4 bytes appear after the data bytes

Could the file possible be a _binary_ file? For instance it is written
by a C program, so it is not structured with records and record
markers?
In that case, try ACCESS='STREAM' (a sufficiently modern version of
gfortran supports that F2003 feature)

Regards,

Arjen
From: Tobias Burnus on
On 05/07/2010 08:15 AM, lumbot wrote:
> I am getting the following error:
> Fortran runtime error: I/O past end of record on unformatted file

You haven't told us the version of the compiler you are using - nor how
you have created the file you are reading (if you used a different
compiler/compiler version to create it, tell us which).

Tobias
From: glen herrmannsfeldt on
lumbot <lumbot(a)gmail.com> wrote:
> I am getting the following error:
> Fortran runtime error: I/O past end of record on unformatted file
(snip)

> The file exists
>>l xx.bin
> -rw-r--r-- 1 -- staff 19353628 May 5 14:01 ./xx.bin

Try:

od -x xx.bin | head

-- glen
From: feenberg on
On May 7, 2:15 am, lumbot <lum...(a)gmail.com> wrote:
> I am getting the following error:
> Fortran runtime error: I/O past end of record on unformatted file
>
> The codes are:
> character(100)fin
> real(4)a
>         fin='xx.bin'
>
> open(unit=2,file=fin,status='old',ACCESS='SEQUENTIAL',FORM='UNFORMATTED')
> read(2)a
> write(*,*)a
> close(2)
>
> The file exists>l xx.bin
>
> -rw-r--r--  1 --  staff  19353628 May  5 14:01 ./xx.bin
>
> Any clue

Unless the file was written by a Fortran program from the same
compiler, "unformatted" will not be able to read the file.
Fortran "unformatted" is not a way to read generic binary
data, but only reads record oriented files with a specific
non-portable structure. To read files from another source
a direct access file with a record length of 1 is possible.

Daniel Feenberg