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