- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I am having a problem with end of file when reading a stream access file. iostat does not indicate the end of file under some conditions. My compiler version is Intel Fortran 11.1 update 4 (I think), build 080, running onMac OS X 10.5.8.
Make a test file of length 8193 bytes. The contents are irrelevant for this demo. Here is my program and results:
mac56:~/fortran/stream 2> ls -Tgo dat5
-rw-r--r-- 1 8193 Apr 28 23:36:53 2010 dat5
mac56:~/fortran/stream 3> file dat5
dat5: ASCII text
mac56:~/fortran/stream 4> cat stream-demo-1.f90
program test
integer buf(4096) ! default 32-bit integers
integer ios
open (10, file='dat5', access='stream', status='old')
read (10, iostat=ios) buf
write (*, '(a,i0)') 'iostat = ', ios
end program test
mac56:~/fortran/stream 5> ifort stream-demo-1.f90
mac56:~/fortran/stream 6> ./a.out
iostat = 0
mac56:~/fortran/stream 15> ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091130 Package ID: m_cprof_p_11.1.080
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
-------------------------
iostat should be -1 to indicate end of file, but instead it is zero which is incorrect.
The correct value of -1 can be obtained by (a) decreasing the buffer size, or (b) decreasing the data file size. For larger files, the relevant factor seems to be the amount of excess data requested in the read statement beyond end of file. The mistake is triggered when the excess is roughly 8K to 16K or more. An array size of at least 16K seems to be required. I did not fully investigate the size relationships.
Is this a compiler bug, or am I doing something wrong?
--Dave A.
링크가 복사됨
4 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Update. This problem still occurs in ifort update 7, package ID =m_cprof_p_11.1.089, running on Mac OS 10.6.
I did some additional testing. In the test case above, end of file is not correctly reported for various input files of lengths 8193 through 16383 bytes. The test program as shown tries to read 16384 bytes.
--Dave
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thank you for the convenient reproducer, Dave.
I verified the incorrect iostat is returned as described. I reported this to the Fortran Library Developers (see internal tracking id below) and willupdate this thread when I learn more.
(Internal tracking id: DPD200160797)
(Resolution Update on 03/03/2011): This defect is fixed in the Intel Fortran Composer XE 2011 Update1 (2011.1.122 - Mac OS)
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
This defect is fixed in the Intel Fortran Composer XE 2011 Update1 (2011.1.122 - Mac OS)
