there was an #include directive missing
[openmpi-llc.git] / config / f77_get_value_true.m4
blob60836e4a62f03e87269a1224aadba3906d279ba2
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
19 # OMPI_F77_GET_VALUE_TRUE()
20 # -------------------------------------------------------
21 # Determine the value of .TRUE. of this FORTRAN compiler.
22 AC_DEFUN([OMPI_F77_GET_VALUE_TRUE],[
23     # invalidate cache if result came from a run where F77 was disabled
24     if test "$ompi_cv_f77_true_value" = "0" ; then
25         unset ompi_cv_f77_true_value
26     fi
28     AC_CACHE_CHECK([FORTRAN value for .TRUE. logical type],
29         [ompi_cv_f77_true_value],
30         [if test "$1" = "none" -o "$OMPI_WANT_F77_BINDINGS" = "0" ; then
31              ompi_cv_f77_true_value=0
32          else
33              OMPI_F77_MAKE_C_FUNCTION([ompi_print_logical_fn], [print])
35              #
36              # C module
37              # We really need the confdefs.h Header file for
38              # the ompi_fortran_logical_t definition
39              #
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_print_logical_fn(ompi_fortran_logical_t * logical);
57 void $ompi_print_logical_fn(ompi_fortran_logical_t * logical)
59     int result = 0;
60     FILE *f=fopen("conftestval", "w");
61     if (!f) exit(1);
63     if( SIZEOF_INT >= sizeof(ompi_fortran_logical_t) ) {
64         fprintf(f, "%d\n", (int)*logical);
65     } else if (SIZEOF_LONG >= sizeof(ompi_fortran_logical_t) ) {
66         fprintf(f, "%ld\n", (long) *logical);
67     } else {
68         exit(1);
69     }
72 #ifdef __cplusplus
74 #endif
75 EOF
77              cat > conftestf.f <<EOF
78       program main
79       logical value
80       value=.TRUE.
81       CALL print(value)
82       end
83 EOF
85              #
86              # Try the compilation and run.
87              #
88              OMPI_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c],
89                  [OMPI_LOG_COMMAND([$F77 $FFLAGS -o conftest conftest.o conftestf.f $LDFLAGS $LIBS],
90                       [happy=1], [happy=0])],
91                  [happy=0])
93              if test "$happy" = "0" ; then
94                  AC_MSG_ERROR([Could not determine value of Fotran .TRUE..  Aborting.])
95              fi
97              AS_IF([test "$cross_compiling" = "yes"],
98                  [AC_MSG_ERROR([Can not determine value of .TRUE. when cross-compiling])],
99                  [OMPI_LOG_COMMAND([./conftest],
100                      [ompi_cv_f77_true_value=`sed 's/  *//' conftestval`],
101                      [AC_MSG_ERROR([Could not determine value of Fotran .TRUE..  Aborting.])])])
102          fi])
104     AC_DEFINE_UNQUOTED([OMPI_FORTRAN_VALUE_TRUE], 
105         [$ompi_cv_f77_true_value],
106         [Fortran value for LOGICAL .TRUE. value])
108     unset happy ompi_print_logical_fn
109     /bin/rm -f conftest*
110 ])dnl