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