Fortran End of File/Backspace command

Fortran End of File/Backspace command

I am getting a Fortran runtime error:End of file at the second line of this subroutine:

subroutine errstp(kunit)

      backspace kunit
      read(kunit, '(a)') zline(1:nline)
      call cmerpr('unexpected end of file')
      call cmerpr('last input data line:')
      call cmerpr(zline(1:nline))
      call finish(yes)

kunit is 1 in this case, and the purpose of this subroutine is to echo the last inout line and then close up shop.  Does my error have something to do with the backspace command or is this something else altogether?


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

We'd need to see more - ideally a complete program that could be run. We don't know where the file position is before the backspace. If it is "after the end-of-file marker - that is, an EOF condition has already been raised, one BACKSPACE will position the file just before the EOF marker. (The marker in this context is virtual - there is no physical representation, but this is how the standard describes it.) If you want to reread the last record after an EOF condition has been raised, you need two BACKSPACEs.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today