summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2016-07-18 18:37:17 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2016-07-18 18:37:17 (GMT)
commit304d85c3e7db1e16ebc1f8df6ea97c76a1731250 (patch)
treef4620f3e4a1d49dda395f36ada57be268ef44a96
parenta71f9dd1e49fa86f7a89a032d9b9ba9031b89356 (diff)
downloadhdf5-304d85c3e7db1e16ebc1f8df6ea97c76a1731250.zip
hdf5-304d85c3e7db1e16ebc1f8df6ea97c76a1731250.tar.gz
hdf5-304d85c3e7db1e16ebc1f8df6ea97c76a1731250.tar.bz2
[svn-r30196] HDFFV-9467: Use the same test programs for CMake and autotools
Tested: jelly (gnu)
-rw-r--r--MANIFEST1
-rw-r--r--config/cmake/HDF5UseFortran.cmake109
-rw-r--r--configure.ac243
-rw-r--r--m4/aclocal_fc.m4169
4 files changed, 65 insertions, 457 deletions
diff --git a/MANIFEST b/MANIFEST
index e3b0195..5d23ba8 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -34,6 +34,7 @@
./m4/aclocal_cxx.m4
./m4/aclocal_fc.m4
+./m4/aclocal_fc.f90
./m4/ax_check_class.m4
./m4/ax_check_classpath.m4
./m4/ax_check_java_home.m4
diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake
index 66e70b4..41efadc 100644
--- a/config/cmake/HDF5UseFortran.cmake
+++ b/config/cmake/HDF5UseFortran.cmake
@@ -19,7 +19,7 @@ ENABLE_LANGUAGE (Fortran)
# so this one is used.
#-----------------------------------------------------------------------------
MACRO (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN)
-# MSB CHECK WHY THIS CHECK?
+#
# if (NOT DEFINED ${RUN_RESULT_VAR})
message (STATUS "Detecting Fortran ${FUNCTION}")
if (CMAKE_REQUIRED_LIBRARIES)
@@ -39,8 +39,6 @@ MACRO (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN)
RUN_OUTPUT_VARIABLE OUTPUT
)
-
-
set(${RETURN} ${OUTPUT})
#message ( "Test result1 ${RETURN} ")
@@ -70,17 +68,22 @@ MACRO (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN)
# endif (NOT DEFINED ${RUN_RESULT_VAR})
ENDMACRO (FORTRAN_RUN)
+# Read source line beginning at the line matching Input:"START" and ending at the line matching Input:"END"
+MACRO (READ_SOURCE START END RETURN)
+ file(READ "${HDF5_SOURCE_DIR}/m4/aclocal_fc.f90" CODE)
+ string(REGEX MATCH "${START}[\\\t\\\n\\\r[].+]*${END}" CODE ${CODE})
+ set(RETURN "${CODE}")
+ENDMACRO (READ_SOURCE START END RETURN)
+
#-----------------------------------------------------------------------------
# Check to see C_LONG_DOUBLE is available
+
+READ_SOURCE("PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" "END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" CODE)
CHECK_FORTRAN_FEATURE(c_long_double
- "
- PROGRAM main
- USE ISO_C_BINDING
- REAL(KIND=C_LONG_DOUBLE) :: d
- END PROGRAM
- "
+ "${CODE}"
FORTRAN_HAVE_C_LONG_DOUBLE
)
+
if (${FORTRAN_HAVE_C_LONG_DOUBLE})
set(FORTRAN_HAVE_C_LONG_DOUBLE 1)
else ()
@@ -89,31 +92,9 @@ endif()
# Check to see C_LONG_DOUBLE is different from C_DOUBLE
+READ_SOURCE("MODULE type_mod" "END PROGRAM PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE" CODE)
CHECK_FORTRAN_FEATURE(c_long_double
- "
- MODULE type_mod
- USE ISO_C_BINDING
- INTERFACE h5t
- MODULE PROCEDURE h5t_c_double
- MODULE PROCEDURE h5t_c_long_double
- END INTERFACE
- CONTAINS
- SUBROUTINE h5t_c_double(r)
- REAL(KIND=C_DOUBLE) :: r
- END SUBROUTINE h5t_c_double
- SUBROUTINE h5t_c_long_double(d)
- REAL(KIND=C_LONG_DOUBLE) :: d
- END SUBROUTINE h5t_c_long_double
- END MODULE type_mod
- PROGRAM main
- USE ISO_C_BINDING
- USE type_mod
- REAL(KIND=C_DOUBLE) :: r
- REAL(KIND=C_LONG_DOUBLE) :: d
- CALL h5t(r)
- CALL h5t(d)
- END PROGRAM main
- "
+ "${CODE}"
FORTRAN_C_LONG_DOUBLE_IS_UNIQUE
)
if (${FORTRAN_C_LONG_DOUBLE_IS_UNIQUE})
@@ -139,66 +120,9 @@ endif(FORTRAN_HAVE_STORAGE_SIZE)
# Determine the available KINDs for REALs and INTEGERs
#-----------------------------------------------------------------------------
+READ_SOURCE("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" CODE)
FORTRAN_RUN("REAL and INTEGER KINDs"
- "
- PROGRAM main
- IMPLICIT NONE
- INTEGER :: ik, jk, k, max_decimal_prec
- INTEGER :: num_rkinds = 1, num_ikinds = 1
- INTEGER, DIMENSION(1:10) :: list_ikinds = -1
- INTEGER, DIMENSION(1:10) :: list_rkinds = -1
-
- ! Find integer KINDs
- list_ikinds(num_ikinds)=SELECTED_INT_KIND(1)
- DO ik = 2, 36
- k = SELECTED_INT_KIND(ik)
- IF(k.LT.0) EXIT
- IF(k.GT.list_ikinds(num_ikinds))THEN
- num_ikinds = num_ikinds + 1
- list_ikinds(num_ikinds) = k
- ENDIF
- ENDDO
-
- DO k = 1, num_ikinds
- WRITE(*,'(I0)', ADVANCE='NO') list_ikinds(k)
- IF(k.NE.num_ikinds)THEN
- WRITE(*,'(A)',ADVANCE='NO') ','
- ELSE
- WRITE(*,'()')
- ENDIF
- ENDDO
-
- ! Find real KINDs
- list_rkinds(num_rkinds)=SELECTED_REAL_KIND(1)
- max_decimal_prec = 1
-
- prec: DO ik = 2, 36
- exp: DO jk = 1, 17000
- k = SELECTED_REAL_KIND(ik,jk)
- IF(k.LT.0) EXIT exp
- IF(k.GT.list_rkinds(num_rkinds))THEN
- num_rkinds = num_rkinds + 1
- list_rkinds(num_rkinds) = k
- ENDIF
- max_decimal_prec = ik
- ENDDO exp
- ENDDO prec
-
- DO k = 1, num_rkinds
- WRITE(*,'(I0)', ADVANCE='NO') list_rkinds(k)
- IF(k.NE.num_rkinds)THEN
- WRITE(*,'(A)',ADVANCE='NO') ','
- ELSE
- WRITE(*,'()')
- ENDIF
- ENDDO
-
- WRITE(*,'(I0)') max_decimal_prec
- WRITE(*,'(I0)') num_ikinds
- WRITE(*,'(I0)') num_rkinds
-
- END PROGRAM main
- "
+ "${CODE}"
XX
YY
PROG_OUTPUT
@@ -210,6 +134,7 @@ FORTRAN_RUN("REAL and INTEGER KINDs"
# dnl -- LINE 4 -- number of valid integer kinds
# dnl -- LINE 5 -- number of valid real kinds
+file(READ "${CMAKE_BINARY_DIR}/pac_fconftest.out" PROG_OUTPUT)
# Convert the string to a list of strings by replacing the carriage return with a semicolon
string(REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}")
diff --git a/configure.ac b/configure.ac
index 74342eb..5ba01c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -281,6 +281,7 @@ while test -n "$hname"; do
test "$hname_tmp" = "$hname" && break
done
+
## ----------------------------------------------------------------------
## Determine build mode (debug, production, clean).
## This has to be done early since the build mode is referred to
@@ -2794,63 +2795,18 @@ esac
##
AC_MSG_CHECKING([if using special algorithm to convert long double to (unsigned) long values])
+## NOTE: Place all configure test programs into cmake's source file, then use a preprocessor directive
+## to select the proper test program. This is done by echoing the #define and cat'ing the cmake
+## source file. (HDFFV-9467)
+
+TEST_SRC="`(echo \"#define H5_LDOUBLE_TO_LONG_SPECIAL_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
+
if test ${ac_cv_sizeof_long_double} = 0; then
hdf5_cv_ldouble_to_long_special=${hdf5_cv_ldouble_to_long_special=no}
else
AC_CACHE_VAL([hdf5_cv_ldouble_to_long_special],
[AC_RUN_IFELSE(
- [AC_LANG_PROGRAM([
- #include <string.h>
- ],[[
- long double ld = 20041683600089727.779961L;
- long ll;
- unsigned long ull;
- unsigned char s[16];
- unsigned char s2[8];
- int ret = 1;
-
- if(sizeof(long double) == 16 && sizeof(long) == 8) {
- /*make sure the long double type has 16 bytes in size and
- * 11 bits of exponent. If it is,
- *the bit sequence should be like below. It's not
- *a decent way to check but this info isn't available. */
- memcpy(s, &ld, 16);
- if(s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 &&
- s[4]==0x85 && s[5]==0xeb && s[6]==0xc8 && s[7]==0xa0 &&
- s[8]==0xbf && s[9]==0xcc && s[10]==0x2a && s[11]==0x3c) {
-
- /* Assign the hexadecimal value of long double type. */
- s[0]=0x43; s[1]=0x51; s[2]=0xcc; s[3]=0xf3;
- s[4]=0x85; s[5]=0xeb; s[6]=0xc8; s[7]=0xa0;
- s[8]=0xbf; s[9]=0xcc; s[10]=0x2a; s[11]=0x3c;
- s[12]=0x3d; s[13]=0x85; s[14]=0x56; s[15]=0x20;
-
- memcpy(&ld, s, 16);
-
- ll = (long)ld;
- memcpy(s2, &ll, 8);
-
- /* The library's algorithm converts it to 0x 00 47 33 ce 17 af 22 82
- * and gets wrong value 20041683600089730 on the IBM Power6 Linux.
- * But the IBM Power6 Linux converts it to 0x00 47 33 ce 17 af 22 7f
- * and gets the correct value 20041683600089727. It uses some special
- * algorithm. We're going to define the macro and skip the test until
- * we can figure out how they do it. */
- if(s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce &&
- s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f)
- ret = 0;
-
- ull = (unsigned long)ld;
- memcpy(s2, &ull, 8);
-
- /* The unsigned long is the same as signed long. */
- if(s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce &&
- s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f)
- ret = 0;
- }
- }
- exit(ret);
- ]])]
+ [AC_LANG_SOURCE([$TEST_SRC])]
, [hdf5_cv_ldouble_to_long_special=yes], [hdf5_cv_ldouble_to_long_special=no],)])
fi
@@ -2872,66 +2828,14 @@ fi
##
AC_MSG_CHECKING([if using special algorithm to convert (unsigned) long to long double values])
+TEST_SRC="`(echo \"#define H5_LONG_TO_LDOUBLE_SPECIAL_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
+
if test ${ac_cv_sizeof_long_double} = 0; then
hdf5_cv_long_to_ldouble_special=${hdf5_cv_long_to_ldouble_special=no}
else
AC_CACHE_VAL([hdf5_cv_long_to_ldouble_special],
[AC_RUN_IFELSE(
- [AC_LANG_PROGRAM([
- #include <string.h>
- ],[[
- long double ld;
- long ll;
- unsigned long ull;
- unsigned char s[16];
- int flag=0, ret=1;
-
- /*Determine if long double has 16 byte in size, 11 bit exponent, and
- *the bias is 0x3ff */
- if(sizeof(long double) == 16) {
- ld = 1.0L;
- memcpy(s, &ld, 16);
- if(s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
- s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00)
- flag = 1;
- }
-
- if(flag==1 && sizeof(long)==8) {
- ll = 0x003fffffffffffffL;
- ld = (long double)ll;
- memcpy(s, &ld, 16);
- /* The library converts the value to 0x434fffffffffffff8000000000000000.
- * In decimal it is 18014398509481982.000000, one value short of the original.
- * The IBM Power6 Linux converts it to 0x4350000000000000bff0000000000000.
- * The value is correct in decimal. It uses some special
- * algorithm. We're going to define the macro and skip the test until
- * we can figure out how they do it. */
- if(s[0]==0x43 && s[1]==0x50 && s[2]==0x00 && s[3]==0x00 &&
- s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 &&
- s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 &&
- s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00)
- ret = 0;
- }
- if(flag==1 && sizeof(unsigned long)==8) {
- ull = 0xffffffffffffffffUL;
- ld = (long double)ull;
- memcpy(s, &ld, 16);
- /* Use a different value from signed long to test. The problem is the same
- * for both long and unsigned long. The value is 18446744073709551615.
- * The library converts the value to 0x43effffffffffffffe000000000000000.
- * In decimal it's 18446744073709548544.000000, very different from the original.
- * The IBM Power6 Linux converts it to 0x43f0000000000000bff0000000000000.
- * The value is correct in decimal. It uses some special
- * algorithm. We're going to define the macro and skip the test until
- * we can figure out how they do it. */
- if(s[0]==0x43 && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
- s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 &&
- s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 &&
- s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00)
- ret = 0;
- }
- exit(ret);
- ]])]
+ [AC_LANG_SOURCE([$TEST_SRC])]
, [hdf5_cv_long_to_ldouble_special=yes], [hdf5_cv_long_to_ldouble_special=no],)])
fi
@@ -2956,48 +2860,14 @@ fi
##
AC_MSG_CHECKING([if correctly converting long double to (unsigned) long long values])
+TEST_SRC="`(echo \"#define H5_LDOUBLE_TO_LLONG_ACCURATE_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
+
if test ${ac_cv_sizeof_long_double} = 0; then
hdf5_cv_ldouble_to_llong_accurate=${hdf5_cv_ldouble_to_llong_accurate=no}
else
AC_CACHE_VAL([hdf5_cv_ldouble_to_llong_accurate],
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
- int main(void)
- {
- long double ld = 20041683600089727.779961L;
- long long ll;
- unsigned long long ull;
- unsigned char s[16];
- int ret = 0;
-
- if(sizeof(long double) == 16) {
- /*make sure the long double type is the same as the failing type
- *which has 16 bytes in size and 11 bits of exponent. If it is,
- *the bit sequence should be like below. It's not
- *a decent way to check but this info isn't available. */
- memcpy(s, &ld, 16);
- if(s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 &&
- s[4]==0x85 && s[5]==0xeb && s[6]==0xc8 && s[7]==0xa0 &&
- s[8]==0xbf && s[9]==0xcc && s[10]==0x2a && s[11]==0x3c) {
-
- /*slightly adjust the bit sequence (s[8]=0xdf). The converted
- *values will go wild on Mac OS 10.4 and IRIX64 6.5.*/
- s[0]=0x43; s[1]=0x51; s[2]=0xcc; s[3]=0xf3;
- s[4]=0x85; s[5]=0xeb; s[6]=0xc8; s[7]=0xa0;
- s[8]=0xdf; s[9]=0xcc; s[10]=0x2a; s[11]=0x3c;
- s[12]=0x3d; s[13]=0x85; s[14]=0x56; s[15]=0x20;
-
- memcpy(&ld, s, 16);
- ll = (long long)ld;
- ull = (unsigned long long)ld;
-
- if(ll != 20041683600089728 || ull != 20041683600089728)
- ret = 1;
- }
- }
- done:
- exit(ret);
- }
- ]])], [hdf5_cv_ldouble_to_llong_accurate=yes], [hdf5_cv_ldouble_to_llong_accurate=no],[])])
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([$TEST_SRC])],
+ [hdf5_cv_ldouble_to_llong_accurate=yes], [hdf5_cv_ldouble_to_llong_accurate=no],[])])
fi
if test ${hdf5_cv_ldouble_to_llong_accurate} = "yes"; then
@@ -3019,52 +2889,14 @@ fi
##
AC_MSG_CHECKING([if correctly converting (unsigned) long long to long double values])
+TEST_SRC="`(echo \"#define H5_LLONG_TO_LDOUBLE_CORRECT_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
+
if test ${ac_cv_sizeof_long_double} = 0; then
hdf5_cv_llong_to_ldouble_correct=${hdf5_cv_llong_to_ldouble_correct=no}
else
AC_CACHE_VAL([hdf5_cv_llong_to_ldouble_correct],
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
- int main(void)
- {
- long double ld;
- long long ll;
- unsigned long long ull;
- unsigned char s[16];
- int flag=0, ret=0;
-
- /*Determine if long double has 16 byte in size, 11 bit exponent, and
- *the bias is 0x3ff */
- if(sizeof(long double) == 16) {
- ld = 1.0L;
- memcpy(s, &ld, 16);
- if(s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
- s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00)
- flag = 1;
- }
-
- if(flag==1 && sizeof(long long)==8) {
- ll = 0x01ffffffffffffffLL;
- ld = (long double)ll;
- memcpy(s, &ld, 16);
- /*Check if the bit sequence is as supposed to be*/
- if(s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
- s[4]!=0xff || s[5]!=0xff || s[6]!=0xff || s[7]!=0xff ||
- s[8]!=0xf0 || s[9]!=0x00 || s[10]!=0x00 || s[11]!=0x00)
- ret = 1;
- }
- if(flag==1 && sizeof(unsigned long long)==8) {
- ull = 0x01ffffffffffffffULL;
- ld = (long double)ull;
- memcpy(s, &ld, 16);
- if(s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
- s[4]!=0xff || s[5]!=0xff || s[6]!=0xff || s[7]!=0xff ||
- s[8]!=0xf0 || s[9]!=0x00 || s[10]!=0x00 || s[11]!=0x00)
- ret = 1;
- }
- done:
- exit(ret);
- }
- ]])],[hdf5_cv_llong_to_ldouble_correct=yes], [hdf5_cv_llong_to_ldouble_correct=no],[])])
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([$TEST_SRC])],
+ [hdf5_cv_llong_to_ldouble_correct=yes], [hdf5_cv_llong_to_ldouble_correct=no],[])])
fi
if test ${hdf5_cv_llong_to_ldouble_correct} = "yes"; then
@@ -3358,40 +3190,11 @@ AC_ARG_ENABLE([embedded-libinfo],
## Check if pointer alignments are enforced
##
AC_MSG_CHECKING([if alignment restrictions are strictly enforced])
+
+TEST_SRC="`(echo \"#define H5_NO_ALIGNMENT_RESTRICTIONS_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
+
AC_RUN_IFELSE([
- AC_LANG_PROGRAM([
- #include <stdlib.h>
- #include <string.h>
-
- typedef struct {
- size_t len;
- void *p;
- } hvl_t;
- ], [
- char *chp = "beefs";
- char **chpp = malloc (2 * sizeof (char *));
- char **chpp2;
- hvl_t vl = { 12345, (void *) chp };
- hvl_t *vlp;
- hvl_t *vlp2;
-
- memcpy ((void *) ((char *) chpp + 1), &chp, sizeof (char *));
- chpp2 = (char **) ((char *) chpp + 1);
- if (strcmp (*chpp2, chp)) {
- free (chpp);
- return 1;
- }
- free (chpp);
-
- vlp = malloc (2 * sizeof (hvl_t));
- memcpy ((void *) ((char *) vlp + 1), &vl, sizeof (hvl_t));
- vlp2 = (hvl_t *) ((char *) vlp + 1);
- if (vlp2->len != vl.len || vlp2->p != vl.p) {
- free (vlp);
- return 1;
- }
- free (vlp);
- ])
+ AC_LANG_SOURCE([$TEST_SRC])
], [
AC_DEFINE([NO_ALIGNMENT_RESTRICTIONS], [1], [Define if we can violate pointer alignment restrictions])
AC_MSG_RESULT([no])
diff --git a/m4/aclocal_fc.m4 b/m4/aclocal_fc.m4
index 0b46505..23f7482 100644
--- a/m4/aclocal_fc.m4
+++ b/m4/aclocal_fc.m4
@@ -68,11 +68,8 @@ dnl See if the fortran compiler supports the intrinsic module "ISO_FORTRAN_ENV"
AC_DEFUN([PAC_PROG_FC_ISO_FORTRAN_ENV],[
HAVE_ISO_FORTRAN_ENV="no"
AC_MSG_CHECKING([if Fortran compiler supports intrinsic module ISO_FORTRAN_ENV])
- AC_LINK_IFELSE([AC_LANG_SOURCE([
- PROGRAM main
- USE, INTRINSIC :: ISO_FORTRAN_ENV
- END PROGRAM
- ])],[AC_MSG_RESULT([yes])
+ TEST_SRC="`sed -n '/PROGRAM PROG_FC_ISO_FORTRAN_ENV/,/END PROGRAM PROG_FC_ISO_FORTRAN_ENV/p' $srcdir/m4/aclocal_fc.f90`"
+ AC_LINK_IFELSE([$TEST_SRC],[AC_MSG_RESULT([yes])
HAVE_ISO_FORTRAN_ENV="yes"],
[AC_MSG_RESULT([no])])
])
@@ -82,11 +79,8 @@ dnl See if the fortran compiler supports the intrinsic function "SIZEOF"
AC_DEFUN([PAC_PROG_FC_SIZEOF],[
HAVE_SIZEOF_FORTRAN="no"
AC_MSG_CHECKING([if Fortran compiler supports intrinsic SIZEOF])
- AC_LINK_IFELSE([AC_LANG_SOURCE([
- PROGRAM main
- i = sizeof(x)
- END PROGRAM
- ])],[AC_MSG_RESULT([yes])
+ TEST_SRC="`sed -n '/PROGRAM PROG_FC_SIZEOF/,/END PROGRAM PROG_FC_SIZEOF/p' $srcdir/m4/aclocal_fc.f90`"
+ AC_LINK_IFELSE([$TEST_SRC],[AC_MSG_RESULT([yes])
HAVE_SIZEOF_FORTRAN="yes"],
[AC_MSG_RESULT([no])])
])
@@ -96,14 +90,8 @@ dnl See if the fortran compiler supports the intrinsic function "C_SIZEOF"
AC_DEFUN([PAC_PROG_FC_C_SIZEOF],[
HAVE_C_SIZEOF_FORTRAN="no"
AC_MSG_CHECKING([if Fortran compiler supports intrinsic C_SIZEOF])
- AC_LINK_IFELSE([AC_LANG_SOURCE([
- PROGRAM main
- USE ISO_C_BINDING
- INTEGER(C_INT) :: a
- INTEGER(C_SIZE_T) :: result
- result = C_SIZEOF(a)
- END PROGRAM
- ])], [AC_MSG_RESULT([yes])
+ TEST_SRC="`sed -n '/PROGRAM PROG_FC_C_SIZEOF/,/END PROGRAM PROG_FC_C_SIZEOF/p' $srcdir/m4/aclocal_fc.f90`"
+ AC_LINK_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes])
HAVE_C_SIZEOF_FORTRAN="yes"],
[AC_MSG_RESULT([no])])
])
@@ -113,13 +101,8 @@ dnl See if the fortran compiler supports the intrinsic function "STORAGE_SIZE"
AC_DEFUN([PAC_PROG_FC_STORAGE_SIZE],[
HAVE_STORAGE_SIZE_FORTRAN="no"
AC_MSG_CHECKING([if Fortran compiler supports intrinsic STORAGE_SIZE])
- AC_LINK_IFELSE([AC_LANG_SOURCE([
- PROGRAM main
- INTEGER :: a
- INTEGER :: result
- result = STORAGE_SIZE(a)
- END PROGRAM
- ])], [AC_MSG_RESULT([yes])
+ TEST_SRC="`sed -ne '/PROGRAM PROG_FC_STORAGE_SIZE/,/END PROGRAM PROG_FC_STORAGE_SIZE/p' $srcdir/m4/aclocal_fc.f90`"
+ AC_LINK_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes])
HAVE_STORAGE_SIZE_FORTRAN="yes"],
[AC_MSG_RESULT([no])])
@@ -130,12 +113,9 @@ dnl Check to see C_LONG_DOUBLE is available
AC_DEFUN([PAC_PROG_FC_HAVE_C_LONG_DOUBLE],[
HAVE_C_LONG_DOUBLE_FORTRAN="no"
AC_MSG_CHECKING([if Fortran compiler supports intrinsic C_LONG_DOUBLE])
- AC_LINK_IFELSE([AC_LANG_SOURCE([
- PROGRAM main
- USE ISO_C_BINDING
- REAL(KIND=C_LONG_DOUBLE) :: d
- END PROGRAM
- ])], [AC_MSG_RESULT([yes])
+ TEST_SRC=""
+ TEST_SRC="`sed -n '/PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE/,/END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE/p' $srcdir/m4/aclocal_fc.f90`"
+ AC_LINK_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes])
HAVE_C_LONG_DOUBLE_FORTRAN="yes"],
[AC_MSG_RESULT([no])])
])
@@ -146,31 +126,8 @@ if test "X$FORTRAN_HAVE_C_LONG_DOUBLE" = "Xyes"; then
AC_DEFUN([PAC_PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE],[
C_LONG_DOUBLE_IS_UNIQUE_FORTRAN="no"
AC_MSG_CHECKING([if Fortran C_LONG_DOUBLE is different from C_DOUBLE])
-
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
- MODULE type_mod
- USE ISO_C_BINDING
- INTERFACE h5t
- MODULE PROCEDURE h5t_c_double
- MODULE PROCEDURE h5t_c_long_double
- END INTERFACE
- CONTAINS
- SUBROUTINE h5t_c_double(r)
- REAL(KIND=C_DOUBLE) :: r
- END SUBROUTINE h5t_c_double
- SUBROUTINE h5t_c_long_double(d)
- REAL(KIND=C_LONG_DOUBLE) :: d
- END SUBROUTINE h5t_c_long_double
- END MODULE type_mod
- PROGRAM main
- USE ISO_C_BINDING
- USE type_mod
- REAL(KIND=C_DOUBLE) :: r
- REAL(KIND=C_LONG_DOUBLE) :: d
- CALL h5t(r)
- CALL h5t(d)
- END PROGRAM main
- ])], [AC_MSG_RESULT([yes])
+ TEST_SRC="`sed -n '/MODULE type_mod/,/END PROGRAM PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE/p' $srcdir/m4/aclocal_fc.f90`"
+ AC_COMPILE_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes])
C_LONG_DOUBLE_IS_UNIQUE_FORTRAN="yes"],
[AC_MSG_RESULT([no])])
])
@@ -180,24 +137,12 @@ dnl Checking if the compiler supports the required Fortran 2003 features and
dnl disable Fortran 2003 if it does not.
AC_DEFUN([PAC_PROG_FC_HAVE_F2003_REQUIREMENTS],[
+ HAVE_F2003_REQUIREMENTS="no"
AC_MSG_CHECKING([if Fortran compiler version compatible with Fortran 2003 HDF])
-dnl --------------------------------------------------------------------
-dnl Default for FORTRAN 2003 compliant compilers
-dnl
- HAVE_F2003_REQUIREMENTS="no"
- AC_LINK_IFELSE([AC_LANG_PROGRAM([],[
-
- USE iso_c_binding
- IMPLICIT NONE
- TYPE(C_PTR) :: ptr
- TYPE(C_FUNPTR) :: funptr
- CHARACTER(LEN=80, KIND=c_char), TARGET :: ichr
-
- ptr = C_LOC(ichr(1:1))
-
- ])],[AC_MSG_RESULT([yes])
- HAVE_F2003_REQUIREMENTS=[yes]],
- [AC_MSG_RESULT([no])])
+ TEST_SRC="`sed -n '/PROG_FC_HAVE_F2003_REQUIREMENTS/,/END PROGRAM PROG_FC_HAVE_F2003_REQUIREMENTS/p' $srcdir/m4/aclocal_fc.f90`"
+ AC_COMPILE_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes])
+ HAVE_F2003_REQUIREMENTS="yes"],
+ [AC_MSG_RESULT([no])])
])
dnl -------------------------------------------------------------------------
@@ -294,16 +239,10 @@ AC_DEFUN([PAC_PROG_FC_MPI_CHECK],[
dnl Change to the Fortran 90 language
AC_LANG_PUSH(Fortran)
-
+ TEST_SRC="`sed -n '/PROGRAM FC_MPI_CHECK/,/END PROGRAM FC_MPI_CHECK/p' $srcdir/m4/aclocal_fc.f90`"
dnl Try link a simple MPI program.
AC_MSG_CHECKING([whether a simple MPI-IO Fortran program can be linked])
- AC_LINK_IFELSE([
- PROGRAM main
- INCLUDE 'mpif.h'
- INTEGER :: comm, amode, info, fh, ierror
- CHARACTER(LEN=1) :: filename
- CALL MPI_File_open( comm, filename, amode, info, fh, ierror)
- END],
+ AC_LINK_IFELSE([$TEST_SRC],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([unable to link a simple MPI-IO Fortran program])])
@@ -321,69 +260,9 @@ dnl
AC_DEFUN([PAC_FC_AVAIL_KINDS],[
AC_LANG_PUSH([Fortran])
rm -f pac_fconftest.out
-
-AC_RUN_IFELSE([
- AC_LANG_SOURCE([
- PROGRAM main
- IMPLICIT NONE
- INTEGER :: ik, jk, k, max_decimal_prec
- INTEGER :: num_rkinds = 1, num_ikinds = 1
- INTEGER, DIMENSION(1:10) :: list_ikinds = -1
- INTEGER, DIMENSION(1:10) :: list_rkinds = -1
-
- OPEN(8, FILE='pac_fconftest.out', FORM='formatted')
-
- ! Find integer KINDs
- list_ikinds(num_ikinds)=SELECTED_INT_KIND(1)
- DO ik = 2, 36
- k = SELECTED_INT_KIND(ik)
- IF(k.LT.0) EXIT
- IF(k.GT.list_ikinds(num_ikinds))THEN
- num_ikinds = num_ikinds + 1
- list_ikinds(num_ikinds) = k
- ENDIF
- ENDDO
-
- DO k = 1, num_ikinds
- WRITE(8,'(I0)', ADVANCE='NO') list_ikinds(k)
- IF(k.NE.num_ikinds)THEN
- WRITE(8,'(A)',ADVANCE='NO') ','
- ELSE
- WRITE(8,'()')
- ENDIF
- ENDDO
-
- ! Find real KINDs
- list_rkinds(num_rkinds)=SELECTED_REAL_KIND(1)
- max_decimal_prec = 1
-
- prec: DO ik = 2, 36
- exp: DO jk = 1, 17000
- k = SELECTED_REAL_KIND(ik,jk)
- IF(k.LT.0) EXIT exp
- IF(k.GT.list_rkinds(num_rkinds))THEN
- num_rkinds = num_rkinds + 1
- list_rkinds(num_rkinds) = k
- ENDIF
- max_decimal_prec = ik
- ENDDO exp
- ENDDO prec
-
- DO k = 1, num_rkinds
- WRITE(8,'(I0)', ADVANCE='NO') list_rkinds(k)
- IF(k.NE.num_rkinds)THEN
- WRITE(8,'(A)',ADVANCE='NO') ','
- ELSE
- WRITE(8,'()')
- ENDIF
- ENDDO
-
- WRITE(8,'(I0)') max_decimal_prec
- WRITE(8,'(I0)') num_ikinds
- WRITE(8,'(I0)') num_rkinds
- END PROGRAM main
- ])
-],[
+TEST_SRC="`sed -n '/PROGRAM FC_AVAIL_KINDS/,/END PROGRAM FC_AVAIL_KINDS/p' $srcdir/m4/aclocal_fc.f90`"
+AC_RUN_IFELSE([$TEST_SRC],
+ [
if test -s pac_fconftest.out ; then
dnl The output from the above program will be:
@@ -588,7 +467,7 @@ rm -f pac_Cconftest.out
LDBL_DIG="`sed -n '1p' pac_Cconftest.out`"
FLT128_DIG="`sed -n '2p' pac_Cconftest.out`"
else
- AC_MSG_ERROR([No output from Fortran decimal precision program!])
+ AC_MSG_ERROR([No output from C decimal precision program!])
fi
rm -f pac_Cconftest.out
],[