d@0
|
1 <html lang="en">
|
d@0
|
2 <head>
|
d@0
|
3 <title>FFTW Execution in Fortran - 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="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran" title="FFTW Constants in Fortran">
|
d@0
|
10 <link rel="next" href="Fortran-Examples.html#Fortran-Examples" title="Fortran Examples">
|
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="FFTW-Execution-in-Fortran"></a>
|
d@0
|
51 Next: <a rel="next" accesskey="n" href="Fortran-Examples.html#Fortran-Examples">Fortran Examples</a>,
|
d@0
|
52 Previous: <a rel="previous" accesskey="p" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran">FFTW Constants in Fortran</a>,
|
d@0
|
53 Up: <a rel="up" accesskey="u" href="Calling-FFTW-from-Fortran.html#Calling-FFTW-from-Fortran">Calling FFTW from Fortran</a>
|
d@0
|
54 <hr>
|
d@0
|
55 </div>
|
d@0
|
56
|
d@0
|
57 <h3 class="section">7.3 FFTW Execution in Fortran</h3>
|
d@0
|
58
|
d@0
|
59 <p>In C, in order to use a plan, one normally calls <code>fftw_execute</code>,
|
d@0
|
60 which executes the plan to perform the transform on the input/output
|
d@0
|
61 arrays passed when the plan was created (see <a href="Using-Plans.html#Using-Plans">Using Plans</a>). The
|
d@0
|
62 corresponding subroutine call in Fortran is:
|
d@0
|
63 <pre class="example"> call dfftw_execute(plan)
|
d@0
|
64 </pre>
|
d@0
|
65 <p><a name="index-dfftw_005fexecute-338"></a>
|
d@0
|
66 However, we have had reports that this causes problems with some
|
d@0
|
67 recent optimizing Fortran compilers. The problem is, because the
|
d@0
|
68 input/output arrays are not passed as explicit arguments to
|
d@0
|
69 <code>dfftw_execute</code>, the semantics of Fortran (unlike C) allow the
|
d@0
|
70 compiler to assume that the input/output arrays are not changed by
|
d@0
|
71 <code>dfftw_execute</code>. As a consequence, certain compilers end up
|
d@0
|
72 optimizing out or repositioning the call to <code>dfftw_execute</code>,
|
d@0
|
73 assuming incorrectly that it does nothing.
|
d@0
|
74
|
d@0
|
75 <p>There are various workarounds to this, but the safest and simplest
|
d@0
|
76 thing is to not use <code>dfftw_execute</code> in Fortran. Instead, use the
|
d@0
|
77 functions described in <a href="New_002darray-Execute-Functions.html#New_002darray-Execute-Functions">New-array Execute Functions</a>, which take
|
d@0
|
78 the input/output arrays as explicit arguments. For example, if the
|
d@0
|
79 plan is for a complex-data DFT and was created for the arrays
|
d@0
|
80 <code>in</code> and <code>out</code>, you would do:
|
d@0
|
81 <pre class="example"> call dfftw_execute_dft(plan, in, out)
|
d@0
|
82 </pre>
|
d@0
|
83 <p><a name="index-dfftw_005fexecute_005fdft-339"></a>
|
d@0
|
84 There are a few things to be careful of, however:
|
d@0
|
85
|
d@0
|
86 <ul>
|
d@0
|
87 <li>You must use the correct type of execute function, matching the way
|
d@0
|
88 the plan was created. Complex DFT plans should use
|
d@0
|
89 <code>dfftw_execute_dft</code>, Real-input (r2c) DFT plans should use use
|
d@0
|
90 <code>dfftw_execute_dft_r2c</code>, and real-output (c2r) DFT plans should
|
d@0
|
91 use <code>dfftw_execute_dft_c2r</code>. The various r2r plans should use
|
d@0
|
92 <code>dfftw_execute_r2r</code>.
|
d@0
|
93
|
d@0
|
94 <li>You should normally pass the same input/output arrays that were used when
|
d@0
|
95 creating the plan. This is always safe.
|
d@0
|
96
|
d@0
|
97 <li><em>If</em> you pass <em>different</em> input/output arrays compared to
|
d@0
|
98 those used when creating the plan, you must abide by all the
|
d@0
|
99 restrictions of the new-array execute functions (see <a href="New_002darray-Execute-Functions.html#New_002darray-Execute-Functions">New-array Execute Functions</a>). The most difficult of these, in Fortran, is the
|
d@0
|
100 requirement that the new arrays have the same alignment as the
|
d@0
|
101 original arrays, because there seems to be no way in Fortran to obtain
|
d@0
|
102 guaranteed-aligned arrays (analogous to <code>fftw_malloc</code> in C). You
|
d@0
|
103 can, of course, use the <code>FFTW_UNALIGNED</code> flag when creating the
|
d@0
|
104 plan, in which case the plan does not depend on the alignment, but
|
d@0
|
105 this may sacrifice substantial performance on architectures (like x86)
|
d@0
|
106 with SIMD instructions (see <a href="SIMD-alignment-and-fftw_005fmalloc.html#SIMD-alignment-and-fftw_005fmalloc">SIMD alignment and fftw_malloc</a>).
|
d@0
|
107 <a name="index-FFTW_005fUNALIGNED-340"></a>
|
d@0
|
108 </ul>
|
d@0
|
109
|
d@0
|
110 <!-- -->
|
d@0
|
111 </body></html>
|
d@0
|
112
|