Files
2024-02-19 00:21:47 -05:00

502 lines
22 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>fort77</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="fort77"></a> <a name="tag_04_57"></a><!-- fort77 -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_04_57_01"></a>NAME</h4>
<blockquote>fort77 - FORTRAN compiler (<b>FORTRAN</b>)</blockquote>
<h4><a name="tag_04_57_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<div class="box"><code><tt><sup>[<a href="javascript:open_code('FD')">FD</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> fort77</tt> <b>[</b><tt>-c</tt><b>][</b><tt>-g</tt><b>][</b><tt>-L</tt>
<i>directory</i><b>]</b><tt>...</tt> <b>[</b><tt>-O</tt> <i>optlevel</i><b>][</b><tt>-o</tt>
<i>outfile</i><b>][</b><tt>-s</tt><b>][</b><tt>-w</tt><b>]<br>
</b> <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt> <b></b><i>operand</i><tt>... <img src="../images/opt-end.gif" alt="[Option End]"
border="0"></tt></code></div>
</blockquote>
<h4><a name="tag_04_57_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>fort77</i> utility is the interface to the FORTRAN compilation system; it shall accept the full FORTRAN-77 language
defined by the ANSI&nbsp;X3.9-1978 standard. The system conceptually consists of a compiler and link editor. The files referenced
by <i>operand</i>s are compiled and linked to produce an executable file. It is unspecified whether the linking occurs entirely
within the operation of <i>fort77</i>; some implementations may produce objects that are not fully resolved until the file is
executed.</p>
<p>If the <b>-c</b> option is present, for all pathname operands of the form <i>file</i> <b>.f</b>, the files:</p>
<pre>
<tt>$(basename</tt> <i>pathname</i><tt>.f).o
</tt>
</pre>
<p>shall be created or overwritten as the result of successful compilation. If the <b>-c</b> option is not specified, it is
unspecified whether such <b>.o</b> files are created or deleted for the <i>file</i> <b>.f</b> operands.</p>
<p>If there are no options that prevent link editing (such as <b>-c</b>) and all operands compile and link without error, the
resulting executable file shall be written into the file named by the <b>-o</b> option (if present) or to the file <b>a.out</b>.
The executable file shall be created as specified in the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, except that
the file permissions shall be set to:</p>
<blockquote>
<pre>
S_IRWXO | S_IRWXG | S_IRWXU
</pre>
</blockquote>
<p>and that the bits specified by the <i>umask</i> of the process shall be cleared.</p>
</blockquote>
<h4><a name="tag_04_57_04"></a>OPTIONS</h4>
<blockquote>
<p>The <i>fort77</i> utility shall conform to the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>, except that:</p>
<ul>
<li>
<p>The <b>-l</b> <i>library</i> operands have the format of options, but their position within a list of operands affects the order
in which libraries are searched.</p>
</li>
<li>
<p>The order of specifying the multiple <b>-L</b> options is significant.</p>
</li>
<li>
<p>Conforming applications shall specify each option separately; that is, grouping option letters (for example, <b>-cg</b>) need
not be recognized by all implementations.</p>
</li>
</ul>
<p>The following options shall be supported:</p>
<dl compact>
<dt><b>-c</b></dt>
<dd>Suppress the link-edit phase of the compilation, and do not remove any object files that are produced.</dd>
<dt><b>-g</b></dt>
<dd>Produce symbolic information in the object or executable files; the nature of this information is unspecified, and may be
modified by implementation-defined interactions with other options.</dd>
<dt><b>-s</b></dt>
<dd>Produce object or executable files, or both, from which symbolic and other information not required for proper execution using
the <i>exec</i> family of functions defined in the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001 has been removed
(stripped). If both <b>-g</b> and <b>-s</b> options are present, the action taken is unspecified.</dd>
<dt><b>-o&nbsp;</b> <i>outfile</i></dt>
<dd>Use the pathname <i>outfile</i>, instead of the default <b>a.out</b>, for the executable file produced. If the <b>-o</b> option
is present with <b>-c</b>, the result is unspecified.</dd>
<dt><b>-L&nbsp;</b> <i>directory</i></dt>
<dd>Change the algorithm of searching for the libraries named in <b>-l</b> operands to look in the directory named by the
<i>directory</i> pathname before looking in the usual places. Directories named in <b>-L</b> options shall be searched in the
specified order. At least ten instances of this option shall be supported in a single <i>fort77</i> command invocation. If a
directory specified by a <b>-L</b> option contains a file named <b>libf.a</b>, the results are unspecified.</dd>
<dt><b>-O&nbsp;</b> <i>optlevel</i></dt>
<dd>Specify the level of code optimization. If the <i>optlevel</i> option-argument is the digit <tt>'0'</tt> , all special code
optimizations shall be disabled. If it is the digit <tt>'1'</tt> , the nature of the optimization is unspecified. If the <b>-O</b>
option is omitted, the nature of the system's default optimization is unspecified. It is unspecified whether code generated in the
presence of the <b>-O</b> 0 option is the same as that generated when <b>-O</b> is omitted. Other <i>optlevel</i> values may be
supported.</dd>
<dt><b>-w</b></dt>
<dd>Suppress warnings.</dd>
</dl>
<p>Multiple instances of <b>-L</b> options can be specified.</p>
</blockquote>
<h4><a name="tag_04_57_05"></a>OPERANDS</h4>
<blockquote>
<p>An <i>operand</i> is either in the form of a pathname or the form <b>-l</b> <i>library</i>. At least one operand of the pathname
form shall be specified. The following operands shall be supported:</p>
<dl compact>
<dt><i>file.</i><b>f</b></dt>
<dd>The pathname of a FORTRAN source file to be compiled and optionally passed to the link editor. The filename operand shall be of
this form if the <b>-c</b> option is used.</dd>
<dt><i>file.</i><b>a</b></dt>
<dd>A library of object files typically produced by <a href="../utilities/ar.html"><i>ar</i></a>, and passed directly to the link
editor. Implementations may recognize implementation-defined suffixes other than <b>.a</b> as denoting object file libraries.</dd>
<dt><i>file.</i><b>o</b></dt>
<dd>An object file produced by <i>fort77</i> <b>-c</b> and passed directly to the link editor. Implementations may recognize
implementation-defined suffixes other than <b>.o</b> as denoting object files.</dd>
</dl>
<p>The processing of other files is implementation-defined.</p>
<dl compact>
<dt><b>-l&nbsp;</b> <i>library</i></dt>
<dd>(The letter ell.) Search the library named:
<pre>
<tt>lib</tt><i>library</i><tt>.a
</tt>
</pre>
<p>A library is searched when its name is encountered, so the placement of a <b>-l</b> operand is significant. Several standard
libraries can be specified in this manner, as described in the EXTENDED DESCRIPTION section. Implementations may recognize
implementation-defined suffixes other than <b>.a</b> as denoting libraries.</p>
</dd>
</dl>
</blockquote>
<h4><a name="tag_04_57_06"></a>STDIN</h4>
<blockquote>
<p>Not used.</p>
</blockquote>
<h4><a name="tag_04_57_07"></a>INPUT FILES</h4>
<blockquote>
<p>The input file shall be one of the following: a text file containing FORTRAN source code; an object file in the format produced
by <i>fort77</i> <b>-c</b>; or a library of object files, in the format produced by archiving zero or more object files, using <a
href="../utilities/ar.html"><i>ar</i></a>. Implementations may supply additional utilities that produce files in these formats.
Additional input files are implementation-defined.</p>
<p>A &lt;tab&gt; encountered within the first six characters on a line of source code shall cause the compiler to interpret the
following character as if it were the seventh character on the line (that is, in column 7).</p>
</blockquote>
<h4><a name="tag_04_57_08"></a>ENVIRONMENT VARIABLES</h4>
<blockquote>
<p>The following environment variables shall affect the execution of <i>fort77</i>:</p>
<dl compact>
<dt><i>LANG</i></dt>
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
<dt><i>LC_ALL</i></dt>
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
<dt><i>LC_CTYPE</i></dt>
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
opposed to multi-byte characters in arguments and input files).</dd>
<dt><i>LC_MESSAGES</i></dt>
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
error.</dd>
<dt><i>NLSPATH</i></dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"></dd>
<dt><i>TMPDIR</i></dt>
<dd>Determine the pathname that should override the default directory for temporary files, if any.</dd>
</dl>
</blockquote>
<h4><a name="tag_04_57_09"></a>ASYNCHRONOUS EVENTS</h4>
<blockquote>
<p>Default.</p>
</blockquote>
<h4><a name="tag_04_57_10"></a>STDOUT</h4>
<blockquote>
<p>Not used.</p>
</blockquote>
<h4><a name="tag_04_57_11"></a>STDERR</h4>
<blockquote>
<p>The standard error shall be used only for diagnostic messages. If more than one <i>file</i> operand ending in <b>.f</b> (or
possibly other unspecified suffixes) is given, for each such file:</p>
<pre>
<tt>"%s:\n", &lt;</tt><i>file</i><tt>&gt;
</tt>
</pre>
<p>may be written to allow identification of the diagnostic message with the appropriate input file.</p>
<p>This utility may produce warning messages about certain conditions that do not warrant returning an error (non-zero) exit
value.</p>
</blockquote>
<h4><a name="tag_04_57_12"></a>OUTPUT FILES</h4>
<blockquote>
<p>Object files, listing files, and executable files shall be produced in unspecified formats.</p>
</blockquote>
<h4><a name="tag_04_57_13"></a>EXTENDED DESCRIPTION</h4>
<blockquote>
<h5><a name="tag_04_57_13_01"></a>Standard Libraries</h5>
<p>The <i>fort77</i> utility shall recognize the following <b>-l</b> operand for the standard library:</p>
<dl compact>
<dt><b>-l&nbsp;f</b></dt>
<dd>This library contains all functions referenced in the ANSI&nbsp;X3.9-1978 standard. This operand shall not be required to be
present to cause a search of this library.</dd>
</dl>
<p>In the absence of options that inhibit invocation of the link editor, such as <b>-c</b>, the <i>fort77</i> utility shall cause
the equivalent of a <b>-l&nbsp;f</b> operand to be passed to the link editor as the last <b>-l</b> operand, causing it to be
searched after all other object files and libraries are loaded.</p>
<p>It is unspecified whether the library <b>libf.a</b> exists as a regular file. The implementation may accept as <b>-l</b>
operands names of objects that do not exist as regular files.</p>
<h5><a name="tag_04_57_13_02"></a>External Symbols</h5>
<p>The FORTRAN compiler and link editor shall support the significance of external symbols up to a length of at least 31 bytes;
case folding is permitted. The action taken upon encountering symbols exceeding the implementation-defined maximum symbol length is
unspecified.</p>
<p>The compiler and link editor shall support a minimum of 511 external symbols per source or object file, and a minimum of 4095
external symbols total. A diagnostic message is written to standard output if the implementation-defined limit is exceeded; other
actions are unspecified.</p>
</blockquote>
<h4><a name="tag_04_57_14"></a>EXIT STATUS</h4>
<blockquote>
<p>The following exit values shall be returned:</p>
<dl compact>
<dt>&nbsp;0</dt>
<dd>Successful compilation or link edit.</dd>
<dt>&gt;0</dt>
<dd>An error occurred.</dd>
</dl>
</blockquote>
<h4><a name="tag_04_57_15"></a>CONSEQUENCES OF ERRORS</h4>
<blockquote>
<p>When <i>fort77</i> encounters a compilation error, it shall write a diagnostic to standard error and continue to compile other
source code operands. It shall return a non-zero exit status, but it is implementation-defined whether an object module is created.
If the link edit is unsuccessful, a diagnostic message shall be written to standard error, and <i>fort77</i> shall exit with a
non-zero status.</p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_04_57_16"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_57_17"></a>EXAMPLES</h4>
<blockquote>
<p>The following usage example compiles <b>xyz.f</b> and creates the executable file <b>foo</b>:</p>
<pre>
<tt>fort77 -o foo xyz.f
</tt>
</pre>
<p>The following example compiles <b>xyz.f</b> and creates the object file <b>xyz.o</b>:</p>
<pre>
<tt>fort77 -c xyz.f
</tt>
</pre>
<p>The following example compiles <b>xyz.f</b> and creates the executable file <b>a.out</b>:</p>
<pre>
<tt>fort77 xyz.f
</tt>
</pre>
<p>The following example compiles <b>xyz.f</b>, links it with <b>b.o</b>, and creates the executable <b>a.out</b>:</p>
<pre>
<tt>fort77 xyz.f b.o
</tt>
</pre>
</blockquote>
<h4><a name="tag_04_57_18"></a>RATIONALE</h4>
<blockquote>
<p>The name of this utility was chosen as <i>fort77</i> to parallel the renaming of the C compiler. The name <i>f77</i> was not
chosen to avoid problems with historical implementations. The ANSI&nbsp;X3.9-1978 standard was selected as a normative reference
because the ISO/IEC version of FORTRAN-77 has been superseded by the ISO/IEC&nbsp;1539:1990 standard (Fortran-90).</p>
<p>The file inclusion and symbol definition <b>#define</b> mechanisms used by the <a href="../utilities/c99.html"><i>c99</i></a>
utility were not included in this volume of IEEE&nbsp;Std&nbsp;1003.1-2001-even though they are commonly implemented-since there is
no requirement that the FORTRAN compiler use the C preprocessor.</p>
<p>The <b>-onetrip</b> option was not included in this volume of IEEE&nbsp;Std&nbsp;1003.1-2001, even though many historical
compilers support it, because it is derived from FORTRAN-66; it is an anachronism that should not be perpetuated.</p>
<p>Some implementations produce compilation listings. This aspect of FORTRAN has been left unspecified because there was
controversy concerning the various methods proposed for implementing it: a <b>-V</b> option overlapped with historical vendor
practice and a naming convention of creating files with <b>.l</b> suffixes collided with historical <a href=
"../utilities/lex.html"><i>lex</i></a> file naming practice.</p>
<p>There is no <b>-I</b> option in this version of this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 to specify a directory for file
inclusion. An INCLUDE directive has been a part of the Fortran-90 discussions, but an interface supporting that standard is not in
the current scope.</p>
<p>It is noted that many FORTRAN compilers produce an object module even when compilation errors occur; during a subsequent
compilation, the compiler may patch the object module rather than recompiling all the code. Consequently, it is left to the
implementor whether or not an object file is created.</p>
<p>A reference to MIL-STD-1753 was removed from an early proposal in response to a request from the POSIX FORTRAN-binding standard
developers. It was not the intention of the standard developers to require certification of the FORTRAN compiler, and
IEEE&nbsp;Std&nbsp;1003.9-1992 does not specify the military standard or any special preprocessing requirements. Furthermore, use
of that document would have been inappropriate for an international standard.</p>
<p>The specification of optimization has been subject to changes through early proposals. At one time, <b>-O</b> and <b>-N</b> were
Booleans: optimize and do not optimize (with an unspecified default). Some historical practice led this to be changed to:</p>
<dl compact>
<dt><b>-O</b>&nbsp;0</dt>
<dd>No optimization.</dd>
<dt><b>-O</b>&nbsp;1</dt>
<dd>Some level of optimization.</dd>
<dt><b>-O&nbsp;</b> <i>n</i></dt>
<dd>Other, unspecified levels of optimization.</dd>
</dl>
<p>It is not always clear whether &quot;good code generation&quot; is the same thing as optimization. Simple optimizations of local actions
do not usually affect the semantics of a program. The <b>-O</b> 0 option has been included to accommodate the very particular
nature of scientific calculations in a highly optimized environment; compilers make errors. Some degree of optimization is
expected, even if it is not documented here, and the ability to shut it off completely could be important when porting an
application. An implementation may treat <b>-O</b> 0 as &quot;do less than normal&quot; if it wishes, but this is only meaningful if any of
the operations it performs can affect the semantics of a program. It is highly dependent on the implementation whether doing less
than normal is logical. It is not the intent of the <b>-O</b> 0 option to ask for inefficient code generation, but rather to assure
that any semantically visible optimization is suppressed.</p>
<p>The specification of standard library access is consistent with the C compiler specification. Implementations are not required
to have <b>/usr/lib/libf.a</b>, as many historical implementations do, but if not they are required to recognize <b>f</b> as a
token.</p>
<p>External symbol size limits are in normative text; conforming applications need to know these limits. However, the minimum
maximum symbol length should be taken as a constraint on a conforming application, not on an implementation, and consequently the
action taken for a symbol exceeding the limit is unspecified. The minimum size for the external symbol table was added for similar
reasons.</p>
<p>The CONSEQUENCES OF ERRORS section clearly specifies the behavior of the compiler when compilation or link-edit errors occur.
The behavior of several historical implementations was examined, and the choice was made to be silent on the status of the
executable, or <b>a.out</b>, file in the face of compiler or linker errors. If a linker writes the executable file, then links it
on disk with <a href="../functions/lseek.html"><i>lseek</i>()</a>s and <a href="../functions/write.html"><i>write</i>()</a>s, the
partially linked executable file can be left on disk and its execute bits turned off if the link edit fails. However, if the linker
links the image in memory before writing the file to disk, it need not touch the executable file (if it already exists) because the
link edit fails. Since both approaches are historical practice, a conforming application shall rely on the exit status of
<i>fort77</i>, rather than on the existence or mode of the executable file.</p>
<p>The <b>-g</b> and <b>-s</b> options are not specified as mutually-exclusive. Historically these two options have been
mutually-exclusive, but because both are so loosely specified, it seemed appropriate to leave their interaction unspecified.</p>
<p>The requirement that conforming applications specify compiler options separately is to reserve the multi-character option name
space for vendor-specific compiler options, which are known to exist in many historical implementations. Implementations are not
required to recognize, for example, <b>-gc</b> as if it were <b>-g</b> <b>-c</b>; nor are they forbidden from doing so. The
SYNOPSIS shows all of the options separately to highlight this requirement on applications.</p>
<p>Echoing filenames to standard error is considered a diagnostic message because it would otherwise be difficult to associate an
error message with the erring file. They are described with &quot;may&quot; to allow implementations to use other methods of identifying
files and to parallel the description in <a href="../utilities/c99.html"><i>c99</i></a>.</p>
</blockquote>
<h4><a name="tag_04_57_19"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>A compilation system based on the ISO/IEC&nbsp;1539:1990 standard (Fortran-90) may be considered for a future version; it may
have a different utility name from <i>fort77</i>.</p>
</blockquote>
<h4><a name="tag_04_57_20"></a>SEE ALSO</h4>
<blockquote>
<p><a href="ar.html"><i>ar</i></a> , <a href="asa.html"><i>asa</i></a> , <a href="c99.html"><i>c99</i></a> , <a href=
"umask.html"><i>umask</i>()</a> , the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <i>exec</i></p>
</blockquote>
<h4><a name="tag_04_57_21"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 4.</p>
</blockquote>
<h4><a name="tag_04_57_22"></a>Issue 6</h4>
<blockquote>
<p>This utility is marked as part of the FORTRAN Development Utilities option.</p>
<p>The normative text is reworded to avoid use of the term &quot;must&quot; for application requirements.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>