8.118 FTELL — Current stream position

Description:

Retrieves the current position within an open file.

This intrinsic is provided in both subroutine and function forms; however, only one form can be used in any given program unit.

Standard:

GNU extension

Class:

Subroutine, function

Syntax:
CALL FTELL(UNIT, OFFSET)
OFFSET = FTELL(UNIT)
Arguments:
OFFSETShall of type INTEGER.
UNITShall of type INTEGER.
Return value:

In either syntax, OFFSET is set to the current offset of unit number UNIT, or to -1 if the unit is not currently open.

Example:
PROGRAM test_ftell
  INTEGER :: i
  OPEN(10, FILE="temp.dat")
  CALL ftell(10,i)
  WRITE(*,*) i
END PROGRAM
See also:

FSEEK — Low level file positioning subroutine