comparison src/fftw-3.3.8/doc/f77_wisdom.f @ 167:bd3cc4d1df30

Add FFTW 3.3.8 source, and a Linux build
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 19 Nov 2019 14:52:55 +0000
parents
children
comparison
equal deleted inserted replaced
166:cbd6d7e562c7 167:bd3cc4d1df30
1 c Copyright (c) 2003, 2007-14 Matteo Frigo
2 c Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
3 c
4 c This program is free software; you can redistribute it and/or modify
5 c it under the terms of the GNU General Public License as published by
6 c the Free Software Foundation; either version 2 of the License, or
7 c (at your option) any later version.
8 c
9 c This program is distributed in the hope that it will be useful,
10 c but WITHOUT ANY WARRANTY; without even the implied warranty of
11 c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 c GNU General Public License for more details.
13 c
14 c You should have received a copy of the GNU General Public License
15 c along with this program; if not, write to the Free Software
16 c Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 c
18 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
19 c
20 c This is an example implementation of Fortran wisdom export/import
21 c to/from a Fortran unit (file), exploiting the generic
22 c dfftw_export_wisdom/dfftw_import_wisdom functions.
23 c
24 c We cannot compile this file into the FFTW library itself, lest all
25 c FFTW-calling programs be required to link to the Fortran I/O
26 c libraries.
27 c
28 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
29
30 c Strictly speaking, the '$' format specifier, which allows us to
31 c write a character without a trailing newline, is not standard F77.
32 c However, it seems to be a nearly universal extension.
33 subroutine write_char(c, iunit)
34 character c
35 integer iunit
36 write(iunit,321) c
37 321 format(a,$)
38 end
39
40 subroutine export_wisdom_to_file(iunit)
41 integer iunit
42 external write_char
43 call dfftw_export_wisdom(write_char, iunit)
44 end
45
46 c Fortran 77 does not have any portable way to read an arbitrary
47 c file one character at a time. The best alternative seems to be to
48 c read a whole line into a buffer, since for fftw-exported wisdom we
49 c can bound the line length. (If the file contains longer lines,
50 c then the lines will be truncated and the wisdom import should
51 c simply fail.) Ugh.
52 subroutine read_char(ic, iunit)
53 integer ic
54 integer iunit
55 character*256 buf
56 save buf
57 integer ibuf
58 data ibuf/257/
59 save ibuf
60 if (ibuf .lt. 257) then
61 ic = ichar(buf(ibuf:ibuf))
62 ibuf = ibuf + 1
63 return
64 endif
65 read(iunit,123,end=666) buf
66 ic = ichar(buf(1:1))
67 ibuf = 2
68 return
69 666 ic = -1
70 ibuf = 257
71 123 format(a256)
72 end
73
74 subroutine import_wisdom_from_file(isuccess, iunit)
75 integer isuccess
76 integer iunit
77 external read_char
78 call dfftw_import_wisdom(isuccess, read_char, iunit)
79 end