Sophie

Sophie

distrib > Mandriva > 2011.0 > x86_64 > by-pkgid > f13f137693327172bf7ba9b443ff3a61 > files > 80

gcc-gfortran-4.6.1-2.x86_64.rpm

<html lang="en">
<head>
<title>Code Gen Options - The GNU Fortran Compiler</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="The GNU Fortran Compiler">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" title="Invoking GNU Fortran">
<link rel="prev" href="Runtime-Options.html#Runtime-Options" title="Runtime Options">
<link rel="next" href="Environment-Variables.html#Environment-Variables" title="Environment Variables">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Funding Free Software'', the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
``GNU Free Documentation License''.

(a) The FSF's Front-Cover Text is:

     A GNU Manual

(b) The FSF's Back-Cover Text is:

     You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Code-Gen-Options"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Environment-Variables.html#Environment-Variables">Environment Variables</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Runtime-Options.html#Runtime-Options">Runtime Options</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran">Invoking GNU Fortran</a>
<hr>
</div>

<h3 class="section">2.9 Options for code generation conventions</h3>

<p><a name="index-code-generation_002c-conventions-212"></a><a name="index-options_002c-code-generation-213"></a><a name="index-options_002c-run_002dtime-214"></a>
These machine-independent options control the interface conventions
used in code generation.

   <p>Most of them have both positive and negative forms; the negative form
of <samp><span class="option">-ffoo</span></samp> would be <samp><span class="option">-fno-foo</span></samp>.  In the table below, only
one of the forms is listed&mdash;the one which is not the default.  You
can figure out the other form by either removing <samp><span class="option">no-</span></samp> or adding
it.

     <dl>
<dt><code>-fno-automatic</code><dd><a name="index-g_t_0040code_007bfno_002dautomatic_007d-215"></a><a name="index-g_t_0040code_007bSAVE_007d-statement-216"></a><a name="index-statement_002c-_0040code_007bSAVE_007d-217"></a>Treat each program unit (except those marked as RECURSIVE) as if the
<code>SAVE</code> statement were specified for every local variable and array
referenced in it. Does not affect common blocks. (Some Fortran compilers
provide this option under the name <samp><span class="option">-static</span></samp> or <samp><span class="option">-save</span></samp>.) 
The default, which is <samp><span class="option">-fautomatic</span></samp>, uses the stack for local
variables smaller than the value given by <samp><span class="option">-fmax-stack-var-size</span></samp>. 
Use the option <samp><span class="option">-frecursive</span></samp> to use no static memory.

     <br><dt><code>-ff2c</code><dd><a name="index-ff2c-218"></a><a name="index-calling-convention-219"></a><a name="index-g_t_0040command_007bf2c_007d-calling-convention-220"></a><a name="index-g_t_0040command_007bg77_007d-calling-convention-221"></a><a name="index-libf2c-calling-convention-222"></a>Generate code designed to be compatible with code generated
by <samp><span class="command">g77</span></samp> and <samp><span class="command">f2c</span></samp>.

     <p>The calling conventions used by <samp><span class="command">g77</span></samp> (originally implemented
in <samp><span class="command">f2c</span></samp>) require functions that return type
default <code>REAL</code> to actually return the C type <code>double</code>, and
functions that return type <code>COMPLEX</code> to return the values via an
extra argument in the calling sequence that points to where to
store the return value.  Under the default GNU calling conventions, such
functions simply return their results as they would in GNU
C&mdash;default <code>REAL</code> functions return the C type <code>float</code>, and
<code>COMPLEX</code> functions return the GNU C type <code>complex</code>. 
Additionally, this option implies the <samp><span class="option">-fsecond-underscore</span></samp>
option, unless <samp><span class="option">-fno-second-underscore</span></samp> is explicitly requested.

     <p>This does not affect the generation of code that interfaces with
the <samp><span class="command">libgfortran</span></samp> library.

     <p><em>Caution:</em> It is not a good idea to mix Fortran code compiled with
<samp><span class="option">-ff2c</span></samp> with code compiled with the default <samp><span class="option">-fno-f2c</span></samp>
calling conventions as, calling <code>COMPLEX</code> or default <code>REAL</code>
functions between program parts which were compiled with different
calling conventions will break at execution time.

     <p><em>Caution:</em> This will break code which passes intrinsic functions
of type default <code>REAL</code> or <code>COMPLEX</code> as actual arguments, as
the library implementations use the <samp><span class="option">-fno-f2c</span></samp> calling conventions.

     <br><dt><code>-fno-underscoring</code><dd><a name="index-g_t_0040code_007bfno_002dunderscoring_007d-223"></a><a name="index-underscore-224"></a><a name="index-symbol-names_002c-underscores-225"></a><a name="index-transforming-symbol-names-226"></a><a name="index-symbol-names_002c-transforming-227"></a>Do not transform names of entities specified in the Fortran
source file by appending underscores to them.

     <p>With <samp><span class="option">-funderscoring</span></samp> in effect, GNU Fortran appends one
underscore to external names with no underscores.  This is done to ensure
compatibility with code produced by many UNIX Fortran compilers.

     <p><em>Caution</em>: The default behavior of GNU Fortran is
incompatible with <samp><span class="command">f2c</span></samp> and <samp><span class="command">g77</span></samp>, please use the
<samp><span class="option">-ff2c</span></samp> option if you want object files compiled with
GNU Fortran to be compatible with object code created with these
tools.

     <p>Use of <samp><span class="option">-fno-underscoring</span></samp> is not recommended unless you are
experimenting with issues such as integration of GNU Fortran into
existing system environments (vis-&agrave;-vis existing libraries, tools,
and so on).

     <p>For example, with <samp><span class="option">-funderscoring</span></samp>, and assuming other defaults like
<samp><span class="option">-fcase-lower</span></samp> and that <code>j()</code> and <code>max_count()</code> are
external functions while <code>my_var</code> and <code>lvar</code> are local variables,
a statement like
     <pre class="smallexample">          I = J() + MAX_COUNT (MY_VAR, LVAR)
</pre>
     <p class="noindent">is implemented as something akin to:
     <pre class="smallexample">          i = j_() + max_count__(&amp;my_var__, &amp;lvar);
</pre>
     <p>With <samp><span class="option">-fno-underscoring</span></samp>, the same statement is implemented as:

     <pre class="smallexample">          i = j() + max_count(&amp;my_var, &amp;lvar);
</pre>
     <p>Use of <samp><span class="option">-fno-underscoring</span></samp> allows direct specification of
user-defined names while debugging and when interfacing GNU Fortran
code with other languages.

     <p>Note that just because the names match does <em>not</em> mean that the
interface implemented by GNU Fortran for an external name matches the
interface implemented by some other language for that same name. 
That is, getting code produced by GNU Fortran to link to code produced
by some other compiler using this or any other method can be only a
small part of the overall solution&mdash;getting the code generated by
both compilers to agree on issues other than naming can require
significant effort, and, unlike naming disagreements, linkers normally
cannot detect disagreements in these other areas.

     <p>Also, note that with <samp><span class="option">-fno-underscoring</span></samp>, the lack of appended
underscores introduces the very real possibility that a user-defined
external name will conflict with a name in a system library, which
could make finding unresolved-reference bugs quite difficult in some
cases&mdash;they might occur at program run time, and show up only as
buggy behavior at run time.

     <p>In future versions of GNU Fortran we hope to improve naming and linking
issues so that debugging always involves using the names as they appear
in the source, even if the names as seen by the linker are mangled to
prevent accidental linking between procedures with incompatible
interfaces.

     <br><dt><code>-fwhole-file</code><dd><a name="index-g_t_0040code_007bfwhole_002dfile_007d-228"></a>By default, GNU Fortran parses, resolves and translates each procedure
in a file separately.  Using this option modifies this such that the
whole file is parsed and placed in a single front-end tree.  During
resolution, in addition to all the usual checks and fixups, references
to external procedures that are in the same file effect resolution of
that procedure, if not already done, and a check of the interfaces. The
dependences are resolved by changing the order in which the file is
translated into the backend tree.  Thus, a procedure that is referenced
is translated before the reference and the duplication of backend tree
declarations eliminated.

     <br><dt><code>-fsecond-underscore</code><dd><a name="index-g_t_0040code_007bfsecond_002dunderscore_007d-229"></a><a name="index-underscore-230"></a><a name="index-symbol-names_002c-underscores-231"></a><a name="index-transforming-symbol-names-232"></a><a name="index-symbol-names_002c-transforming-233"></a><a name="index-g_t_0040command_007bf2c_007d-calling-convention-234"></a><a name="index-g_t_0040command_007bg77_007d-calling-convention-235"></a><a name="index-libf2c-calling-convention-236"></a>By default, GNU Fortran appends an underscore to external
names.  If this option is used GNU Fortran appends two
underscores to names with underscores and one underscore to external names
with no underscores.  GNU Fortran also appends two underscores to
internal names with underscores to avoid naming collisions with external
names.

     <p>This option has no effect if <samp><span class="option">-fno-underscoring</span></samp> is
in effect.  It is implied by the <samp><span class="option">-ff2c</span></samp> option.

     <p>Otherwise, with this option, an external name such as <code>MAX_COUNT</code>
is implemented as a reference to the link-time external symbol
<code>max_count__</code>, instead of <code>max_count_</code>.  This is required
for compatibility with <samp><span class="command">g77</span></samp> and <samp><span class="command">f2c</span></samp>, and is implied
by use of the <samp><span class="option">-ff2c</span></samp> option.

     <br><dt><code>-fcoarray=</code><var>&lt;keyword&gt;</var><dd><a name="index-g_t_0040code_007bfcoarray_007d-237"></a><a name="index-coarrays-238"></a>
          <dl>
<dt>&lsquo;<samp><span class="samp">none</span></samp>&rsquo;<dd>Disable coarray support; using coarray declarations and image-control
statements will produce a compile-time error. (Default)

          <br><dt>&lsquo;<samp><span class="samp">single</span></samp>&rsquo;<dd>Single-image mode, i.e. <code>num_images()</code> is always one. 
</dl>

     <br><dt><code>-fcheck=</code><var>&lt;keyword&gt;</var><dd><a name="index-g_t_0040code_007bfcheck_007d-239"></a><a name="index-array_002c-bounds-checking-240"></a><a name="index-bounds-checking-241"></a><a name="index-pointer-checking-242"></a><a name="index-memory-checking-243"></a><a name="index-range-checking-244"></a><a name="index-subscript-checking-245"></a><a name="index-checking-subscripts-246"></a><a name="index-run_002dtime-checking-247"></a><a name="index-checking-array-temporaries-248"></a>
Enable the generation of run-time checks; the argument shall be
a comma-delimited list of the following keywords.

          <dl>
<dt>&lsquo;<samp><span class="samp">all</span></samp>&rsquo;<dd>Enable all run-time test of <samp><span class="option">-fcheck</span></samp>.

          <br><dt>&lsquo;<samp><span class="samp">array-temps</span></samp>&rsquo;<dd>Warns at run time when for passing an actual argument a temporary array
had to be generated. The information generated by this warning is
sometimes useful in optimization, in order to avoid such temporaries.

          <p>Note: The warning is only printed once per location.

          <br><dt>&lsquo;<samp><span class="samp">bounds</span></samp>&rsquo;<dd>Enable generation of run-time checks for array subscripts
and against the declared minimum and maximum values.  It also
checks array indices for assumed and deferred
shape arrays against the actual allocated bounds and ensures that all string
lengths are equal for character array constructors without an explicit
typespec.

          <p>Some checks require that <samp><span class="option">-fcheck=bounds</span></samp> is set for
the compilation of the main program.

          <p>Note: In the future this may also include other forms of checking, e.g.,
checking substring references.

          <br><dt>&lsquo;<samp><span class="samp">do</span></samp>&rsquo;<dd>Enable generation of run-time checks for invalid modification of loop
iteration variables.

          <br><dt>&lsquo;<samp><span class="samp">mem</span></samp>&rsquo;<dd>Enable generation of run-time checks for memory allocation. 
Note: This option does not affect explicit allocations using the
<code>ALLOCATE</code> statement, which will be always checked.

          <br><dt>&lsquo;<samp><span class="samp">pointer</span></samp>&rsquo;<dd>Enable generation of run-time checks for pointers and allocatables.

          <br><dt>&lsquo;<samp><span class="samp">recursion</span></samp>&rsquo;<dd>Enable generation of run-time checks for recursively called subroutines and
functions which are not marked as recursive. See also <samp><span class="option">-frecursive</span></samp>. 
Note: This check does not work for OpenMP programs and is disabled if used
together with <samp><span class="option">-frecursive</span></samp> and <samp><span class="option">-fopenmp</span></samp>. 
</dl>

     <br><dt><code>-fbounds-check</code><dd><a name="index-g_t_0040code_007bfbounds_002dcheck_007d-249"></a><!-- Note: This option is also referred in gcc's manpage -->
Deprecated alias for <samp><span class="option">-fcheck=bounds</span></samp>.

     <br><dt><code>-fcheck-array-temporaries</code><dd><a name="index-g_t_0040code_007bfcheck_002darray_002dtemporaries_007d-250"></a>Deprecated alias for <samp><span class="option">-fcheck=array-temps</span></samp>.

     <br><dt><code>-fmax-array-constructor=</code><var>n</var><dd><a name="index-g_t_0040code_007bfmax_002darray_002dconstructor_007d-251"></a>This option can be used to increase the upper limit permitted in
array constructors.  The code below requires this option to expand
the array at compile time.

     <pre class="smallexample">          program test
          implicit none
          integer j
          integer, parameter :: n = 100000
          integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)
          print '(10(I0,1X))', i
          end program test
</pre>
     <p><em>Caution:  This option can lead to long compile times and excessively
large object files.</em>

     <p>The default value for <var>n</var> is 65535.

     <br><dt><code>-fmax-stack-var-size=</code><var>n</var><dd><a name="index-g_t_0040code_007bfmax_002dstack_002dvar_002dsize_007d-252"></a>This option specifies the size in bytes of the largest array that will be put
on the stack; if the size is exceeded static memory is used (except in
procedures marked as RECURSIVE). Use the option <samp><span class="option">-frecursive</span></samp> to
allow for recursive procedures which do not have a RECURSIVE attribute or
for parallel programs. Use <samp><span class="option">-fno-automatic</span></samp> to never use the stack.

     <p>This option currently only affects local arrays declared with constant
bounds, and may not apply to all character variables. 
Future versions of GNU Fortran may improve this behavior.

     <p>The default value for <var>n</var> is 32768.

     <br><dt><code>-fpack-derived</code><dd><a name="index-g_t_0040code_007bfpack_002dderived_007d-253"></a><a name="index-structure-packing-254"></a>This option tells GNU Fortran to pack derived type members as closely as
possible.  Code compiled with this option is likely to be incompatible
with code compiled without this option, and may execute slower.

     <br><dt><code>-frepack-arrays</code><dd><a name="index-g_t_0040code_007bfrepack_002darrays_007d-255"></a><a name="index-repacking-arrays-256"></a>In some circumstances GNU Fortran may pass assumed shape array
sections via a descriptor describing a noncontiguous area of memory. 
This option adds code to the function prologue to repack the data into
a contiguous block at runtime.

     <p>This should result in faster accesses to the array.  However it can introduce
significant overhead to the function call, especially  when the passed data
is noncontiguous.

     <br><dt><code>-fshort-enums</code><dd><a name="index-g_t_0040code_007bfshort_002denums_007d-257"></a>This option is provided for interoperability with C code that was
compiled with the <samp><span class="option">-fshort-enums</span></samp> option.  It will make
GNU Fortran choose the smallest <code>INTEGER</code> kind a given
enumerator set will fit in, and give all its enumerators this kind.

     <br><dt><code>-fexternal-blas</code><dd><a name="index-g_t_0040code_007bfexternal_002dblas_007d-258"></a>This option will make <samp><span class="command">gfortran</span></samp> generate calls to BLAS functions
for some matrix operations like <code>MATMUL</code>, instead of using our own
algorithms, if the size of the matrices involved is larger than a given
limit (see <samp><span class="option">-fblas-matmul-limit</span></samp>).  This may be profitable if an
optimized vendor BLAS library is available.  The BLAS library will have
to be specified at link time.

     <br><dt><code>-fblas-matmul-limit=</code><var>n</var><dd><a name="index-g_t_0040code_007bfblas_002dmatmul_002dlimit_007d-259"></a>Only significant when <samp><span class="option">-fexternal-blas</span></samp> is in effect. 
Matrix multiplication of matrices with size larger than (or equal to) <var>n</var>
will be performed by calls to BLAS functions, while others will be
handled by <samp><span class="command">gfortran</span></samp> internal algorithms. If the matrices
involved are not square, the size comparison is performed using the
geometric mean of the dimensions of the argument and result matrices.

     <p>The default value for <var>n</var> is 30.

     <br><dt><code>-frecursive</code><dd><a name="index-g_t_0040code_007bfrecursive_007d-260"></a>Allow indirect recursion by forcing all local arrays to be allocated
on the stack. This flag cannot be used together with
<samp><span class="option">-fmax-stack-var-size=</span></samp> or <samp><span class="option">-fno-automatic</span></samp>.

     <br><dt><code>-finit-local-zero</code><dt><code>-finit-integer=</code><var>n</var><dt><code>-finit-real=</code><var>&lt;zero|inf|-inf|nan|snan&gt;</var><dt><code>-finit-logical=</code><var>&lt;true|false&gt;</var><dt><code>-finit-character=</code><var>n</var><dd><a name="index-g_t_0040code_007bfinit_002dlocal_002dzero_007d-261"></a><a name="index-g_t_0040code_007bfinit_002dinteger_007d-262"></a><a name="index-g_t_0040code_007bfinit_002dreal_007d-263"></a><a name="index-g_t_0040code_007bfinit_002dlogical_007d-264"></a><a name="index-g_t_0040code_007bfinit_002dcharacter_007d-265"></a>The <samp><span class="option">-finit-local-zero</span></samp> option instructs the compiler to
initialize local <code>INTEGER</code>, <code>REAL</code>, and <code>COMPLEX</code>
variables to zero, <code>LOGICAL</code> variables to false, and
<code>CHARACTER</code> variables to a string of null bytes.  Finer-grained
initialization options are provided by the
<samp><span class="option">-finit-integer=</span><var>n</var></samp>,
<samp><span class="option">-finit-real=</span><var>&lt;zero|inf|-inf|nan|snan&gt;</var></samp> (which also initializes
the real and imaginary parts of local <code>COMPLEX</code> variables),
<samp><span class="option">-finit-logical=</span><var>&lt;true|false&gt;</var></samp>, and
<samp><span class="option">-finit-character=</span><var>n</var></samp> (where <var>n</var> is an ASCII character
value) options.  These options do not initialize components of derived
type variables, nor do they initialize variables that appear in an
<code>EQUIVALENCE</code> statement.  (This limitation may be removed in
future releases).

     <p>Note that the <samp><span class="option">-finit-real=nan</span></samp> option initializes <code>REAL</code>
and <code>COMPLEX</code> variables with a quiet NaN. For a signalling NaN
use <samp><span class="option">-finit-real=snan</span></samp>; note, however, that compile-time
optimizations may convert them into quiet NaN and that trapping
needs to be enabled (e.g. via <samp><span class="option">-ffpe-trap</span></samp>).

     <br><dt><code>-falign-commons</code><dd><a name="index-g_t_0040code_007bfalign_002dcommons_007d-266"></a><a name="index-alignment-of-_0040code_007bCOMMON_007d-blocks-267"></a>By default, <samp><span class="command">gfortran</span></samp> enforces proper alignment of all variables in a
<code>COMMON</code> block by padding them as needed. On certain platforms this is mandatory,
on others it increases performance. If a <code>COMMON</code> block is not declared with
consistent data types everywhere, this padding can cause trouble, and
<samp><span class="option">-fno-align-commons</span></samp> can be used to disable automatic alignment. The
same form of this option should be used for all files that share a <code>COMMON</code> block. 
To avoid potential alignment issues in <code>COMMON</code> blocks, it is recommended to order
objects from largest to smallest.

     <br><dt><code>-fno-protect-parens</code><dd><a name="index-g_t_0040code_007bfno_002dprotect_002dparens_007d-268"></a><a name="index-re_002dassociation-of-parenthesized-expressions-269"></a>By default the parentheses in expression are honored for all optimization
levels such that the compiler does not do any re-association. Using
<samp><span class="option">-fno-protect-parens</span></samp> allows the compiler to reorder <code>REAL</code> and
<code>COMPLEX</code> expressions to produce faster code. Note that for the re-association
optimization <samp><span class="option">-fno-signed-zeros</span></samp> and <samp><span class="option">-fno-trapping-math</span></samp>
need to be in effect.

     <br><dt><code>-frealloc-lhs</code><dd><a name="index-g_t_0040code_007bfrealloc_002dlhs_007d-270"></a><a name="index-Reallocate-the-LHS-in-assignments-271"></a>An allocatable left-hand side of an intrinsic assignment is automatically
(re)allocated if it is either unallocated or has a different shape. The
option is enabled by default except when <samp><span class="option">-std=f95</span></samp> is given. 
</dl>

   <p>See <a href="../gcc/Code-Gen-Options.html#Code-Gen-Options">Options for Code Generation Conventions</a>, for information on more options
offered by the GBE
shared by <samp><span class="command">gfortran</span></samp>, <samp><span class="command">gcc</span></samp>, and other GNU compilers.

<!-- man end -->
   </body></html>