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

ID 767251
Date 9/08/2022
Public

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

Document Table of Contents

Specify Default Pathnames and File Names

Intel® Fortran provides a number of ways of specifying all or part of a file specification (directory and file name). The following list uses the Linux* pathname /usr/proj/testdata as an example:

  • The FILE specifier in an OPEN statement typically specifies only a file name (such as testdata) or contains both a directory and file name (such as /usr/proj/testdata).

  • The DEFAULTFILE specifier in an OPEN statement typically specifies a pathname that contains only a directory (such as /usr/proj/) or both a directory and file name (such as /usr/proj/testdata).

  • If you used an implied OPEN (described in Assigning Files to Logical Units) or if the FILE specifier in an OPEN statement did not specify a file name, you can use an environment variable to specify a file name or a pathname that contains both a directory and file name.

Examples of Applying Default Pathnames and File Names

For example, for an implied OPEN of unit number 3, Intel Fortran will check the environment variable FORT3. If the environment variable FORT3 is set, its value is used. If it is not set, the system supplies the file name fort.3.

In the following table, assume the current directory is /usr/smith and the I/O uses unit 1, as in the statement READ (1,100).

OPEN FILE value

OPEN DEFAULTFILE value

FORT1 environment variable value

Resulting pathname

not specified

not specified

not specified

/usr/smith/fort.1

not specified

not specified

test.dat

/usr/smith/test.dat

not specified

not checked

/usr/tmp/t.dat

/usr/tmp/t.dat

not specified

/tmp

not specified

/tmp/fort.1

not specified

/tmp

testdata

/tmp/testdata

not specified

/usr

lib/testdata

/usr/lib/testdata

file.dat

/usr/group

not checked

/usr/group/file.dat

/tmp/file.dat

not checked

not checked

/tmp/file.dat

file.dat

not specified

not checked

/usr/smith/file.dat

When the resulting file pathname begins with a tilde character (~), C-shell-style pathname substitution is used (regardless of what shell is being used), such as a top-level directory (below the root). For additional information on tilde pathname substitution, see csh(1).

Rules for Applying Default Pathnames and File Names

Intel Fortran determines the file name and the directory path based on certain rules. It determines a file name string as follows:

  • If the FILE specifier is present, its value is used.

  • If the FILE specifier is not present, Intel Fortran examines the corresponding environment variable. If the corresponding environment variable is set, that value is used. If the corresponding environment variable is not set, a file name in the form fort.n is used.

Once Intel Fortran determines the resulting file name string, it determines the directory (which optionally precedes the file name) as follows:

  • If the resulting file name string contains an absolute pathname, it is used and the DEFAULTFILE specifier, environment variable, and current directory values are ignored.

  • If the resulting file name string does not contain an absolute pathname, Intel Fortran examines the DEFAULTFILE specifier and current directory value: If the corresponding environment variable is set and specifies an absolute pathname, that value is used. Otherwise, the DEFAULTFILE specifier value, if present, is used. If the DEFAULTFILE specifier is not present, Intel Fortran uses the current directory as an absolute pathname.