
The following example ( GetFilNam.f) shows one way to construct an absolute path file name from a typed-in name. (See man page entries for getarg(3F) and getenv(3F) for details these and other useful library routines are also described in the Fortran Library Reference). Library routines can be used to bring command-line arguments and environment variables into the program as character variables for use as file names in OPEN statements. Also, the specifier may be a character constant, variable, or character expression. The FILE= specifier on an OPEN statement may specify a simple file name ( FILE='myfile.out') or a file name preceded by an absolute or relative directory path ( FILE='./Amber/Qproj/myfile.out').
#Code blocks fortran manual#
See the Sun FORTRAN 77 Language Reference Manual for a full discussion of the OPEN statement.

This file can be pre-existing or created by the program. The OPEN statement's FILE= specifier establishes the association of a logical unit to a named, physical file at runtime. Also, certain "preconnected " units are automatically associated with specific files at the start of program execution. The asterisk stands for standard input file when it appears in a READ statement it stands for standard output file when it appears in a WRITE or PRINT statement.Ī Fortran logical unit can be associated with a specific, named file through the OPEN statement. The character * can appear as a logical unit identifier. Logical units are identified in an I/O statement by a logical unit number, a nonnegative integer from 0 to the maximum 4-byte integer value (2,147,483,647).


Accessing Files From Within Fortran Programsĭata is transferred between the program and devices or files through a Fortran logical unit. This chapter discusses the input/output features provided by Sun Fortran compilers.
