Mercurial > hg > batch-feature-extraction-tool
comparison Lib/fftw-3.2.1/doc/html/.svn/text-base/Fortran-Examples.html.svn-base @ 0:25bf17994ef1
First commit. VS2013, Codeblocks and Mac OSX configuration
author | Geogaddi\David <d.m.ronan@qmul.ac.uk> |
---|---|
date | Thu, 09 Jul 2015 01:12:16 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:25bf17994ef1 |
---|---|
1 <html lang="en"> | |
2 <head> | |
3 <title>Fortran Examples - FFTW 3.2.1</title> | |
4 <meta http-equiv="Content-Type" content="text/html"> | |
5 <meta name="description" content="FFTW 3.2.1"> | |
6 <meta name="generator" content="makeinfo 4.8"> | |
7 <link title="Top" rel="start" href="index.html#Top"> | |
8 <link rel="up" href="Calling-FFTW-from-Fortran.html#Calling-FFTW-from-Fortran" title="Calling FFTW from Fortran"> | |
9 <link rel="prev" href="FFTW-Execution-in-Fortran.html#FFTW-Execution-in-Fortran" title="FFTW Execution in Fortran"> | |
10 <link rel="next" href="Wisdom-of-Fortran_003f.html#Wisdom-of-Fortran_003f" title="Wisdom of Fortran?"> | |
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.2.1, 5 February 2009). | |
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 <p> | |
50 <a name="Fortran-Examples"></a> | |
51 Next: <a rel="next" accesskey="n" href="Wisdom-of-Fortran_003f.html#Wisdom-of-Fortran_003f">Wisdom of Fortran?</a>, | |
52 Previous: <a rel="previous" accesskey="p" href="FFTW-Execution-in-Fortran.html#FFTW-Execution-in-Fortran">FFTW Execution in Fortran</a>, | |
53 Up: <a rel="up" accesskey="u" href="Calling-FFTW-from-Fortran.html#Calling-FFTW-from-Fortran">Calling FFTW from Fortran</a> | |
54 <hr> | |
55 </div> | |
56 | |
57 <h3 class="section">7.4 Fortran Examples</h3> | |
58 | |
59 <p>In C, you might have something like the following to transform a | |
60 one-dimensional complex array: | |
61 | |
62 <pre class="example"> fftw_complex in[N], out[N]; | |
63 fftw_plan plan; | |
64 | |
65 plan = fftw_plan_dft_1d(N,in,out,FFTW_FORWARD,FFTW_ESTIMATE); | |
66 fftw_execute(plan); | |
67 fftw_destroy_plan(plan); | |
68 </pre> | |
69 <p>In Fortran, you would use the following to accomplish the same thing: | |
70 | |
71 <pre class="example"> double complex in, out | |
72 dimension in(N), out(N) | |
73 integer*8 plan | |
74 | |
75 call dfftw_plan_dft_1d(plan,N,in,out,FFTW_FORWARD,FFTW_ESTIMATE) | |
76 call dfftw_execute_dft(plan, in, out) | |
77 call dfftw_destroy_plan(plan) | |
78 </pre> | |
79 <p><a name="index-dfftw_005fplan_005fdft_005f1d-341"></a><a name="index-dfftw_005fexecute_005fdft-342"></a><a name="index-dfftw_005fdestroy_005fplan-343"></a> | |
80 Notice how all routines are called as Fortran subroutines, and the | |
81 plan is returned via the first argument to <code>dfftw_plan_dft_1d</code>. | |
82 Notice also that we changed <code>fftw_execute</code> to | |
83 <code>dfftw_execute_dft</code> (see <a href="FFTW-Execution-in-Fortran.html#FFTW-Execution-in-Fortran">FFTW Execution in Fortran</a>). To do | |
84 the same thing, but using 8 threads in parallel (see <a href="Multi_002dthreaded-FFTW.html#Multi_002dthreaded-FFTW">Multi-threaded FFTW</a>), you would simply prefix these calls with: | |
85 | |
86 <pre class="example"> call dfftw_init_threads | |
87 call dfftw_plan_with_nthreads(8) | |
88 </pre> | |
89 <p><a name="index-dfftw_005finit_005fthreads-344"></a><a name="index-dfftw_005fplan_005fwith_005fnthreads-345"></a> | |
90 To transform a three-dimensional array in-place with C, you might do: | |
91 | |
92 <pre class="example"> fftw_complex arr[L][M][N]; | |
93 fftw_plan plan; | |
94 | |
95 plan = fftw_plan_dft_3d(L,M,N, arr,arr, | |
96 FFTW_FORWARD, FFTW_ESTIMATE); | |
97 fftw_execute(plan); | |
98 fftw_destroy_plan(plan); | |
99 </pre> | |
100 <p>In Fortran, you would use this instead: | |
101 | |
102 <pre class="example"> double complex arr | |
103 dimension arr(L,M,N) | |
104 integer*8 plan | |
105 | |
106 call dfftw_plan_dft_3d(plan, L,M,N, arr,arr, | |
107 & FFTW_FORWARD, FFTW_ESTIMATE) | |
108 call dfftw_execute_dft(plan, arr, arr) | |
109 call dfftw_destroy_plan(plan) | |
110 </pre> | |
111 <p><a name="index-dfftw_005fplan_005fdft_005f3d-346"></a> | |
112 Note that we pass the array dimensions in the “natural” order in both C | |
113 and Fortran. | |
114 | |
115 <p>To transform a one-dimensional real array in Fortran, you might do: | |
116 | |
117 <pre class="example"> double precision in | |
118 dimension in(N) | |
119 double complex out | |
120 dimension out(N/2 + 1) | |
121 integer*8 plan | |
122 | |
123 call dfftw_plan_dft_r2c_1d(plan,N,in,out,FFTW_ESTIMATE) | |
124 call dfftw_execute_dft_r2c(plan, in, out) | |
125 call dfftw_destroy_plan(plan) | |
126 </pre> | |
127 <p><a name="index-dfftw_005fplan_005fdft_005fr2c_005f1d-347"></a><a name="index-dfftw_005fexecute_005fdft_005fr2c-348"></a> | |
128 To transform a two-dimensional real array, out of place, you might use | |
129 the following: | |
130 | |
131 <pre class="example"> double precision in | |
132 dimension in(M,N) | |
133 double complex out | |
134 dimension out(M/2 + 1, N) | |
135 integer*8 plan | |
136 | |
137 call dfftw_plan_dft_r2c_2d(plan,M,N,in,out,FFTW_ESTIMATE) | |
138 call dfftw_execute_dft_r2c(plan, in, out) | |
139 call dfftw_destroy_plan(plan) | |
140 </pre> | |
141 <p><a name="index-dfftw_005fplan_005fdft_005fr2c_005f2d-349"></a> | |
142 <strong>Important:</strong> Notice that it is the <em>first</em> dimension of the | |
143 complex output array that is cut in half in Fortran, rather than the | |
144 last dimension as in C. This is a consequence of the interface routines | |
145 reversing the order of the array dimensions passed to FFTW so that the | |
146 Fortran program can use its ordinary column-major order. | |
147 <a name="index-column_002dmajor-350"></a><a name="index-r2c_002fc2r-multi_002ddimensional-array-format-351"></a> | |
148 <!-- --> | |
149 | |
150 </body></html> | |
151 |