annotate fft/fftw/fftw-3.3.4/api/f03api.sh @ 40:223f770b5341 kissfft-double tip

Try a double-precision kissfft
author Chris Cannam
date Wed, 07 Sep 2016 10:40:32 +0100
parents 26056e866c29
children
rev   line source
Chris@19 1 #! /bin/sh
Chris@19 2
Chris@19 3 # Script to generate Fortran 2003 interface declarations for FFTW from
Chris@19 4 # the fftw3.h header file.
Chris@19 5
Chris@19 6 # This is designed so that the Fortran caller can do:
Chris@19 7 # use, intrinsic :: iso_c_binding
Chris@19 8 # implicit none
Chris@19 9 # include 'fftw3.f03'
Chris@19 10 # and then call the C FFTW functions directly, with type checking.
Chris@19 11
Chris@19 12 echo "! Generated automatically. DO NOT EDIT!"
Chris@19 13 echo
Chris@19 14
Chris@19 15 # C_FFTW_R2R_KIND is determined by configure and inserted by the Makefile
Chris@19 16 # echo " integer, parameter :: C_FFTW_R2R_KIND = @C_FFTW_R2R_KIND@"
Chris@19 17
Chris@19 18 # Extract constants
Chris@19 19 perl -pe 's/([A-Z0-9_]+)=([+-]?[0-9]+)/\n integer\(C_INT\), parameter :: \1 = \2\n/g' < fftw3.h | grep 'integer(C_INT)'
Chris@19 20 perl -pe 's/#define +([A-Z0-9_]+) +\(([+-]?[0-9]+)U?\)/\n integer\(C_INT\), parameter :: \1 = \2\n/g' < fftw3.h | grep 'integer(C_INT)'
Chris@19 21 perl -pe 'if (/#define +([A-Z0-9_]+) +\(([0-9]+)U? *<< *([0-9]+)\)/) { print "\n integer\(C_INT\), parameter :: $1 = ",$2 << $3,"\n"; }' < fftw3.h | grep 'integer(C_INT)'
Chris@19 22
Chris@19 23 # Extract function declarations
Chris@19 24 for p in $*; do
Chris@19 25 if test "$p" = "d"; then p=""; fi
Chris@19 26
Chris@19 27 echo
Chris@19 28 cat <<EOF
Chris@19 29 type, bind(C) :: fftw${p}_iodim
Chris@19 30 integer(C_INT) n, is, os
Chris@19 31 end type fftw${p}_iodim
Chris@19 32 type, bind(C) :: fftw${p}_iodim64
Chris@19 33 integer(C_INTPTR_T) n, is, os
Chris@19 34 end type fftw${p}_iodim64
Chris@19 35 EOF
Chris@19 36
Chris@19 37 echo
Chris@19 38 echo " interface"
Chris@19 39 gcc -D__GNUC__=5 -D__i386__ -E fftw3.h |grep "fftw${p}_plan_dft" |tr ';' '\n' | grep -v "fftw${p}_execute(" | perl genf03.pl
Chris@19 40 echo " end interface"
Chris@19 41
Chris@19 42 done