1 | dnl -*- mode: autoconf -*-
|
---|
2 | # ===========================================================================
|
---|
3 | # http://www.gnu.org/software/autoconf-archive/ax_prog_fc_mpi.html
|
---|
4 | # ===========================================================================
|
---|
5 | #
|
---|
6 | # SYNOPSIS
|
---|
7 | #
|
---|
8 | # AX_PROG_FC_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
|
---|
9 | #
|
---|
10 | # DESCRIPTION
|
---|
11 | #
|
---|
12 | # This macro tries to find out how to compile Fortran77 programs
|
---|
13 | # that use MPI (Message Passing Interface), a standard API for
|
---|
14 | # parallel process communication (see
|
---|
15 | # http://www-unix.mcs.anl.gov/mpi/). The macro has to be used
|
---|
16 | # instead of the standard macro AC_PROG_FC and will replace the
|
---|
17 | # standard variable FC with the found compiler.
|
---|
18 | #
|
---|
19 | # MPI-WANTED-TEST is used to test whether MPI is actually wanted by
|
---|
20 | # the user. If MPI-WANTED_TEST is omitted or if it succeeds, the
|
---|
21 | # macro will try to find out how to use MPI, if it fails, the macro
|
---|
22 | # will call AC_PROG_CC to find a standard C compiler instead.
|
---|
23 | #
|
---|
24 | # When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not
|
---|
25 | # found (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is
|
---|
26 | # executed. If ACTION-IF-FOUND is not set, the macro will define
|
---|
27 | # HAVE_MPI.
|
---|
28 | #
|
---|
29 | # EXAMPLE
|
---|
30 | #
|
---|
31 | # # If --with-mpi=auto is used, try to find MPI, but use standard FC
|
---|
32 | # compiler if it is not found.
|
---|
33 | # # If --with-mpi=yes is used, try to find MPI and fail if it isn't
|
---|
34 | # # found.
|
---|
35 | # # If --with-mpi=no is used, use a standard FC compiler instead.
|
---|
36 | # AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
|
---|
37 | # [compile with MPI (parallelization) support. If none is found,
|
---|
38 | # MPI is not used. Default: auto])
|
---|
39 | # ],,[with_mpi=auto])
|
---|
40 | #
|
---|
41 | # AX_PROG_FC_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
|
---|
42 | # use_mpi=no
|
---|
43 | # if test x"$with_mpi" = xyes; then
|
---|
44 | # AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
|
---|
45 | # else
|
---|
46 | # AC_MSG_WARN([No MPI compiler found, won't use MPI.])
|
---|
47 | # fi
|
---|
48 | # ])
|
---|
49 | #
|
---|
50 | # LICENSE
|
---|
51 | #
|
---|
52 | # Copyright (c) 2010,2011 Olaf Lenz <olenz@icp.uni-stuttgart.de>
|
---|
53 | #
|
---|
54 | # This program is free software: you can redistribute it and/or modify it
|
---|
55 | # under the terms of the GNU General Public License as published by the
|
---|
56 | # Free Software Foundation, either version 3 of the License, or (at your
|
---|
57 | # option) any later version.
|
---|
58 | #
|
---|
59 | # This program is distributed in the hope that it will be useful, but
|
---|
60 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
61 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
---|
62 | # Public License for more details.
|
---|
63 | #
|
---|
64 | # You should have received a copy of the GNU General Public License along
|
---|
65 | # with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
66 | #
|
---|
67 | # As a special exception, the respective Autoconf Macro's copyright owner
|
---|
68 | # gives unlimited permission to copy, distribute and modify the configure
|
---|
69 | # scripts that are the output of Autoconf when processing the Macro. You
|
---|
70 | # need not follow the terms of the GNU General Public License when using
|
---|
71 | # or distributing such scripts, even though portions of the text of the
|
---|
72 | # Macro appear in them. The GNU General Public License (GPL) does govern
|
---|
73 | # all other use of the material that constitutes the Autoconf Macro.
|
---|
74 | #
|
---|
75 | # This special exception to the GPL applies to versions of the Autoconf
|
---|
76 | # Macro released by the Autoconf Archive. When you make and distribute a
|
---|
77 | # modified version of the Autoconf Macro, you may extend this special
|
---|
78 | # exception to the GPL to apply to your modified version as well.
|
---|
79 |
|
---|
80 | #serial 1
|
---|
81 |
|
---|
82 | AC_DEFUN([AX_PROG_FC_MPI], [
|
---|
83 | AC_PREREQ(2.50)
|
---|
84 |
|
---|
85 | # Check for compiler
|
---|
86 | # Needs to be split off into an extra macro to ensure right expansion
|
---|
87 | # order.
|
---|
88 | AC_REQUIRE([_AX_PROG_FC_MPI],[_AX_PROG_FC_MPI([$1])])
|
---|
89 |
|
---|
90 | AS_IF([test x"$_ax_prog_fc_mpi_mpi_wanted" = xno],
|
---|
91 | [ _ax_prog_fc_mpi_mpi_found=no ],
|
---|
92 | [
|
---|
93 | AC_LANG_PUSH([Fortran])
|
---|
94 |
|
---|
95 | # test whether MPI_INIT is available
|
---|
96 | # We do not use AC_SEARCH_LIBS here, as it caches its outcome and
|
---|
97 | # thus disallows corresponding calls in the other AX_PROG_*_MPI
|
---|
98 | # macros.
|
---|
99 | for lib in NONE mpichf90 fmpi fmpich mpi_mpifh; do
|
---|
100 | save_LIBS=$LIBS
|
---|
101 | if test x"$lib" = xNONE; then
|
---|
102 | AC_MSG_CHECKING([for function MPI_INIT])
|
---|
103 | else
|
---|
104 | AC_MSG_CHECKING([for function MPI_INIT in -l$lib])
|
---|
105 | LIBS="-l$lib $LIBS"
|
---|
106 | fi
|
---|
107 | AC_LINK_IFELSE([AC_LANG_CALL([],[MPI_INIT])],
|
---|
108 | [ _ax_prog_fc_mpi_mpi_found=yes ],
|
---|
109 | [ _ax_prog_fc_mpi_mpi_found=no ])
|
---|
110 | AC_MSG_RESULT($_ax_prog_fc_mpi_mpi_found)
|
---|
111 | if test "x$_ax_prog_fc_mpi_mpi_found" = "xyes"; then
|
---|
112 | break;
|
---|
113 | fi
|
---|
114 | LIBS=$save_LIBS
|
---|
115 | done
|
---|
116 |
|
---|
117 | # Check for header
|
---|
118 | AS_IF([test x"$_ax_prog_fc_mpi_mpi_found" = xyes], [
|
---|
119 | AC_MSG_CHECKING([for mpif.h])
|
---|
120 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
|
---|
121 | include 'mpif.h'
|
---|
122 | ]])],
|
---|
123 | [ AC_MSG_RESULT(yes)],
|
---|
124 | [ AC_MSG_RESULT(no)
|
---|
125 | _ax_prog_fc_mpi_mpi_found=no
|
---|
126 | ])
|
---|
127 | ])
|
---|
128 | AC_LANG_POP([Fortran])
|
---|
129 | ])
|
---|
130 |
|
---|
131 | # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
---|
132 | AS_IF([test x"$_ax_prog_fc_mpi_mpi_found" = xyes], [
|
---|
133 | ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
|
---|
134 | :
|
---|
135 | ],[
|
---|
136 | $3
|
---|
137 | :
|
---|
138 | ])
|
---|
139 |
|
---|
140 | ])dnl AX_PROG_FC_MPI
|
---|
141 |
|
---|
142 | dnl _AX_PROG_FC_MPI is an internal macro required by AX_PROG_FC_MPI.
|
---|
143 | dnl To ensure the right expansion order, the main function AX_PROG_FC_MPI
|
---|
144 | dnl has to be split into two parts. This part looks for the MPI
|
---|
145 | dnl compiler, while the other one tests whether an MPI program can be
|
---|
146 | dnl compiled.
|
---|
147 | dnl
|
---|
148 | AC_DEFUN([_AX_PROG_FC_MPI], [
|
---|
149 | AC_ARG_VAR(MPIFC,[MPI Fortran compiler command])
|
---|
150 | ifelse([$1],,[_ax_prog_fc_mpi_mpi_wanted=yes],[
|
---|
151 | AC_MSG_CHECKING([whether to compile using MPI])
|
---|
152 | if $1; then
|
---|
153 | _ax_prog_fc_mpi_mpi_wanted=yes
|
---|
154 | else
|
---|
155 | _ax_prog_fc_mpi_mpi_wanted=no
|
---|
156 | fi
|
---|
157 | AC_MSG_RESULT($_ax_prog_fc_mpi_mpi_wanted)
|
---|
158 | ])
|
---|
159 | if test x"$_ax_prog_fc_mpi_mpi_wanted" = xyes; then
|
---|
160 | if test -z "$FC" && test -n "$MPIFC"; then
|
---|
161 | FC="$MPIFC"
|
---|
162 | else
|
---|
163 | AC_CHECK_TOOLS([FC], [mpif95 mpxlf95_r mpxlf95 ftn mpif90 mpxlf90_r mpxlf90 mpf90 cmpif90c sxmpif90 mpif77 hf77 mpxlf_r mpxlf mpifrt mpf77 cmpifc xlf95 pgf95 pathf95 ifort g95 f95 fort ifc efc openf95 sunf95 crayftn gfortran lf95 ftn xlf90 f90 pgf90 pghpf pathf90 epcf90 sxf90 openf90 sunf90 xlf f77 frt pgf77 pathf77 g77 cf77 fort77 fl32 af77])
|
---|
164 | fi
|
---|
165 | fi
|
---|
166 | AC_PROG_FC
|
---|
167 | ])dnl _AX_PROG_FC_MPI
|
---|