Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

fortran sequential access

Namgu_Y_
Beginner
2,490 Views

I uses the intel compiler v18.

I'm faced with a problem reading data of unformatted sequential access type.

It seems that intel compiler regards separated records as a one record.

for instance, I attached two sample files.

one of them is a "write.f90" which is a file to write a sample data through unformatted sequential access.

and the other is a "read.f90" that is a file to read the data and write those on screen.

I tried to read separated two records as a one record once. But, this try may make a error message.

Actually, "gnu fortran compiler" produces following error message.

At line 10 of file read.f90 (unit = 11, file = './output.bin')

Fortran runtime error: I/O past end of record on unformatted file

And, other compiler "pgi compiler" also produces following message.

PGFIO-F-219/unformatted read/unit=11/attempt to read/write past end of record.

File name = ./output.bin    unformatted, sequential access   record = 1

In source file read.f90, at line number 10

similarly, "intel compiler" of other version produces error message.

forrtl: severe (67): input statement requires too much data, unit 11, file /home/./output.bin

Image              PC                Routine            Line        Source             

a.out              00000000004674FE  Unknown               Unknown  Unknown

a.out              0000000000465F96  Unknown               Unknown  Unknown

a.out              0000000000440B52  Unknown               Unknown  Unknown

a.out              000000000042BE5B  Unknown               Unknown  Unknown

a.out              000000000042B3C2  Unknown               Unknown  Unknown

a.out              000000000040EE92  Unknown               Unknown  Unknown

a.out              000000000040CA59  Unknown               Unknown  Unknown

a.out              0000000000402B86  Unknown               Unknown  Unknown

a.out              0000000000402A7C  Unknown               Unknown  Unknown

libc.so.6          0000003AADC1ED1D  Unknown               Unknown  Unknown

a.out              0000000000402979  Unknown               Unknown  Unknown

However, intel compiler v18 does not produce "error message" and print the values. 

   1.00000000000000        1.00000000000000        1.00000000000000     

   1.00000000000000        1.00000000000000        1.00000000000000     

   1.00000000000000        1.00000000000000        1.00000000000000     

   1.00000000000000        2.00000000000000        2.00000000000000     

   2.00000000000000        2.00000000000000        2.00000000000000     

   2.00000000000000        2.00000000000000        2.00000000000000     

   2.00000000000000        2.00000000000000

 

I think "that do not print error message" is a problem.    

Because, i usually access data through unformatted sequential access, this error makes me very confused. 

What should i do? Please, help me.

0 Kudos
1 Solution
mecej4
Honored Contributor III
2,490 Views

I receive "forrtl: severe (67): input statement requires too much data, unit 11,.."  using IFort 17.0.6 on Windows-10. I see the bug (i.e., program runs with no I/O error despite reading beyond end of record) with IFort 18.0.2 on Windows-10; the bug is not present in 18.0.3 on Windows.

If the bug is not present in 18.0.3 on Linux/MacOS, your simplest way out may be to update to 18.0.3 from your current 18.0.2.

 

View solution in original post

0 Kudos
3 Replies
Steve_Lionel
Honored Contributor III
2,490 Views

I can't reproduce the lack of error using the 18.0.3 compiler. An error is appropriate as you wrote 10 elements in the first record but tried to read 20. If you want to do this, add 'access="stream"' to the OPEN statements. This does away with records entirely and you just get the data.

Of course, if your intention is to read this data on a big-endian system you'll also need access="stream" on the reading program there.

0 Kudos
Namgu_Y_
Beginner
2,490 Views

Steve Lionel (Ret.) wrote:

I can't reproduce the lack of error using the 18.0.3 compiler. An error is appropriate as you wrote 10 elements in the first record but tried to read 20. If you want to do this, add 'access="stream"' to the OPEN statements. This does away with records entirely and you just get the data.

Of course, if your intention is to read this data on a big-endian system you'll also need access="stream" on the reading program there.

I am using the 18.0.2 compiler.

Can I understand that despite explicitly declaring "sequential access" the compiler does not produce error message ?

then, Does 18.0.2 compiler have a bug ?

0 Kudos
mecej4
Honored Contributor III
2,491 Views

I receive "forrtl: severe (67): input statement requires too much data, unit 11,.."  using IFort 17.0.6 on Windows-10. I see the bug (i.e., program runs with no I/O error despite reading beyond end of record) with IFort 18.0.2 on Windows-10; the bug is not present in 18.0.3 on Windows.

If the bug is not present in 18.0.3 on Linux/MacOS, your simplest way out may be to update to 18.0.3 from your current 18.0.2.

 

0 Kudos
Reply