annotate src/fftw-3.3.3/doc/html/Fortran_002dinterface-routines.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>Fortran-interface routines - 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="Calling-FFTW-from-Legacy-Fortran.html#Calling-FFTW-from-Legacy-Fortran" title="Calling FFTW from Legacy Fortran">
cannam@95 10 <link rel="next" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran" title="FFTW Constants in Fortran">
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="Fortran-interface-routines"></a>
cannam@95 50 <a name="Fortran_002dinterface-routines"></a>
cannam@95 51 <p>
cannam@95 52 Next:&nbsp;<a rel="next" accesskey="n" href="FFTW-Constants-in-Fortran.html#FFTW-Constants-in-Fortran">FFTW Constants in Fortran</a>,
cannam@95 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>,
cannam@95 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>
cannam@95 55 <hr>
cannam@95 56 </div>
cannam@95 57
cannam@95 58 <h3 class="section">8.1 Fortran-interface routines</h3>
cannam@95 59
cannam@95 60 <p>Nearly all of the FFTW functions have Fortran-callable equivalents.
cannam@95 61 The name of the legacy Fortran routine is the same as that of the
cannam@95 62 corresponding C routine, but with the &lsquo;<samp><span class="samp">fftw_</span></samp>&rsquo; prefix replaced by
cannam@95 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
cannam@95 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
cannam@95 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>)
cannam@95 66 is available on some systems as &lsquo;<samp><span class="samp">fftwq_</span></samp>&rsquo; (see <a href="Precision.html#Precision">Precision</a>).
cannam@95 67 (Note that <code>long double</code> on x86 hardware is usually at most
cannam@95 68 80-bit extended precision, <em>not</em> quadruple precision.)
cannam@95 69
cannam@95 70 <p>For the most part, all of the arguments to the functions are the same,
cannam@95 71 with the following exceptions:
cannam@95 72
cannam@95 73 <ul>
cannam@95 74 <li><code>plan</code> variables (what would be of type <code>fftw_plan</code> in C),
cannam@95 75 must be declared as a type that is at least as big as a pointer
cannam@95 76 (address) on your machine. We recommend using <code>integer*8</code> everywhere,
cannam@95 77 since this should always be big enough.
cannam@95 78 <a name="index-portability-578"></a>
cannam@95 79 <li>Any function that returns a value (e.g. <code>fftw_plan_dft</code>) is
cannam@95 80 converted into a <em>subroutine</em>. The return value is converted into
cannam@95 81 an additional <em>first</em> parameter of this subroutine.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
cannam@95 82
cannam@95 83 <li><a name="index-column_002dmajor-579"></a>The Fortran routines expect multi-dimensional arrays to be in
cannam@95 84 <em>column-major</em> order, which is the ordinary format of Fortran
cannam@95 85 arrays (see <a href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>). They do this
cannam@95 86 transparently and costlessly simply by reversing the order of the
cannam@95 87 dimensions passed to FFTW, but this has one important consequence for
cannam@95 88 multi-dimensional real-complex transforms, discussed below.
cannam@95 89
cannam@95 90 <li>Wisdom import and export is somewhat more tricky because one cannot
cannam@95 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>.
cannam@95 92
cannam@95 93 <li>Legacy Fortran cannot use the <code>fftw_malloc</code> dynamic-allocation routine.
cannam@95 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
cannam@95 95 need to figure out some other way to ensure that your arrays are at
cannam@95 96 least 16-byte aligned.
cannam@95 97
cannam@95 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>
cannam@95 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
cannam@95 100 <code>fftw_iodim</code> array arguments in the C guru interface become three
cannam@95 101 integer array arguments (<code>n</code>, <code>is</code>, and <code>os</code>) in the
cannam@95 102 Fortran guru interface, all of whose lengths should be equal to the
cannam@95 103 corresponding <code>rank</code> argument.
cannam@95 104
cannam@95 105 <li>The guru planner interface in Fortran does <em>not</em> do any automatic
cannam@95 106 translation between column-major and row-major; you are responsible
cannam@95 107 for setting the strides etcetera to correspond to your Fortran arrays.
cannam@95 108 However, as a slight bug that we are preserving for backwards
cannam@95 109 compatibility, the &lsquo;<samp><span class="samp">plan_guru_r2r</span></samp>&rsquo; in Fortran <em>does</em> reverse the
cannam@95 110 order of its <code>kind</code> array parameter, so the <code>kind</code> array
cannam@95 111 of that routine should be in the reverse of the order of the iodim
cannam@95 112 arrays (see above).
cannam@95 113
cannam@95 114 </ul>
cannam@95 115
cannam@95 116 <p>In general, you should take care to use Fortran data types that
cannam@95 117 correspond to (i.e. are the same size as) the C types used by FFTW.
cannam@95 118 In practice, this correspondence is usually straightforward
cannam@95 119 (i.e. <code>integer</code> corresponds to <code>int</code>, <code>real</code>
cannam@95 120 corresponds to <code>float</code>, etcetera). The native Fortran
cannam@95 121 double/single-precision complex type should be compatible with
cannam@95 122 <code>fftw_complex</code>/<code>fftwf_complex</code>. Such simple correspondences
cannam@95 123 are assumed in the examples below.
cannam@95 124 <a name="index-portability-582"></a>
cannam@95 125 <!-- -->
cannam@95 126
cannam@95 127 <div class="footnote">
cannam@95 128 <hr>
cannam@95 129 <h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> Technically, Fortran 77 identifiers are not
cannam@95 130 allowed to have more than 6 characters, nor may they contain
cannam@95 131 underscores. Any compiler that enforces this limitation doesn't
cannam@95 132 deserve to link to FFTW.</p>
cannam@95 133
cannam@95 134 <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> The
cannam@95 135 reason for this is that some Fortran implementations seem to have
cannam@95 136 trouble with C function return values, and vice versa.</p>
cannam@95 137
cannam@95 138 <hr></div>
cannam@95 139
cannam@95 140 </body></html>
cannam@95 141