2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. index:: FSEEK, file operation, seek, file operation, position
10 FSEEK --- Low level file positioning subroutine
11 ***********************************************
13 .. function:: FSEEK(UNIT, OFFSET, WHENCE, STATUS)
15 Moves :samp:`{UNIT}` to the specified :samp:`{OFFSET}`. If :samp:`{WHENCE}`
16 is set to 0, the :samp:`{OFFSET}` is taken as an absolute value ``SEEK_SET``,
17 if set to 1, :samp:`{OFFSET}` is taken to be relative to the current position
18 ``SEEK_CUR``, and if set to 2 relative to the end of the file ``SEEK_END``.
19 On error, :samp:`{STATUS}` is set to a nonzero value. If :samp:`{STATUS}` the seek
23 Shall be a scalar of type ``INTEGER``.
26 Shall be a scalar of type ``INTEGER``.
29 Shall be a scalar of type ``INTEGER``.
30 Its value shall be either 0, 1 or 2.
33 (Optional) shall be a scalar of type
43 .. code-block:: fortran
45 CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])
48 .. code-block:: fortran
51 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
52 INTEGER :: fd, offset, ierr
58 OPEN(UNIT=fd, FILE="fseek.test")
59 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
60 print *, FTELL(fd), ierr
62 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
63 print *, FTELL(fd), ierr
65 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
66 print *, FTELL(fd), ierr