From dc788920610a68d759f8bbfc165a68d14642d692 Mon Sep 17 00:00:00 2001
From: Craig E Rasmussen <rasmus@cas.uoregon.edu>
Date: Wed, 2 Feb 2005 00:33:24 +0000
Subject: [PATCH] Added initial versions of f90_get_precision.m4 and
 f90_get_range.m4

This commit was SVN r4260.
---
 config/Makefile.am          |  2 ++
 config/f90_get_precision.m4 | 60 +++++++++++++++++++++++++++++++++++++
 config/f90_get_range.m4     | 60 +++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+)
 create mode 100644 config/f90_get_precision.m4
 create mode 100644 config/f90_get_range.m4

diff --git a/config/Makefile.am b/config/Makefile.am
index 4ebe9cff8f..cfbda6d232 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -27,6 +27,8 @@ EXTRA_DIST = \
         f77_get_sizeof.m4 \
         f90_check_type.m4 \
         f90_get_alignment.m4 \
+        f90_get_precision.m4 \
+        f90_get_range.m4 \
         f90_get_sizeof.m4 \
         mca_acinclude.m4 \
         mca_configure.ac \
diff --git a/config/f90_get_precision.m4 b/config/f90_get_precision.m4
new file mode 100644
index 0000000000..782b02f337
--- /dev/null
+++ b/config/f90_get_precision.m4
@@ -0,0 +1,60 @@
+dnl -*- shell-script -*-
+dnl
+dnl Copyright (c) 2004-2005 The Trustees of Indiana University.
+dnl                         All rights reserved.
+dnl Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
+dnl                         All rights reserved.
+dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
+dnl                         University of Stuttgart.  All rights reserved.
+dnl $COPYRIGHT$
+dnl 
+dnl Additional copyrights may follow
+dnl 
+dnl $HEADER$
+dnl
+
+AC_DEFUN([OMPI_F90_GET_PRECISION],[
+# Determine precision of FORTRAN datatype.
+# First arg is type, 2nd arg is config var to define.
+
+AC_MSG_CHECKING(precision of FORTRAN $1)
+
+cat > conftestf.f90 <<EOF
+program main
+    $1 :: x
+    open(8, file="conftestval")
+    write(8, fmt="(I5)") precision(x)
+    close(8)
+end program
+EOF
+
+#
+# Try the compilation and run.
+#
+
+OMPI_LOG_COMMAND([$FC $FCFLAGS $FCFLAGS_f90 -o conftest conftestf.f90],
+	OMPI_LOG_COMMAND([./conftest], [HAPPY=1], [HAPPY=0]), [HAPPY=0])
+
+ompi_ac_precision=-1
+if test "$HAPPY" = "1" -a -f conftestval; then
+    # get rid of leading spaces for eval assignment
+    ompi_ac_precision=`sed 's/  *//' conftestval`
+    AC_MSG_RESULT([$ompi_ac_precision])
+    if test -n "$2"; then
+	eval "$2=$ompi_ac_precision"
+    fi
+else
+    AC_MSG_RESULT([unknown])
+
+    OMPI_LOG_MSG([here is the fortran program:], 1)
+    OMPI_LOG_FILE([conftestf.f90])
+
+    AC_MSG_WARN([*** Problem running configure test!])
+    AC_MSG_WARN([*** See config.log for details.])
+    AC_MSG_ERROR([*** Cannot continue.])
+fi
+str="$2=$ompi_ac_precision"
+eval $str
+
+unset ompi_ac_precision HAPPY
+/bin/rm -f conftest*])dnl
diff --git a/config/f90_get_range.m4 b/config/f90_get_range.m4
new file mode 100644
index 0000000000..0ce8e84672
--- /dev/null
+++ b/config/f90_get_range.m4
@@ -0,0 +1,60 @@
+dnl -*- shell-script -*-
+dnl
+dnl Copyright (c) 2004-2005 The Trustees of Indiana University.
+dnl                         All rights reserved.
+dnl Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
+dnl                         All rights reserved.
+dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
+dnl                         University of Stuttgart.  All rights reserved.
+dnl $COPYRIGHT$
+dnl 
+dnl Additional copyrights may follow
+dnl 
+dnl $HEADER$
+dnl
+
+AC_DEFUN([OMPI_F90_GET_RANGE],[
+# Determine range of FORTRAN datatype.
+# First arg is type, 2nd arg is config var to define.
+
+AC_MSG_CHECKING(range of FORTRAN $1)
+
+cat > conftestf.f90 <<EOF
+program main
+    $1 :: x
+    open(8, file="conftestval")
+    write(8, fmt="(I5)") range(x)
+    close(8)
+end program
+EOF
+
+#
+# Try the compilation and run.
+#
+
+OMPI_LOG_COMMAND([$FC $FCFLAGS $FCFLAGS_f90 -o conftest conftestf.f90],
+	OMPI_LOG_COMMAND([./conftest], [HAPPY=1], [HAPPY=0]), [HAPPY=0])
+
+ompi_ac_range=-1
+if test "$HAPPY" = "1" -a -f conftestval; then
+    # get rid of leading spaces for eval assignment
+    ompi_ac_range=`sed 's/  *//' conftestval`
+    AC_MSG_RESULT([$ompi_ac_range])
+    if test -n "$2"; then
+	eval "$2=$ompi_ac_range"
+    fi
+else
+    AC_MSG_RESULT([unknown])
+
+    OMPI_LOG_MSG([here is the fortran program:], 1)
+    OMPI_LOG_FILE([conftestf.f90])
+
+    AC_MSG_WARN([*** Problem running configure test!])
+    AC_MSG_WARN([*** See config.log for details.])
+    AC_MSG_ERROR([*** Cannot continue.])
+fi
+str="$2=$ompi_ac_range"
+eval $str
+
+unset ompi_ac_range HAPPY
+/bin/rm -f conftest*])dnl