Coding to detect end of file or read error just won't work, and I can't see a work around. Coding to differentiate between end of file and error condition doesn't work, it all acts like an error.
I have a test code, included below, which creates a simple unformatted file with two records. The first record contains a single integer, and the second record contains three integers. Once this test file is created, it is re-opened and read, attempting a read of three integers, rather than 1 integer, on the first record. This should create a error condition, and it should write out the stop error message stating so. Instead, it writes out the message for the END=100 label. Using IOSTAT doesn't differentiate between end= and err= conditions either, it seems to return 0 for no problems, and -1 for anything else... Code has been run on opteron, centrino, and itanium systems, all running linux (fedora core 8 on the first two, last Suse) !---Relevant Code follows---- integer ni, nj, nk ni = 1 nj = 1 nk = 1 open(1,file='test.data',form='unformatted') write(1) ni write(1) ni,nj,nk close(1) ni = 0 nj = 0 nk = 0 open(1,file='test.data',form='unformatted') read(1,err=10,end=100)ni,nj,nk write(*,*)ni, nj, nk stop 'No End, No ERror' 10 continue write(*,*)ni, nj, nk stop 'ERror' 100 continue write(*,*)ni, nj, nk stop 'End' end !-------------------End of Code ---------------- -- Summary: iostat and/or end= and Err= don't work in read statements, unformatted reads Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: michael dot e dot olsen at nasa dot gov http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36942