annotate src/fftw-3.3.5/mpi/f03api.sh @ 43:5ea0608b923f

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