annotate src/fftw-3.3.3/doc/f77_wisdom.f @ 83:ae30d91d2ffe

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