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