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