annotate src/fftw-3.3.5/mpi/f03api.sh @ 169:223a55898ab9 tip default

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