comparison src/fftw-3.3.3/doc/html/Fortran_002dinterface-routines.html @ 10:37bf6b4a2645

Add FFTW3
author Chris Cannam
date Wed, 20 Mar 2013 15:35:50 +0000
parents
children
comparison
equal deleted inserted replaced
9:c0fb53affa76 10:37bf6b4a2645
1 <html lang="en">
2 <head>
3 <title>Fortran-interface routines - FFTW 3.3.3</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="FFTW 3.3.3">
6 <meta name="generator" content="makeinfo 4.13">
7 <link title="Top" rel="start" href="index.html#Top">
8 <link rel="up" href="Calling-FFTW-from-Legacy-Fortran.html#Calling-FFTW-from-Legacy-Fortran" title="Calling FFTW from Legacy Fortran">
9 <link rel="prev" href="Calling-FFTW-from-Legacy-Fortran.html#Calling-FFTW-from-Legacy-Fortran" title="Calling FFTW from Legacy Fortran">
10 <link rel="next" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran" title="FFTW Constants in Fortran">
11 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12 <!--
13 This manual is for FFTW
14 (version 3.3.3, 25 November 2012).
15
16 Copyright (C) 2003 Matteo Frigo.
17
18 Copyright (C) 2003 Massachusetts Institute of Technology.
19
20 Permission is granted to make and distribute verbatim copies of
21 this manual provided the copyright notice and this permission
22 notice are preserved on all copies.
23
24 Permission is granted to copy and distribute modified versions of
25 this manual under the conditions for verbatim copying, provided
26 that the entire resulting derived work is distributed under the
27 terms of a permission notice identical to this one.
28
29 Permission is granted to copy and distribute translations of this
30 manual into another language, under the above conditions for
31 modified versions, except that this permission notice may be
32 stated in a translation approved by the Free Software Foundation.
33 -->
34 <meta http-equiv="Content-Style-Type" content="text/css">
35 <style type="text/css"><!--
36 pre.display { font-family:inherit }
37 pre.format { font-family:inherit }
38 pre.smalldisplay { font-family:inherit; font-size:smaller }
39 pre.smallformat { font-family:inherit; font-size:smaller }
40 pre.smallexample { font-size:smaller }
41 pre.smalllisp { font-size:smaller }
42 span.sc { font-variant:small-caps }
43 span.roman { font-family:serif; font-weight:normal; }
44 span.sansserif { font-family:sans-serif; font-weight:normal; }
45 --></style>
46 </head>
47 <body>
48 <div class="node">
49 <a name="Fortran-interface-routines"></a>
50 <a name="Fortran_002dinterface-routines"></a>
51 <p>
52 Next:&nbsp;<a rel="next" accesskey="n" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran">FFTW Constants in Fortran</a>,
53 Previous:&nbsp;<a rel="previous" accesskey="p" href="Calling-FFTW-from-Legacy-Fortran.html#Calling-FFTW-from-Legacy-Fortran">Calling FFTW from Legacy Fortran</a>,
54 Up:&nbsp;<a rel="up" accesskey="u" href="Calling-FFTW-from-Legacy-Fortran.html#Calling-FFTW-from-Legacy-Fortran">Calling FFTW from Legacy Fortran</a>
55 <hr>
56 </div>
57
58 <h3 class="section">8.1 Fortran-interface routines</h3>
59
60 <p>Nearly all of the FFTW functions have Fortran-callable equivalents.
61 The name of the legacy Fortran routine is the same as that of the
62 corresponding C routine, but with the &lsquo;<samp><span class="samp">fftw_</span></samp>&rsquo; prefix replaced by
63 &lsquo;<samp><span class="samp">dfftw_</span></samp>&rsquo;.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> The single and long-double precision
64 versions use &lsquo;<samp><span class="samp">sfftw_</span></samp>&rsquo; and &lsquo;<samp><span class="samp">lfftw_</span></samp>&rsquo;, respectively, instead of
65 &lsquo;<samp><span class="samp">fftwf_</span></samp>&rsquo; and &lsquo;<samp><span class="samp">fftwl_</span></samp>&rsquo;; quadruple precision (<code>real*16</code>)
66 is available on some systems as &lsquo;<samp><span class="samp">fftwq_</span></samp>&rsquo; (see <a href="Precision.html#Precision">Precision</a>).
67 (Note that <code>long double</code> on x86 hardware is usually at most
68 80-bit extended precision, <em>not</em> quadruple precision.)
69
70 <p>For the most part, all of the arguments to the functions are the same,
71 with the following exceptions:
72
73 <ul>
74 <li><code>plan</code> variables (what would be of type <code>fftw_plan</code> in C),
75 must be declared as a type that is at least as big as a pointer
76 (address) on your machine. We recommend using <code>integer*8</code> everywhere,
77 since this should always be big enough.
78 <a name="index-portability-578"></a>
79 <li>Any function that returns a value (e.g. <code>fftw_plan_dft</code>) is
80 converted into a <em>subroutine</em>. The return value is converted into
81 an additional <em>first</em> parameter of this subroutine.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
82
83 <li><a name="index-column_002dmajor-579"></a>The Fortran routines expect multi-dimensional arrays to be in
84 <em>column-major</em> order, which is the ordinary format of Fortran
85 arrays (see <a href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>). They do this
86 transparently and costlessly simply by reversing the order of the
87 dimensions passed to FFTW, but this has one important consequence for
88 multi-dimensional real-complex transforms, discussed below.
89
90 <li>Wisdom import and export is somewhat more tricky because one cannot
91 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>.
92
93 <li>Legacy Fortran cannot use the <code>fftw_malloc</code> dynamic-allocation routine.
94 If you want to exploit the SIMD FFTW (see <a href="SIMD-alignment-and-fftw_005fmalloc.html#SIMD-alignment-and-fftw_005fmalloc">SIMD alignment and fftw_malloc</a>), you'll
95 need to figure out some other way to ensure that your arrays are at
96 least 16-byte aligned.
97
98 <li><a name="index-fftw_005fiodim-580"></a><a name="index-guru-interface-581"></a>Since Fortran 77 does not have data structures, the <code>fftw_iodim</code>
99 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
100 <code>fftw_iodim</code> array arguments in the C guru interface become three
101 integer array arguments (<code>n</code>, <code>is</code>, and <code>os</code>) in the
102 Fortran guru interface, all of whose lengths should be equal to the
103 corresponding <code>rank</code> argument.
104
105 <li>The guru planner interface in Fortran does <em>not</em> do any automatic
106 translation between column-major and row-major; you are responsible
107 for setting the strides etcetera to correspond to your Fortran arrays.
108 However, as a slight bug that we are preserving for backwards
109 compatibility, the &lsquo;<samp><span class="samp">plan_guru_r2r</span></samp>&rsquo; in Fortran <em>does</em> reverse the
110 order of its <code>kind</code> array parameter, so the <code>kind</code> array
111 of that routine should be in the reverse of the order of the iodim
112 arrays (see above).
113
114 </ul>
115
116 <p>In general, you should take care to use Fortran data types that
117 correspond to (i.e. are the same size as) the C types used by FFTW.
118 In practice, this correspondence is usually straightforward
119 (i.e. <code>integer</code> corresponds to <code>int</code>, <code>real</code>
120 corresponds to <code>float</code>, etcetera). The native Fortran
121 double/single-precision complex type should be compatible with
122 <code>fftw_complex</code>/<code>fftwf_complex</code>. Such simple correspondences
123 are assumed in the examples below.
124 <a name="index-portability-582"></a>
125 <!-- -->
126
127 <div class="footnote">
128 <hr>
129 <h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> Technically, Fortran 77 identifiers are not
130 allowed to have more than 6 characters, nor may they contain
131 underscores. Any compiler that enforces this limitation doesn't
132 deserve to link to FFTW.</p>
133
134 <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> The
135 reason for this is that some Fortran implementations seem to have
136 trouble with C function return values, and vice versa.</p>
137
138 <hr></div>
139
140 </body></html>
141