Hi,
It looks like if you do a read with advance='no' without a variable list on a file opened with access='stream', the advance specified gets applied to the following read as well. Consider this test program:
program advance_test implicit none integer :: unit = 10 integer :: i open(access='stream', action='write', form='formatted', file='testfile', unit=unit) do i = 1, 10 write(fmt='(i0)', unit=unit) i end do close(unit=unit) open(access='stream', action='read', form='formatted', file='testfile', unit=unit) read(fmt='(i1)', advance='no', unit=unit) read(fmt=*, unit=unit) i write(*, *) i read(fmt=*, unit=unit) i write(*, *) i read(fmt=*, unit=unit) i write(*, *) i close(unit=unit) end program advance_test
I would expect the first (advance='no') read to do nothing, the second read to get 1, the third to get 2, and so on. And indeed, using gfortran, this is what I get:
13:13 bjm900@raijin5 noadvance > gfortran file.f90 13:13 bjm900@raijin5 noadvance > ./a.out 1 2 3
Using ifort, however, I get this:
13:12 bjm900@raijin5 noadvance > ifort file.f90 13:13 bjm900@raijin5 noadvance > ./a.out 1 1 2
At a guess, the advance='no' with no variables is inadvertently setting some internal flag that's not being reset before the following read. In the case I'm investigating, this structure is used to reposition the file pointer in a formatted file, i.e.:
read(unit, "(I1)", pos=position, advance="no")
The version of ifort I'm using is
13:23 bjm900@raijin5 noadvance > ifort --version ifort (IFORT) 15.0.0 20140723 Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
but it is also like this for at least this earlier version
13:23 bjm900@raijin5 noadvance > ifort --version ifort (IFORT) 14.0.3 20140422 Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
Cheers,
Ben