File: ax_prog_f77_mpi.m4

package info (click to toggle)
med-fichier 4.0.0%2Brepack-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 55,660 kB
  • sloc: cpp: 679,525; ansic: 72,977; python: 37,983; fortran: 12,925; sh: 6,821; f90: 5,531; makefile: 5,136; tcl: 216; xml: 173
file content (185 lines) | stat: -rw-r--r-- 7,181 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# ===========================================================================
#      http://www.gnu.org/software/autoconf-archive/ax_prog_f77_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_PROG_F77_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
#
# DESCRIPTION
#
#   This macro tries to find out how to compile Fortran77 programs that use
#   MPI (Message Passing Interface), a standard API for parallel process
#   communication (see http://www-unix.mcs.anl.gov/mpi/).  The macro has to
#   be used instead of the standard macro AC_PROG_F77 and will replace the
#   standard variable F77 with the found compiler.
#
#   MPI-WANTED-TEST is used to test whether MPI is actually wanted by the
#   user. If MPI-WANTED_TEST is omitted or if it succeeds, the macro will
#   try to find out how to use MPI, if it fails, the macro will call
#   AC_PROG_CC to find a standard C compiler instead.
#
#   When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not found
#   (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is executed. If
#   ACTION-IF-FOUND is not set, the macro will define HAVE_MPI.
#
#   The following example demonstrates usage of the macro:
#
#     # If --with-mpi=auto is used, try to find MPI, but use standard F77 compiler if it is not found.
#     # If --with-mpi=yes is used, try to find MPI and fail if it isn't found.
#     # If --with-mpi=no is used, use a standard F77 compiler instead.
#     AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
#         [compile with MPI (parallelization) support. If none is found,
#         MPI is not used. Default: auto])
#     ],,[with_mpi=auto])
#
#     AX_PROG_F77_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
#       use_mpi=no
#       if test x"$with_mpi" = xyes; then
#         AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
#       else
#         AC_MSG_WARN([No MPI compiler found, won't use MPI.])
#       fi
#     ])
#
# LICENSE
#
#   Copyright (c) 2010,2011 Olaf Lenz <olenz@icp.uni-stuttgart.de>
#
#   This program is free software: you can redistribute it and/or modify it
#   under the terms of the GNU General Public License as published by the
#   Free Software Foundation, either version 3 of the License, or (at your
#   option) any later version.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
#   Public License for more details.
#
#   You should have received a copy of the GNU General Public License along
#   with this program. If not, see <http://www.gnu.org/licenses/>.
#
#   As a special exception, the respective Autoconf Macro's copyright owner
#   gives unlimited permission to copy, distribute and modify the configure
#   scripts that are the output of Autoconf when processing the Macro. You
#   need not follow the terms of the GNU General Public License when using
#   or distributing such scripts, even though portions of the text of the
#   Macro appear in them. The GNU General Public License (GPL) does govern
#   all other use of the material that constitutes the Autoconf Macro.
#
#   This special exception to the GPL applies to versions of the Autoconf
#   Macro released by the Autoconf Archive. When you make and distribute a
#   modified version of the Autoconf Macro, you may extend this special
#   exception to the GPL to apply to your modified version as well.

#serial 2

AC_DEFUN([AX_PROG_F77_MPI], [
AC_PREREQ(2.50)
AC_BEFORE([$0],[AC_PROG_F77])

# Check for compiler
# Needs to be split off into an extra macro to ensure right expansion
# order.
AC_REQUIRE([_AX_PROG_F77_MPI],[_AX_PROG_F77_MPI([$1])])

test x"$enable_fortran" = xyes && \
AS_IF([test x"$_ax_prog_f77_mpi_mpi_wanted" = xno],
  [ _ax_prog_f77_mpi_mpi_found=no ],
  [
    AC_LANG_PUSH([Fortran 77])

    # test whether MPI_INIT is available
    # We do not use AC_SEARCH_LIBS here, as it caches its outcome and
    # thus disallows corresponding calls in the other AX_PROG_*_MPI
    # macros.
    for lib in NONE fmpi fmpich; do
      save_LIBS=$LIBS
      if test x"$lib" = xNONE; then
        AC_MSG_CHECKING([for function MPI_INIT])
      else
        AC_MSG_CHECKING([for function MPI_INIT in -l$lib])
        LIBS="-l$lib $LIBS"
      fi
      AC_LINK_IFELSE([AC_LANG_CALL([],[MPI_INIT])],
        [ _ax_prog_f77_mpi_mpi_found=yes ],
        [ _ax_prog_f77_mpi_mpi_found=no ])
      AC_MSG_RESULT($_ax_prog_f77_mpi_mpi_found)
      if test "x$_ax_prog_f77_mpi_mpi_found" = "xyes"; then
        break;
      fi
      LIBS=$save_LIBS
    done

    # Check for header
    AS_IF([test x"$_ax_prog_f77_mpi_mpi_found" = xyes], [
      AC_MSG_CHECKING([for mpif.h])
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
      include 'mpif.h'
]])],
        [ AC_MSG_RESULT(yes)],
        [ AC_MSG_RESULT(no)
	  _ax_prog_f77_mpi_mpi_found=no
      ])
    ])
    AC_LANG_POP([Fortran 77])
])

# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
AS_IF([test x"$_ax_prog_f77_mpi_mpi_found" = xyes], [
        ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
        :
],[
        $3
        :
])

])dnl AX_PROG_F77_MPI

dnl _AX_PROG_F77_MPI is an internal macro required by AX_PROG_F77_MPI.
dnl To ensure the right expansion order, the main function AX_PROG_F77_MPI
dnl has to be split into two parts. This part looks for the MPI
dnl compiler, while the other one tests whether an MPI program can be
dnl compiled.
dnl
dnl Known Fortran 77 compilers:
dnl  af77         Apogee F77 compiler for Intergraph hardware running CLIX
dnl  blrts_xlf    IBM BlueGene/L F77 cross-compiler
dnl  cf77         native F77 compiler under older Crays (prefer over fort77)
dnl  f77          generic compiler names
dnl  fl32         Microsoft Fortran 77 "PowerStation" compiler
dnl  fort77       native F77 compiler under HP-UX (and some older Crays)
dnl  frt          Fujitsu F77 compiler
dnl  g77          GNU Fortran 77 compiler
dnl  pgf77        Portland Group F77 compiler
dnl  xlf          IBM (AIX) F77 compiler
dnl  pathf77      PathScale
dnl
AC_DEFUN([__AX_PROG_F77_MPI], [
  AC_ARG_VAR(MPIF77,[MPI Fortran77 compiler command])
  ifelse([$1],,[_ax_prog_f77_mpi_mpi_wanted=yes],[
    AC_MSG_CHECKING([whether to compile F77 using MPI])
    if $1; then
      _ax_prog_f77_mpi_mpi_wanted=yes
    else
      _ax_prog_f77_mpi_mpi_wanted=no
    fi
    AC_MSG_RESULT($_ax_prog_f77_mpi_mpi_wanted)
  ])
  if test x"$_ax_prog_f77_mpi_mpi_wanted" = xyes && test x"$enable_fortran" = xyes; then
    if test -z "$F77" && test -n "$MPIF77"; then
      F77="$MPIF77"
    elif test -z "$F77"; then
      AC_CHECK_TOOLS([F77], [mpif77 hf77 mpxlf_r mpxlf mpifrt mpf77 cmpifc xlf f77 frt pgf77 pathf77 g77 cf77 fort77 fl32 af77])
    fi
  fi
])dnl _AX_PROG_F77_MPI

AC_DEFUN([_AX_PROG_F77_MPI], [
  AC_REQUIRE([__AX_PROG_F77_MPI],[__AX_PROG_F77_MPI([$1])])
#echo "---------F77 3-$enable_fortran----------------------"
  if test x"$enable_fortran" = xyes ; then
    AC_PROG_F77
  fi
#echo "---------F77 4-$enable_fortran----------------------"
])