1dnl -*- shell-script -*- 2dnl 3dnl Copyright (c) 2004-2005 The Trustees of Indiana University. 4dnl All rights reserved. 5dnl Copyright (c) 2004-2005 The Trustees of the University of Tennessee. 6dnl All rights reserved. 7dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 8dnl University of Stuttgart. All rights reserved. 9dnl Copyright (c) 2004-2005 The Regents of the University of California. 10dnl All rights reserved. 11dnl Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. 12dnl Copyright (c) 2015 Research Organization for Information Science 13dnl and Technology (RIST). All rights reserved. 14dnl $COPYRIGHT$ 15dnl 16dnl Additional copyrights may follow 17dnl 18dnl $HEADER$ 19dnl 20 21 22# OMPI_FORTRAN_GET_VALUE_TRUE() 23# ------------------------------------------------------- 24# Determine the value of .TRUE. of this Fortran compiler. 25AC_DEFUN([OMPI_FORTRAN_GET_VALUE_TRUE],[ 26 # invalidate cache if result came from a run where FORTRAN was disabled 27 if test "$ompi_cv_fortran_true_value" = "0" ; then 28 unset ompi_cv_fortran_true_value 29 fi 30 31 AS_VAR_PUSHDEF([fortran_true_var], 32 [ompi_cv_fortran_true_value]) 33 34 AC_CACHE_CHECK([Fortran value for .TRUE. logical type], 35 fortran_true_var, 36 [if test "$1" = "none" || \ 37 test $OMPI_TRY_FORTRAN_BINDINGS -eq $OMPI_FORTRAN_NO_BINDINGS || \ 38 test $ompi_fortran_happy -eq 0 ; then 39 value=77 40 else 41 # 42 # C module 43 # We really need the confdefs.h Header file for 44 # the ompi_fortran_logical_t definition 45 # 46 if test \! -f confdefs.h ; then 47 AC_MSG_WARN([*** Problem running configure test!]) 48 AC_MSG_WARN([*** Cannot find confdefs.h file for config test]) 49 AC_MSG_WARN([*** See config.log for details.]) 50 AC_MSG_ERROR([*** Cannot continue.]) 51 fi 52 53 cat > conftest.c <<EOF 54#include <stdio.h> 55#include <stdlib.h> 56#include "confdefs.h" 57 58#ifdef __cplusplus 59extern "C" { 60#endif 61 62void ompi_print_f(ompi_fortran_logical_t * logical) 63{ 64 FILE *f=fopen("conftestval", "w"); 65 if (!f) exit(1); 66 67 if( SIZEOF_INT >= sizeof(ompi_fortran_logical_t) ) { 68 fprintf(f, "%d\n", (int)*logical); 69 } else if (SIZEOF_LONG >= sizeof(ompi_fortran_logical_t) ) { 70 fprintf(f, "%ld\n", (long) *logical); 71#ifdef HAVE_LONG_LONG 72 } else if (SIZEOF_LONG_LONG >= sizeof(ompi_fortran_logical_t) ) { 73 fprintf(f, "%lld\n", (long long) *logical); 74#endif 75 } else { 76 exit(1); 77 } 78} 79 80void ompi_print(ompi_fortran_logical_t *logical) 81{ ompi_print_f(logical); } 82 83void ompi_print_(ompi_fortran_logical_t *logical) 84{ ompi_print_f(logical); } 85 86void ompi_print__(ompi_fortran_logical_t *logical) 87{ ompi_print_f(logical); } 88 89void OMPI_PRINT(ompi_fortran_logical_t *logical) 90{ ompi_print_f(logical); } 91 92#ifdef __cplusplus 93} 94#endif 95EOF 96 cat > conftestf.f <<EOF 97 program main 98 logical value 99 value=.TRUE. 100 CALL ompi_print(value) 101 end 102EOF 103 104 # 105 # Try the compilation and run. 106 # 107 OPAL_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c], 108 [OPAL_LOG_COMMAND([$FC $FCFLAGS -o conftest conftest.o conftestf.f $LDFLAGS $LIBS], 109 [happy=1], [happy=0])], 110 [happy=0]) 111 112 AS_IF([test $happy -eq 0 && test $ompi_fortran_happy -eq 1], 113 [AC_MSG_ERROR([Could not compile Fortran .TRUE. test. Aborting.]) 114 ]) 115 116 AS_IF([test "$cross_compiling" = "yes"], 117 [AC_MSG_ERROR([Can not determine value of .TRUE. when cross-compiling])], 118 [OPAL_LOG_COMMAND([./conftest], 119 [value=`sed 's/ *//' conftestval`], 120 [AC_MSG_ERROR([Could not determine value of Fotran .TRUE.. Aborting.])])]) 121 fi 122 AS_VAR_SET(fortran_true_var, [$value]) 123 unset value 124 ]) 125 126 AS_VAR_COPY([ompi_fortran_true_value], [fortran_true_var]) 127 AC_DEFINE_UNQUOTED([OMPI_FORTRAN_VALUE_TRUE], 128 [$ompi_fortran_true_value], 129 [Fortran value for LOGICAL .TRUE. value]) 130 AS_VAR_POPDEF([fortran_true_var]) 131 132 unset happy ompi_print_logical_fn 133 rm -rf conftest* 134])dnl 135