1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
<html lang="en">
<head>
<title>Fortran-interface routines - FFTW 3.1.2</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="FFTW 3.1.2">
<meta name="generator" content="makeinfo 4.8">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Calling-FFTW-from-Fortran.html#Calling-FFTW-from-Fortran" title="Calling FFTW from Fortran">
<link rel="prev" href="Calling-FFTW-from-Fortran.html#Calling-FFTW-from-Fortran" title="Calling FFTW from Fortran">
<link rel="next" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran" title="FFTW Constants in Fortran">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is for FFTW
(version 3.1.2, 23 June 2006).
Copyright (C) 2003 Matteo Frigo.
Copyright (C) 2003 Massachusetts Institute of Technology.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission
notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided
that the entire resulting derived work is distributed under the
terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for
modified versions, except that this permission notice may be
stated in a translation approved by the Free Software Foundation.
-->
<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">
<p>
<a name="Fortran-interface-routines"></a>
<a name="Fortran_002dinterface-routines"></a>
Next: <a rel="next" accesskey="n" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran">FFTW Constants in Fortran</a>,
Previous: <a rel="previous" accesskey="p" href="Calling-FFTW-from-Fortran.html#Calling-FFTW-from-Fortran">Calling FFTW from Fortran</a>,
Up: <a rel="up" accesskey="u" href="Calling-FFTW-from-Fortran.html#Calling-FFTW-from-Fortran">Calling FFTW from Fortran</a>
<hr>
</div>
<h3 class="section">6.1 Fortran-interface routines</h3>
<p>Nearly all of the FFTW functions have Fortran-callable equivalents. The
name of the Fortran routine is the same as that of the corresponding C
routine, but with the `<samp><span class="samp">fftw_</span></samp>' prefix replaced by `<samp><span class="samp">dfftw_</span></samp>'.
(The single and long-double precision versions use `<samp><span class="samp">sfftw_</span></samp>' and
`<samp><span class="samp">lfftw_</span></samp>', respectively, instead of `<samp><span class="samp">fftwf_</span></samp>' and
`<samp><span class="samp">fftwl_</span></samp>'.)<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
<p>For the most part, all of the arguments to the functions are the same,
with the following exceptions:
<ul>
<li><code>plan</code> variables (what would be of type <code>fftw_plan</code> in C),
must be declared as a type that is at least as big as a pointer
(address) on your machine. We recommend using <code>integer*8</code>.
<a name="index-portability-320"></a>
<li>Any function that returns a value (e.g. <code>fftw_plan_dft</code>) is
converted into a <em>subroutine</em>. The return value is converted into
an additional <em>first</em> parameter of this subroutine.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
<li><a name="index-column_002dmajor-321"></a>The Fortran routines expect multi-dimensional arrays to be in
<em>column-major</em> order, which is the ordinary format of Fortran
arrays (see <a href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>). They do this
transparently and costlessly simply by reversing the order of the
dimensions passed to FFTW, but this has one important consequence for
multi-dimensional real-complex transforms, discussed below.
<li>Wisdom import and export is somewhat more tricky because one cannot
easily pass files or strings between C and Fortran; see <a href="Wisdom-of-Fortran_003f.html#Wisdom-of-Fortran_003f">Wisdom of Fortran?</a>.
<li>Fortran cannot use the <code>fftw_malloc</code> dynamic-allocation routine.
If you want to exploit the SIMD FFTW (see <a href="Data-Alignment.html#Data-Alignment">Data Alignment</a>), you'll
need to figure out some other way to ensure that your arrays are at
least 16-byte aligned.
<li><a name="index-fftw_005fiodim-322"></a><a name="index-guru-interface-323"></a>Since Fortran 77 does not have data structures, the <code>fftw_iodim</code>
structure from the guru interface (see <a href="Guru-vector-and-transform-sizes.html#Guru-vector-and-transform-sizes">Guru vector and transform sizes</a>) must be split into separate arguments. In particular, any
<code>fftw_iodim</code> array arguments in the C guru interface become three
integer array arguments (<code>n</code>, <code>is</code>, and <code>os</code>) in the
Fortran guru interface, all of whose lengths should be equal to the
corresponding <code>rank</code> argument.
</ul>
<p>In general, you should take care to use Fortran data types that
correspond to (i.e. are the same size as) the C types used by FFTW. If
your C and Fortran compilers are made by the same vendor, the
correspondence is usually straightforward (i.e. <code>integer</code>
corresponds to <code>int</code>, <code>real</code> corresponds to <code>float</code>,
etcetera). The native Fortran double/single-precision complex type
should be compatible with <code>fftw_complex</code>/<code>fftwf_complex</code>.
Such simple correspondences are assumed in the examples below.
<a name="index-portability-324"></a>
<!-- -->
<div class="footnote">
<hr>
<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> Technically, Fortran 77 identifiers are
not allowed to have more than 6 characters, nor may they contain
underscores. Any compiler that enforces this limitation doesn't deserve
to link to FFTW.</p>
<p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> The
reason for this is that some Fortran implementations seem to have
trouble with C function return values, and vice versa.</p>
<p><hr></div>
</body></html>
|