there was an #include directive missing
[openmpi-llc.git] / config / f77_check_logical_array.m4
blob0971dd83bda2882f07b01c5871a1d615d896e0de
1 dnl -*- shell-script -*-
2 dnl
3 dnl Copyright (c) 2004-2005 The Trustees of Indiana University.
4 dnl                         All rights reserved.
5 dnl Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
6 dnl                         All rights reserved.
7 dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
8 dnl                         University of Stuttgart.  All rights reserved.
9 dnl Copyright (c) 2004-2005 The Regents of the University of California.
10 dnl                         All rights reserved.
11 dnl $COPYRIGHT$
12 dnl 
13 dnl Additional copyrights may follow
14 dnl 
15 dnl $HEADER$
16 dnl
18 AC_DEFUN([OMPI_F77_CHECK_LOGICAL_ARRAY],[
19     AC_CACHE_CHECK([for correct handling of FORTRAN logical arrays],
20         [ompi_cv_f77_logical_array_correct],
21         [if test "$1" = "none" -o "$OMPI_WANT_F77_BINDINGS" = "0"; then
22              ompi_cv_f77_logical_array_correct=yes
23          else
24              OMPI_F77_MAKE_C_FUNCTION([ompi_check_logical_fn], [check])
26              # Fortran module
27              cat > conftestf.f <<EOF
28         program check_logical_array
29         external check
30         logical l(2)
31         l(1)=.FALSE.
32         l(2)=.TRUE.
33         CALL check(l)
34         end
35 EOF
37              # C module
38              # We really need the confdefs.h Header file for 
39              # the ompi_fortran_logical_t definition
40              if test \! -f confdefs.h ; then
41                  AC_MSG_WARN([*** Problem running configure test!])
42                  AC_MSG_WARN([*** Cannot find confdefs.h file for config test])
43                  AC_MSG_WARN([*** See config.log for details.])
44                  AC_MSG_ERROR([*** Cannot continue.])
45              fi
47              cat > conftest.c <<EOF
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include "confdefs.h"
52 #ifdef __cplusplus
53   extern "C" {
54 #endif
55 void $ompi_check_logical_fn(ompi_fortran_logical_t * logical);
57 void $ompi_check_logical_fn(ompi_fortran_logical_t * logical)
59     int result = 0;
60     FILE *f=fopen("conftestval", "w");
61     if (!f) exit(1);
63     if (logical[[0]] == 0 &&
64         logical[[1]] == $ompi_cv_f77_true_value)
65       result = 1;
66     fprintf(f, "%d\n", result);
68 #ifdef __cplusplus
70 #endif
71 EOF
73              # Try the compilation and run.  Can't use AC_TRY_RUN
74              # because it's two module files.
75              OMPI_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c],
76                  [OMPI_LOG_COMMAND([$F77 $FFLAGS conftestf.f conftest.o -o conftest $LDFLAGS $LIBS],
77                      [happy=1], [happy=0])],
78                  [happy=0])
79              if test "$happy" = "0" ; then
80                  AC_MSG_ERROR([Error determining if arrays of logical values work properly.])
81              fi
83              AS_IF([test "$cross_compiling" = "yes"], 
84                  [ # assume we're ok
85                   ompi_cv_f77_logical_array_correct=yes],
86                  [OMPI_LOG_COMMAND([./conftest],
87                       [if test "`cat conftestval`" = "1" ; then
88                            ompi_cv_f77_logical_array_correct=yes
89                        else
90                            ompi_cv_f77_logical_array_correct=no
91                        fi],             
92                       [ompi_cv_f77_logical_array_correct=no])])
93     fi])
95     if test "$ompi_cv_f77_logical_array_correct" = "no" ; then
96         AC_MSG_ERROR([Error determining if arrays of logical values work properly.])
97     fi
99     unset happy ompi_check_logical_fn
100     /bin/rm -f conftest*
101 ])dnl