Mercurial > hg > sv-dependency-builds
annotate src/fftw-3.3.3/mpi/f03api.sh @ 10:37bf6b4a2645
Add FFTW3
author | Chris Cannam |
---|---|
date | Wed, 20 Mar 2013 15:35:50 +0000 |
parents | |
children |
rev | line source |
---|---|
Chris@10 | 1 #! /bin/sh |
Chris@10 | 2 |
Chris@10 | 3 # Script to generate Fortran 2003 interface declarations for FFTW's MPI |
Chris@10 | 4 # interface from the fftw3-mpi.h header file. |
Chris@10 | 5 |
Chris@10 | 6 # This is designed so that the Fortran caller can do: |
Chris@10 | 7 # use, intrinsic :: iso_c_binding |
Chris@10 | 8 # implicit none |
Chris@10 | 9 # include 'fftw3-mpi.f03' |
Chris@10 | 10 # and then call the C FFTW MPI functions directly, with type checking. |
Chris@10 | 11 # |
Chris@10 | 12 # One caveat: because there is no standard way to conver MPI_Comm objects |
Chris@10 | 13 # from Fortran (= integer) to C (= opaque type), the Fortran interface |
Chris@10 | 14 # technically calls C wrapper functions (also auto-generated) which |
Chris@10 | 15 # call MPI_Comm_f2c to convert the communicators as needed. |
Chris@10 | 16 |
Chris@10 | 17 echo "! Generated automatically. DO NOT EDIT!" |
Chris@10 | 18 echo |
Chris@10 | 19 |
Chris@10 | 20 echo " include 'fftw3.f03'" |
Chris@10 | 21 echo |
Chris@10 | 22 |
Chris@10 | 23 # Extract constants |
Chris@10 | 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@10 | 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@10 | 26 |
Chris@10 | 27 # Extract function declarations |
Chris@10 | 28 for p in $*; do |
Chris@10 | 29 if test "$p" = "d"; then p=""; fi |
Chris@10 | 30 |
Chris@10 | 31 echo |
Chris@10 | 32 cat <<EOF |
Chris@10 | 33 type, bind(C) :: fftw${p}_mpi_ddim |
Chris@10 | 34 integer(C_INTPTR_T) n, ib, ob |
Chris@10 | 35 end type fftw${p}_mpi_ddim |
Chris@10 | 36 EOF |
Chris@10 | 37 |
Chris@10 | 38 echo |
Chris@10 | 39 echo " interface" |
Chris@10 | 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@10 | 41 echo " end interface" |
Chris@10 | 42 |
Chris@10 | 43 done |