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