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