cannam@95: #! /bin/sh cannam@95: cannam@95: # Script to generate Fortran 2003 interface declarations for FFTW's MPI cannam@95: # interface from the fftw3-mpi.h header file. cannam@95: cannam@95: # This is designed so that the Fortran caller can do: cannam@95: # use, intrinsic :: iso_c_binding cannam@95: # implicit none cannam@95: # include 'fftw3-mpi.f03' cannam@95: # and then call the C FFTW MPI functions directly, with type checking. cannam@95: # cannam@95: # One caveat: because there is no standard way to conver MPI_Comm objects cannam@95: # from Fortran (= integer) to C (= opaque type), the Fortran interface cannam@95: # technically calls C wrapper functions (also auto-generated) which cannam@95: # call MPI_Comm_f2c to convert the communicators as needed. cannam@95: cannam@95: echo "! Generated automatically. DO NOT EDIT!" cannam@95: echo cannam@95: cannam@95: echo " include 'fftw3.f03'" cannam@95: echo cannam@95: cannam@95: # Extract constants cannam@95: 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)' cannam@95: 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)' cannam@95: cannam@95: # Extract function declarations cannam@95: for p in $*; do cannam@95: if test "$p" = "d"; then p=""; fi cannam@95: cannam@95: echo cannam@95: cat <