annotate src/fftw-3.3.8/mpi/f03api.sh @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents d0c2a83c1364
children
rev   line source
Chris@82 1 #! /bin/sh
Chris@82 2
Chris@82 3 # Script to generate Fortran 2003 interface declarations for FFTW's MPI
Chris@82 4 # interface from the fftw3-mpi.h header file.
Chris@82 5
Chris@82 6 # This is designed so that the Fortran caller can do:
Chris@82 7 # use, intrinsic :: iso_c_binding
Chris@82 8 # implicit none
Chris@82 9 # include 'fftw3-mpi.f03'
Chris@82 10 # and then call the C FFTW MPI functions directly, with type checking.
Chris@82 11 #
Chris@82 12 # One caveat: because there is no standard way to conver MPI_Comm objects
Chris@82 13 # from Fortran (= integer) to C (= opaque type), the Fortran interface
Chris@82 14 # technically calls C wrapper functions (also auto-generated) which
Chris@82 15 # call MPI_Comm_f2c to convert the communicators as needed.
Chris@82 16
Chris@82 17 echo "! Generated automatically. DO NOT EDIT!"
Chris@82 18 echo
Chris@82 19
Chris@82 20 echo " include 'fftw3.f03'"
Chris@82 21 echo
Chris@82 22
Chris@82 23 # Extract constants
Chris@82 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@82 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@82 26
Chris@82 27 # Extract function declarations
Chris@82 28 for p in $*; do
Chris@82 29 if test "$p" = "d"; then p=""; fi
Chris@82 30
Chris@82 31 echo
Chris@82 32 cat <<EOF
Chris@82 33 type, bind(C) :: fftw${p}_mpi_ddim
Chris@82 34 integer(C_INTPTR_T) n, ib, ob
Chris@82 35 end type fftw${p}_mpi_ddim
Chris@82 36 EOF
Chris@82 37
Chris@82 38 echo
Chris@82 39 echo " interface"
Chris@82 40 grep -v 'mpi.h' fftw3-mpi.h | gcc -I../api -D__GNUC__=5 -D__i386__ -E - |grep "fftw${p}_mpi_init" |tr ';' '\n' | perl ../api/genf03.pl
Chris@82 41 echo " end interface"
Chris@82 42
Chris@82 43 done