g77, g95, Absoft 9.2, etc.. position the text file correctly, but gfortran is off by one line -
[dranta:~/tests/gfortran-D] dir% gfortran -fno-automatic -std=legacy -o aRead01 aRead01.f [dranta:~/tests/gfortran-D] dir% aRead01 < aRead01.in 1 one 2 Two 3 Three read =Two [dranta:~/tests/gfortran-D] dir% g77 -o aRead01 aRead01.f [dranta:~/tests/gfortran-D] dir% aRead01 < aRead01.in 1 one 2 Two 3 Three read =Three [dranta:~/tests/gfortran-D] dir% cat aRead01.f program main character*10 a ncards=2 read(5,1000)a read(5,1000)a call inlist(ncards) read(5,1000)a write(6,2000)a stop 1000 format(a10) 2000 format('read =',a10) end subroutine inlist(ncards) character*4 data(20) input=5 c if (ncards.eq.0) go to 20 do 15 i=1,ncards backspace input 15 continue c 20 continue kard = 0 30 read(5,1000,end=60) data 40 kard=kard + 1 50 write (6,2020) kard,data go to 30 60 continue kard=kard - ncards + 1 do 70 i=1,kard backspace input 70 continue c return c 1000 format (20a4) 2020 format (8x,i15,8x,20a4) c end [dranta:~/tests/gfortran-D] dir% cat aRead01.in one Two Three [dranta:~/tests/gfortran-D] dir% gfortran --v Using built-in specs. Target: powerpc-apple-darwin8.9.0 Configured with: ../gcc/configure --enable-checking --disable-multilib --prefix=/usr/local/gfortran --enable-languages=c,fortran Thread model: posix gcc version 4.3.0 20070604 (experimental) -- Summary: gfortran - incorrectly position text file after backspace Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dir at lanl dot gov GCC host triplet: powerpc-apple-darwin8.9.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32235