annotate src/fftw-3.3.3/doc/html/FFTW-Execution-in-Fortran.html @ 95:89f5e221ed7b

Add FFTW3
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 20 Mar 2013 15:35:50 +0000
parents
children
rev   line source
cannam@95 1 <html lang="en">
cannam@95 2 <head>
cannam@95 3 <title>FFTW Execution in Fortran - FFTW 3.3.3</title>
cannam@95 4 <meta http-equiv="Content-Type" content="text/html">
cannam@95 5 <meta name="description" content="FFTW 3.3.3">
cannam@95 6 <meta name="generator" content="makeinfo 4.13">
cannam@95 7 <link title="Top" rel="start" href="index.html#Top">
cannam@95 8 <link rel="up" href="Calling-FFTW-from-Legacy-Fortran.html#Calling-FFTW-from-Legacy-Fortran" title="Calling FFTW from Legacy Fortran">
cannam@95 9 <link rel="prev" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran" title="FFTW Constants in Fortran">
cannam@95 10 <link rel="next" href="Fortran-Examples.html#Fortran-Examples" title="Fortran Examples">
cannam@95 11 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
cannam@95 12 <!--
cannam@95 13 This manual is for FFTW
cannam@95 14 (version 3.3.3, 25 November 2012).
cannam@95 15
cannam@95 16 Copyright (C) 2003 Matteo Frigo.
cannam@95 17
cannam@95 18 Copyright (C) 2003 Massachusetts Institute of Technology.
cannam@95 19
cannam@95 20 Permission is granted to make and distribute verbatim copies of
cannam@95 21 this manual provided the copyright notice and this permission
cannam@95 22 notice are preserved on all copies.
cannam@95 23
cannam@95 24 Permission is granted to copy and distribute modified versions of
cannam@95 25 this manual under the conditions for verbatim copying, provided
cannam@95 26 that the entire resulting derived work is distributed under the
cannam@95 27 terms of a permission notice identical to this one.
cannam@95 28
cannam@95 29 Permission is granted to copy and distribute translations of this
cannam@95 30 manual into another language, under the above conditions for
cannam@95 31 modified versions, except that this permission notice may be
cannam@95 32 stated in a translation approved by the Free Software Foundation.
cannam@95 33 -->
cannam@95 34 <meta http-equiv="Content-Style-Type" content="text/css">
cannam@95 35 <style type="text/css"><!--
cannam@95 36 pre.display { font-family:inherit }
cannam@95 37 pre.format { font-family:inherit }
cannam@95 38 pre.smalldisplay { font-family:inherit; font-size:smaller }
cannam@95 39 pre.smallformat { font-family:inherit; font-size:smaller }
cannam@95 40 pre.smallexample { font-size:smaller }
cannam@95 41 pre.smalllisp { font-size:smaller }
cannam@95 42 span.sc { font-variant:small-caps }
cannam@95 43 span.roman { font-family:serif; font-weight:normal; }
cannam@95 44 span.sansserif { font-family:sans-serif; font-weight:normal; }
cannam@95 45 --></style>
cannam@95 46 </head>
cannam@95 47 <body>
cannam@95 48 <div class="node">
cannam@95 49 <a name="FFTW-Execution-in-Fortran"></a>
cannam@95 50 <p>
cannam@95 51 Next:&nbsp;<a rel="next" accesskey="n" href="Fortran-Examples.html#Fortran-Examples">Fortran Examples</a>,
cannam@95 52 Previous:&nbsp;<a rel="previous" accesskey="p" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran">FFTW Constants in Fortran</a>,
cannam@95 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>
cannam@95 54 <hr>
cannam@95 55 </div>
cannam@95 56
cannam@95 57 <h3 class="section">8.3 FFTW Execution in Fortran</h3>
cannam@95 58
cannam@95 59 <p>In C, in order to use a plan, one normally calls <code>fftw_execute</code>,
cannam@95 60 which executes the plan to perform the transform on the input/output
cannam@95 61 arrays passed when the plan was created (see <a href="Using-Plans.html#Using-Plans">Using Plans</a>). The
cannam@95 62 corresponding subroutine call in legacy Fortran is:
cannam@95 63 <pre class="example"> call dfftw_execute(plan)
cannam@95 64 </pre>
cannam@95 65 <p><a name="index-dfftw_005fexecute-584"></a>
cannam@95 66 However, we have had reports that this causes problems with some
cannam@95 67 recent optimizing Fortran compilers. The problem is, because the
cannam@95 68 input/output arrays are not passed as explicit arguments to
cannam@95 69 <code>dfftw_execute</code>, the semantics of Fortran (unlike C) allow the
cannam@95 70 compiler to assume that the input/output arrays are not changed by
cannam@95 71 <code>dfftw_execute</code>. As a consequence, certain compilers end up
cannam@95 72 optimizing out or repositioning the call to <code>dfftw_execute</code>,
cannam@95 73 assuming incorrectly that it does nothing.
cannam@95 74
cannam@95 75 <p>There are various workarounds to this, but the safest and simplest
cannam@95 76 thing is to not use <code>dfftw_execute</code> in Fortran. Instead, use the
cannam@95 77 functions described in <a href="New_002darray-Execute-Functions.html#New_002darray-Execute-Functions">New-array Execute Functions</a>, which take
cannam@95 78 the input/output arrays as explicit arguments. For example, if the
cannam@95 79 plan is for a complex-data DFT and was created for the arrays
cannam@95 80 <code>in</code> and <code>out</code>, you would do:
cannam@95 81 <pre class="example"> call dfftw_execute_dft(plan, in, out)
cannam@95 82 </pre>
cannam@95 83 <p><a name="index-dfftw_005fexecute_005fdft-585"></a>
cannam@95 84 There are a few things to be careful of, however:
cannam@95 85
cannam@95 86 <ul>
cannam@95 87 <li>You must use the correct type of execute function, matching the way
cannam@95 88 the plan was created. Complex DFT plans should use
cannam@95 89 <code>dfftw_execute_dft</code>, Real-input (r2c) DFT plans should use use
cannam@95 90 <code>dfftw_execute_dft_r2c</code>, and real-output (c2r) DFT plans should
cannam@95 91 use <code>dfftw_execute_dft_c2r</code>. The various r2r plans should use
cannam@95 92 <code>dfftw_execute_r2r</code>.
cannam@95 93
cannam@95 94 <li>You should normally pass the same input/output arrays that were used when
cannam@95 95 creating the plan. This is always safe.
cannam@95 96
cannam@95 97 <li><em>If</em> you pass <em>different</em> input/output arrays compared to
cannam@95 98 those used when creating the plan, you must abide by all the
cannam@95 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
cannam@95 100 requirement that the new arrays have the same alignment as the
cannam@95 101 original arrays, because there seems to be no way in legacy Fortran to obtain
cannam@95 102 guaranteed-aligned arrays (analogous to <code>fftw_malloc</code> in C). You
cannam@95 103 can, of course, use the <code>FFTW_UNALIGNED</code> flag when creating the
cannam@95 104 plan, in which case the plan does not depend on the alignment, but
cannam@95 105 this may sacrifice substantial performance on architectures (like x86)
cannam@95 106 with SIMD instructions (see <a href="SIMD-alignment-and-fftw_005fmalloc.html#SIMD-alignment-and-fftw_005fmalloc">SIMD alignment and fftw_malloc</a>).
cannam@95 107 <a name="index-FFTW_005fUNALIGNED-586"></a>
cannam@95 108 </ul>
cannam@95 109
cannam@95 110 <!-- -->
cannam@95 111 </body></html>
cannam@95 112