Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

FSEEK

Portability Function: Repositions a file specified by a Fortran external unit.

Module

USE IFPORT

result = FSEEK (lunit,offset,from)

lunit

(Input) INTEGER(4). External unit number of a file.

offset

(Input) INTEGER(4) or INTEGER(8). Offset in bytes, relative to from, that is to be the new location of the file marker.

from

(Input) INTEGER(4). A position in the file. It must be one of the following:

Value

Variable

Position

0

SEEK_SET

Positions the file relative to the beginning of the file.

1

SEEK_CUR

Positions the file relative to the current position.

2

SEEK_END

Positions the file relative to the end of the file.

Results

The result type is INTEGER(4). The result is zero if the repositioning was successful; otherwise, an error code, such as:

EINVAL: The specified unit is invalid because either the unit is not already open, an invalid unit number was specified, or the from parameter is invalid.

The file specified in lunit must be open.

Example

USE IFPORT
integer(4) istat, offset, ipos
character ichar
OPEN (unit=1,file='datfile.dat')
offset = 5
ipos = 0
istat=fseek(1,offset,ipos)
if (.NOT. stat) then
  istat=fgetc(1,ichar)
  print *, 'data is ',ichar
end if