Sophie

Sophie

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

gcc-gfortran-4.6.1-2.x86_64.rpm

<html lang="en">
<head>
<title>Argument list functions - 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="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" title="Extensions implemented in GNU Fortran">
<link rel="prev" href="OpenMP.html#OpenMP" title="OpenMP">
<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="Argument-list-functions"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="OpenMP.html#OpenMP">OpenMP</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran">Extensions implemented in GNU Fortran</a>
<hr>
</div>

<h4 class="subsection">6.1.17 Argument list functions <code>%VAL</code>, <code>%REF</code> and <code>%LOC</code></h4>

<p><a name="index-argument-list-functions-320"></a><a name="index-g_t_0040code_007b_0025VAL_007d-321"></a><a name="index-g_t_0040code_007b_0025REF_007d-322"></a><a name="index-g_t_0040code_007b_0025LOC_007d-323"></a>
GNU Fortran supports argument list functions <code>%VAL</code>, <code>%REF</code>
and <code>%LOC</code> statements, for backward compatibility with g77. 
It is recommended that these should be used only for code that is
accessing facilities outside of GNU Fortran, such as operating system
or windowing facilities.  It is best to constrain such uses to isolated
portions of a program&ndash;portions that deal specifically and exclusively
with low-level, system-dependent facilities.  Such portions might well
provide a portable interface for use by the program as a whole, but are
themselves not portable, and should be thoroughly tested each time they
are rebuilt using a new compiler or version of a compiler.

   <p><code>%VAL</code> passes a scalar argument by value, <code>%REF</code> passes it by
reference and <code>%LOC</code> passes its memory location.  Since gfortran
already passes scalar arguments by reference, <code>%REF</code> is in effect
a do-nothing.  <code>%LOC</code> has the same effect as a Fortran pointer.

   <p>An example of passing an argument by value to a C subroutine foo.:
<pre class="smallexample">     C
     C prototype      void foo_ (float x);
     C
           external foo
           real*4 x
           x = 3.14159
           call foo (%VAL (x))
           end
</pre>
   <p>For details refer to the g77 manual
<a href="http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/index.html#Top">http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/index.html#Top</a>.

   <p>Also, <code>c_by_val.f</code> and its partner <code>c_by_val.c</code> of the
GNU Fortran testsuite are worth a look.

   </body></html>