Statement Type:

This is an executable statement.

Statement Purpose:

The inquire statement is used to check on the status of different files.

Required Form:

inquire ( inquiry list)

Required Inquiry List Elements:

The inquiry list must contain one of the following:


This is followed either by a quoted string or character variable containing the name of the file, for which information is needed.



This is followed by an integer variable or constant specifying the unit number for which information is needed.

Optional Inquiry List Elements:

There are other specifies that can go along with the INQUIRE statement. Most have uses that are beyond what a beginning programer has need for. Listed below are three more specifiers that may be useful for the beginner. However if additional information is required about some of the other specifiers, please consult a manual on the Fortran Standard.


After this specifier goes a logical variable. The program will then assign a value of true to the variable if the file does indeed exist and a value of false if it doesn't.


The number that gets returned when this specifier is used is the record length of a file connected for direct access, or the maximum record length for a file connected as sequential access.


This returns the access type or the kind of file you are inquiring about. The three character strings that can be returned are SEQUENTIAL, DIRECT, or UNDEFINED. These character strings are then stored in a character variable that is placed after the equals sign.


To check on the existence of a file:
		inquire (file="",exist=log1)
This by itself won't help much as the program won't tell you anything if the file doesn't exist. So, do the following to find out:
		if (log1==.false.) then
		   Print *, 'File does not exist!'

Related Topics and Lectures

open statement

close statement

logical variables

relational operators

if statement

lecture twenty two

Up one level / Home

Written by Jason Wehr : and Maintained by John Mahaffy :