annotate fft/fftw/fftw-3.3.4/mpi/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's MPI
Chris@19 4 # interface from the fftw3-mpi.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-mpi.f03'
Chris@19 10 # and then call the C FFTW MPI functions directly, with type checking.
Chris@19 11 #
Chris@19 12 # One caveat: because there is no standard way to conver MPI_Comm objects
Chris@19 13 # from Fortran (= integer) to C (= opaque type), the Fortran interface
Chris@19 14 # technically calls C wrapper functions (also auto-generated) which
Chris@19 15 # call MPI_Comm_f2c to convert the communicators as needed.
Chris@19 16
Chris@19 17 echo "! Generated automatically. DO NOT EDIT!"
Chris@19 18 echo
Chris@19 19
Chris@19 20 echo " include 'fftw3.f03'"
Chris@19 21 echo
Chris@19 22
Chris@19 23 # Extract constants
Chris@19 24 perl -pe 's/#define +([A-Z0-9_]+) +\(([+-]?[0-9]+)U?\)/\n integer\(C_INTPTR_T\), parameter :: \1 = \2\n/g' < fftw3-mpi.h | grep 'integer(C_INTPTR_T)'
Chris@19 25 perl -pe 'if (/#define +([A-Z0-9_]+) +\(([0-9]+)U? *<< *([0-9]+)\)/) { print "\n integer\(C_INT\), parameter :: $1 = ",$2 << $3,"\n"; }' < fftw3-mpi.h | grep 'integer(C_INT)'
Chris@19 26
Chris@19 27 # Extract function declarations
Chris@19 28 for p in $*; do
Chris@19 29 if test "$p" = "d"; then p=""; fi
Chris@19 30
Chris@19 31 echo
Chris@19 32 cat <<EOF
Chris@19 33 type, bind(C) :: fftw${p}_mpi_ddim
Chris@19 34 integer(C_INTPTR_T) n, ib, ob
Chris@19 35 end type fftw${p}_mpi_ddim
Chris@19 36 EOF
Chris@19 37
Chris@19 38 echo
Chris@19 39 echo " interface"
Chris@19 40 grep -v 'mpi.h' fftw3-mpi.h | gcc -D__GNUC__=5 -D__i386__ -E - |grep "fftw${p}_mpi_init" |tr ';' '\n' | perl ../api/genf03.pl
Chris@19 41 echo " end interface"
Chris@19 42
Chris@19 43 done