there was an #include directive missing
[openmpi-llc.git] / config / ompi_setup_f90.m4
blob7111c35a5bbb0c7ca110b449c321572b3cd1af1f
1 dnl -*- shell-script -*-
2 dnl
3 dnl Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
4 dnl                         University Research and Technology
5 dnl                         Corporation.  All rights reserved.
6 dnl Copyright (c) 2004-2005 The University of Tennessee and The University
7 dnl                         of Tennessee Research Foundation.  All rights
8 dnl                         reserved.
9 dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
10 dnl                         University of Stuttgart.  All rights reserved.
11 dnl Copyright (c) 2004-2005 The Regents of the University of California.
12 dnl                         All rights reserved.
13 dnl $COPYRIGHT$
14 dnl 
15 dnl Additional copyrights may follow
16 dnl 
17 dnl $HEADER$
18 dnl
19 dnl OMPI_SETUP_F90
20 dnl
21 dnl sets:
22 dnl  F90                   : full pathname to compiler
23 dnl  BASEF90               : compiler name (no path)
24 dnl  OMPI_WANT_F90_BINDINGS : (actually set by ompi_configure_options, may be
25 dnl                          redefined here)
26 dnl  FC                    : Same as F90.  Side effect of AC_PROG_FC.  Should
27 dnl                          not be used
28 dnl defines:
29 dnl  OMPI_F90               : same as F90
30 dnl  OMPI_WANT_F90_BINDINGS :
31 dnl am_conditional:
32 dnl  OMPI_WANT_F90_BINDINGS :
34 AC_DEFUN([OMPI_SETUP_F90],[
36 # Modularize this setup so that sub-configure.in scripts can use this
37 # same setup code.
39 ompi_show_subtitle "Fortran 90/95 compiler" 
41 if test "$OMPI_WANT_F77_BINDINGS" = "0" ; then
42     AC_MSG_WARN([*** Fortran 90/95 bindings implicitly disabled (because])
43     AC_MSG_WARN([*** Fortran 77 bindings were disabled)])
45     OMPI_WANT_F90_BINDINGS=0
46     OMPI_F90="none"
47     BASEF90="none"
48     OMPI_F90_ABSOLUTE="none"
49     if test "$enable_f90" = "yes"; then
50         AC_MSG_WARN([*** but --enable-f90 was explicitly specified])
51         AC_MSG_ERROR([Cannot continue])
52     fi
53 elif test "$OMPI_WANT_F90_BINDINGS" = "0" ; then
54     AC_MSG_WARN([*** Fortran 90/95 bindings disabled by user])
55     OMPI_WANT_F90_BINDINGS=0
56     OMPI_F90="none"
57     BASEF90="none"
58     OMPI_F90_ABSOLUTE="none"
59 else
61     #
62     # Check for the compiler
63     #
64     # Note that we don't actually *use* the fortran compiler to build
65     # anything in OMPI; it's only used here in configure to find out
66     # symbol conventions, type sizes, etc.  We also pass it down to
67     # the wrapper compiler mpif90.
68     #
69     # Note that AC_PROG_FC will look for *any* fortran compiler, and
70     # we don't want it to find an F77 compiler.  The AC docs don't
71     # recommend using the "dialect" feature of AC_PROG_FC (and you can
72     # only look for one of Fortran 90 or 95 -- not both), so instead
73     # use the optional first parameter and steal the list of Fortran
74     # compilers (excluding the f77 compiler names) from AC's default
75     # list of 95 and 90 compilers and use it here.
76     #
78     ompi_fcflags_save="$FCFLAGS"
79     AC_PROG_FC([gfortran f95 fort xlf95 ifort ifc efc pgf95 lf95 f90 xlf90 pgf90 epcf90])
80     FCFLAGS="$ompi_fcflags_save"
81     if test -z "$FC"; then
82         AC_MSG_WARN([*** Fortran 90/95 bindings disabled (could not find compiler)])
83         OMPI_WANT_F90_BINDINGS=0
84         OMPI_F90="none"
85         BASEF90="none"
86         OMPI_F90_ABSOLUTE="none"
87     else
88         OMPI_WANT_F90_BINDINGS=1
89         OMPI_F90="$FC"
90         BASEF90="`basename $FC`"
91         OMPI_F90_ABSOLUTE="`which $FC`"
92     fi
94 # make sure the compiler actually works, if not cross-compiling
95 # Don't just use the AC macro so that we can have a pretty
96 # message.
97 AS_IF([test $OMPI_WANT_F90_BINDINGS -eq 1],
98        [OMPI_CHECK_COMPILER_WORKS([Fortran], [], [], 
99            [AC_MSG_ERROR([Could not run a simple Fortran program.  Aborting.])])])
101 # check to see if the F77 and F90 compilers are compatible
102 AS_IF([test $OMPI_WANT_F90_BINDINGS -eq 1],
103     [AC_MSG_CHECKING([whether $OMPI_F77 and $OMPI_F90 compilers are compatible])
104      OMPI_INTL_F90_F77_INTERACTION([fortran_goodness=1], [fortran_goodness=0])
105      if test "$fortran_goodness" = "0" ; then
106          AC_MSG_RESULT([no])
107          AC_MSG_WARN([*** Fortran 77 and Fortran 90 compilers are not link compatible])
108          AC_MSG_WARN([*** Disabling MPI Fortran 90/95 bindings])
109          OMPI_WANT_F90_BINDINGS=0
110      else
111          AC_MSG_RESULT([yes])
112      fi
115 # if we're still good, then save the extra file types.  Do this last
116 # because it implies tests that should be invoked by the above tests
117 # (e.g., running the fortran compiler).
118 AS_IF([test $OMPI_WANT_F90_BINDINGS -eq 1],
119        [AC_LANG_PUSH(Fortran)
120         AC_FC_SRCEXT(f)
121         AC_FC_SRCEXT(f90)
122         AC_LANG_POP(Fortran)])
124 # All done -- save values
125 AC_DEFINE_UNQUOTED(OMPI_WANT_F90_BINDINGS, $OMPI_WANT_F90_BINDINGS,
126     [Whether we want the MPI f90 bindings or not])
127 AC_DEFINE_UNQUOTED(OMPI_F90, "$OMPI_F90", [OMPI underlying F90 compiler])
128 AM_CONDITIONAL(OMPI_WANT_F90_BINDINGS, test "$OMPI_WANT_F90_BINDINGS" = "1")
129 AC_SUBST(OMPI_F90_ABSOLUTE)
130 unset fortran_goodness
133 #############################################################################
135 AC_DEFUN([OMPI_INTL_F90_F77_INTERACTION], [
136 # make sure that we can combine F90 and F77 code
137 AC_LANG_PUSH(Fortran)
138 # Fortran module
139 cat > conftestf77.f <<EOF
140         subroutine Conf1_test()
141         end
143 cat > conftestf90.f <<EOF
144         program main
145         call Conf1_test()
146         end
149 # Try the compile
150 OMPI_LOG_COMMAND(
151     [$OMPI_F90 $FCFLAGS $FCFLAGS_f -c conftestf90.f],
152     OMPI_LOG_COMMAND(
153         [$OMPI_F77 $FFLAGS -c conftestf77.f],
154         OMPI_LOG_COMMAND(
155             [$OMPI_F90 $FCFLAGS -o conftest conftestf90.o conftestf77.o $LIBS],
156             [HAPPY=1],
157             [HAPPY=0]),
158         [HAPPY=0]),
159     [HAPPY=0])
161 if test "$HAPPY" = "1"; then
162    $1
163 else
164     OMPI_LOG_MSG([here is the F77 program:], 1)
165     OMPI_LOG_FILE([conftestf77.f])
166     OMPI_LOG_MSG([here is the F90 program:], 1)
167     OMPI_LOG_FILE([conftestf90.f])
168     $2
171 unset HAPPY ompi_conftest_h
172 /bin/rm -f conftest*
174 AC_LANG_POP(Fortran)
175 ])dnl