FSEEK — Low level file positioning subroutine#
-
FSEEK(UNIT, OFFSET, WHENCE, STATUS)#
Moves
UNIT
to the specifiedOFFSET
. IfWHENCE
is set to 0, theOFFSET
is taken as an absolute valueSEEK_SET
, if set to 1,OFFSET
is taken to be relative to the current positionSEEK_CUR
, and if set to 2 relative to the end of the fileSEEK_END
. On error,STATUS
is set to a nonzero value. IfSTATUS
the seek fails silently.- Parameters
UNIT – Shall be a scalar of type
INTEGER
.OFFSET – Shall be a scalar of type
INTEGER
.WHENCE – Shall be a scalar of type
INTEGER
. Its value shall be either 0, 1 or 2.STATUS – (Optional) shall be a scalar of type
INTEGER(4)
.
- Standard:
GNU extension
- Class:
Subroutine
- Syntax:
CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])
- Example:
PROGRAM test_fseek INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2 INTEGER :: fd, offset, ierr ierr = 0 offset = 5 fd = 10 OPEN(UNIT=fd, FILE="fseek.test") CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET print *, FTELL(fd), ierr CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end print *, FTELL(fd), ierr CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning print *, FTELL(fd), ierr CLOSE(UNIT=fd) END PROGRAM
- See also: