annotate src/fftw-3.3.3/doc/f77_wisdom.f @ 169:223a55898ab9 tip default

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