diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-04-07 17:58:13 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-04-07 17:58:13 (GMT) |
commit | a72239ecf4858706928b22b220041fbec8f1106d (patch) | |
tree | e8a2f993425641652bad594a67ea43b9889988d9 /m4 | |
parent | 8d2de5906b4257f44c08f22cfecafb8ff3a2a9dd (diff) | |
download | hdf5-a72239ecf4858706928b22b220041fbec8f1106d.zip hdf5-a72239ecf4858706928b22b220041fbec8f1106d.tar.gz hdf5-a72239ecf4858706928b22b220041fbec8f1106d.tar.bz2 |
Add missing m4 file
Diffstat (limited to 'm4')
-rw-r--r-- | m4/aclocal_cxx.m4 | 74 | ||||
-rw-r--r-- | m4/aclocal_fc.f90 | 162 | ||||
-rw-r--r-- | m4/aclocal_fc.m4 | 357 |
3 files changed, 456 insertions, 137 deletions
diff --git a/m4/aclocal_cxx.m4 b/m4/aclocal_cxx.m4 index 922320c..29a0607 100644 --- a/m4/aclocal_cxx.m4 +++ b/m4/aclocal_cxx.m4 @@ -7,9 +7,9 @@ dnl dnl This file is part of HDF5. The full HDF5 copyright notice, including dnl terms governing use, modification, and redistribution, is contained in dnl the COPYING file, which can be found at the root of the source code -dnl dnl distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -dnl dnl If you do not have access to either file, you may request a copy from -dnl dnl help@hdfgroup.org +dnl distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +dnl If you do not have access to either file, you may request a copy from +dnl help@hdfgroup.org dnl dnl ------------------------------------------------------------------------- dnl ------------------------------------------------------------------------- @@ -24,14 +24,11 @@ dnl we need as part of the C++ support. To distinquish these, they dnl have a [PAC] prefix. dnl Checking if C++ needs old style header files in includes - AC_DEFUN([PAC_PROG_CXX_HEADERS],[ AC_MSG_CHECKING([if $CXX needs old style header files in includes]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#include <iostream> + TEST_SRC="`(echo \"#define OLD_HEADER_FILENAME 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" -int main(void) { return 0; } - ])], + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([yes]) CXXFLAGS="${CXXFLAGS} -DOLD_HEADER_FILENAME" @@ -39,80 +36,43 @@ int main(void) { return 0; } ]) dnl Checking if ++ can handle namespaces - AC_DEFUN([PAC_PROG_CXX_NAMESPACE],[ AC_MSG_CHECKING([if $CXX can handle namespaces]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -namespace H5 { -int fnord; -} + TEST_SRC="`(echo \"#define HDF_NO_NAMESPACE 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" -int main(void) { - using namespace H5; - fnord = 37; - return 0; -} - ])], [AC_MSG_RESULT([yes])], + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - CXXFLAGS="${CXXFLAGS} -DH5_NO_NAMESPACE" - AM_CXXFLAGS="${AM_CXXFLAGS} -DH5_NO_NAMESPACE"]) + CXXFLAGS="${CXXFLAGS} -DHDF_NO_NAMESPACE" + AM_CXXFLAGS="${AM_CXXFLAGS} -DHDF_NO_NAMESPACE"]) ]) dnl Checking if C++ supports std - AC_DEFUN([PAC_PROG_CXX_STD],[ AC_MSG_CHECKING([if $CXX supports std]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#include <string> - -using namespace std; + TEST_SRC="`(echo \"#define HDF_NO_STD 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" -int main(void) { - string myString("testing namespace std"); - return 0; -} - ])], [AC_MSG_RESULT([yes])], + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) CXXFLAGS="${CXXFLAGS} -DH5_NO_STD" AM_CXXFLAGS="${AM_CXXFLAGS} -DH5_NO_STD"]) ]) dnl Checking if C++ has offsetof extension - AC_DEFUN([PAC_PROG_CXX_OFFSETOF],[ AC_MSG_CHECKING([if $CXX has offsetof extension]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([ - #include <stdio.h> - #include <stddef.h> - ],[ - struct index_st - { - unsigned char type; - unsigned char num; - unsigned int len; - }; - typedef struct index_st index_t; - int x,y; - x = offsetof(struct index_st, len); - y = offsetof(index_t, num) - ])],[AC_MSG_RESULT([yes]) + TEST_SRC="`(echo \"#define CXX_HAVE_OFFSETOF 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" + + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])],[AC_MSG_RESULT([yes]) AC_DEFINE([CXX_HAVE_OFFSETOF], [1], [Define if C++ compiler recognizes offsetof])], AC_MSG_RESULT([no])) ]) dnl Checking if C++ can handle static cast - AC_DEFUN([PAC_PROG_CXX_STATIC_CAST],[ AC_MSG_CHECKING([if $CXX can handle static cast]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -int main(void) { - float test_float; - int test_int; - test_float = 37.0; - test_int = static_cast <int> (test_float); - return 0; -} - ])], [AC_MSG_RESULT([yes])], + TEST_SRC="`(echo \"#define NO_STATIC_CAST 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" + + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) CXXFLAGS="${CXXFLAGS} -DNO_STATIC_CAST" AM_CXXFLAGS="${AM_CXXFLAGS} -DNO_STATIC_CAST"]) diff --git a/m4/aclocal_fc.f90 b/m4/aclocal_fc.f90 new file mode 100644 index 0000000..7e81a52 --- /dev/null +++ b/m4/aclocal_fc.f90 @@ -0,0 +1,162 @@ +! COPYRIGHT +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! All rights reserved. * +! * +! This file is part of HDF5. The full HDF5 copyright notice, including * +! terms governing use, modification, and redistribution, is contained in * +! the COPYING file, which can be found at the root of the source code * +! distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * +! If you do not have access to either file, you may request a copy from * +! help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! This file contains all the configure test programs +! used by autotools and cmake. This avoids having to +! duplicate code for both cmake and autotool tests. +! For autotools, a program below is chosen via a +! sed command in aclocal_fc.m4. For cmake, a program +! below is chosen via the macro READ_SOURCE in +! HDF5UseFortran.cmake +! + +PROGRAM PROG_FC_ISO_FORTRAN_ENV + USE, INTRINSIC :: ISO_FORTRAN_ENV +END PROGRAM PROG_FC_ISO_FORTRAN_ENV + +PROGRAM PROG_FC_SIZEOF + i = sizeof(x) +END PROGRAM PROG_FC_SIZEOF + +PROGRAM PROG_FC_C_SIZEOF + USE ISO_C_BINDING + INTEGER(C_INT) :: a + INTEGER(C_SIZE_T) :: RESULT + RESULT = C_SIZEOF(a) +END PROGRAM PROG_FC_C_SIZEOF + +PROGRAM PROG_FC_STORAGE_SIZE + INTEGER :: a + INTEGER :: RESULT + RESULT = STORAGE_SIZE(a) +END PROGRAM PROG_FC_STORAGE_SIZE + +PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE + USE ISO_C_BINDING + REAL(KIND=C_LONG_DOUBLE) :: d +END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE + +PROGRAM PROG_FC_HAVE_F2003_REQUIREMENTS + 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)) +END PROGRAM PROG_FC_HAVE_F2003_REQUIREMENTS + +!---- START ----- Check to see C_LONG_DOUBLE is different from C_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 PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE + 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 PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE +!---- END ------- Check to see C_LONG_DOUBLE is different from C_DOUBLE + +!---- START ----- Determine the available KINDs for REALs and INTEGERs +PROGRAM FC_AVAIL_KINDS + IMPLICIT NONE + INTEGER :: ik, jk, k, kk, max_decimal_prec + INTEGER :: prev_rkind, num_rkinds = 1, num_ikinds = 1 + INTEGER, DIMENSION(1:10) :: list_ikinds = -1 + INTEGER, DIMENSION(1:10) :: list_rkinds = -1 + LOGICAL :: new_kind + + 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 + prev_rkind=list_rkinds(num_rkinds) + + prec: DO ik = 2, 36 + exp: DO jk = 1, 700 + k = SELECTED_REAL_KIND(ik,jk) + IF(k.LT.0) EXIT exp + IF(k.NE.prev_rkind)THEN + ! Check if we aleady have that kind + new_kind = .TRUE. + DO kk = 1, num_rkinds + IF(k.EQ.list_rkinds(kk))THEN + new_kind=.FALSE. + EXIT + ENDIF + ENDDO + IF(new_kind)THEN + num_rkinds = num_rkinds + 1 + list_rkinds(num_rkinds) = k + prev_rkind=list_rkinds(num_rkinds) + ENDIF + 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 FC_AVAIL_KINDS +!---- END ----- Determine the available KINDs for REALs and INTEGERs + +PROGRAM FC_MPI_CHECK + INCLUDE 'mpif.h' + INTEGER :: comm, amode, info, fh, ierror + CHARACTER(LEN=1) :: filename + CALL MPI_File_open( comm, filename, amode, info, fh, ierror) +END PROGRAM FC_MPI_CHECK diff --git a/m4/aclocal_fc.m4 b/m4/aclocal_fc.m4 index 227e760..ab45bbc 100644 --- a/m4/aclocal_fc.m4 +++ b/m4/aclocal_fc.m4 @@ -7,9 +7,9 @@ dnl dnl This file is part of HDF5. The full HDF5 copyright notice, including dnl terms governing use, modification, and redistribution, is contained in dnl the COPYING file, which can be found at the root of the source code -dnl dnl distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -dnl dnl If you do not have access to either file, you may request a copy from -dnl dnl help@hdfgroup.org +dnl distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +dnl If you do not have access to either file, you may request a copy from +dnl help@hdfgroup.org dnl dnl ------------------------------------------------------------------------- dnl ------------------------------------------------------------------------- @@ -61,16 +61,24 @@ dnl was required" problem when libtool is also used dnl [1] MPICH.org dnl +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]) + 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])]) +]) + 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])]) ]) @@ -80,14 +88,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])]) ]) @@ -97,74 +99,48 @@ 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])]) ]) -dnl Check to see if -r8 was specified to determine if we need to -dnl compile the DOUBLE PRECISION interfaces. - -AC_DEFUN([PAC_PROG_FC_DEFAULT_REALisDBLE],[ - FORTRAN_DEFAULT_REALisDBLE="no" - AC_MSG_CHECKING([if Fortran default REAL is DOUBLE PRECISION]) - - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - MODULE type_mod - INTERFACE h5t - MODULE PROCEDURE h5t_real - MODULE PROCEDURE h5t_dble - END INTERFACE - CONTAINS - SUBROUTINE h5t_real(r) - REAL :: r - END SUBROUTINE h5t_real - SUBROUTINE h5t_dble(d) - DOUBLE PRECISION :: d - END SUBROUTINE h5t_dble - END MODULE type_mod - PROGRAM main - USE type_mod - REAL :: r - DOUBLE PRECISION :: d - CALL h5t(r) - CALL h5t(d) - END PROGRAM main - ])], [AC_MSG_RESULT([no])], - [AC_MSG_RESULT([yes]) - FORTRAN_DEFAULT_REALisDBLE="yes"]) +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]) + 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])]) ]) +dnl Check if C_LONG_DOUBLE is different from C_DOUBLE + +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]) + 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])]) +]) +fi + 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_FORTRAN_2003="no" - 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 ------------------------------------------------------------------------- @@ -261,16 +237,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 - USE mpi - 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])]) @@ -278,4 +248,231 @@ dnl Try link a simple MPI program. dnl Change to the C language AC_LANG_POP(Fortran) ]) + +dnl ------------------------------------------------------ +dnl Determine the available KINDs for REALs and INTEGERs +dnl ------------------------------------------------------ +dnl +dnl This is a runtime test. +dnl +AC_DEFUN([PAC_FC_AVAIL_KINDS],[ +AC_LANG_PUSH([Fortran]) +rm -f pac_fconftest.out +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: + dnl -- LINE 1 -- valid integer kinds (comma seperated list) + dnl -- LINE 2 -- valid real kinds (comma seperated list) + dnl -- LINE 3 -- max decimal precision for reals + dnl -- LINE 4 -- number of valid integer kinds + dnl -- LINE 5 -- number of valid real kinds + + pac_validIntKinds="`sed -n '1p' pac_fconftest.out`" + pac_validRealKinds="`sed -n '2p' pac_fconftest.out`" + PAC_FC_MAX_REAL_PRECISION="`sed -n '3p' pac_fconftest.out`" + AC_DEFINE_UNQUOTED([PAC_FC_MAX_REAL_PRECISION], $PAC_FC_MAX_REAL_PRECISION, [Define Fortran Maximum Real Decimal Precision]) + + PAC_FC_ALL_INTEGER_KINDS="{`echo $pac_validIntKinds`}" + PAC_FC_ALL_REAL_KINDS="{`echo $pac_validRealKinds`}" + + PAC_FORTRAN_NUM_INTEGER_KINDS="`sed -n '4p' pac_fconftest.out`" + H5CONFIG_F_NUM_IKIND="INTEGER, PARAMETER :: num_ikinds = `echo $PAC_FORTRAN_NUM_INTEGER_KINDS`" + H5CONFIG_F_IKIND="INTEGER, DIMENSION(1:num_ikinds) :: ikind = (/`echo $pac_validIntKinds`/)" + H5CONFIG_F_NUM_RKIND="INTEGER, PARAMETER :: num_rkinds = `sed -n '5p' pac_fconftest.out`" + H5CONFIG_F_RKIND="INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/`echo $pac_validRealKinds`/)" + + AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_RKIND], $H5CONFIG_F_NUM_RKIND, [Define number of valid Fortran REAL KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_IKIND], $H5CONFIG_F_NUM_IKIND, [Define number of valid Fortran INTEGER KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_RKIND], $H5CONFIG_F_RKIND, [Define valid Fortran REAL KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_IKIND], $H5CONFIG_F_IKIND, [Define valid Fortran INTEGER KINDs]) + + AC_MSG_CHECKING([for Number of Fortran INTEGER KINDs]) + AC_MSG_RESULT([$PAC_FORTRAN_NUM_INTEGER_KINDS]) + AC_MSG_CHECKING([for Fortran INTEGER KINDs]) + AC_MSG_RESULT([$PAC_FC_ALL_INTEGER_KINDS]) + AC_MSG_CHECKING([for Fortran REAL KINDs]) + AC_MSG_RESULT([$PAC_FC_ALL_REAL_KINDS]) + AC_MSG_CHECKING([for Fortran REALs maximum decimal precision]) + AC_MSG_RESULT([$PAC_FC_MAX_REAL_PRECISION]) + else + AC_MSG_RESULT([Error]) + AC_MSG_ERROR([No output from Fortran test program!]) + fi + rm -f pac_fconftest.out +],[ + AC_MSG_RESULT([Error]) + AC_MSG_ERROR([Failed to run Fortran program to determine available KINDs]) +],[]) + +AC_LANG_POP([Fortran]) +]) +AC_DEFUN([PAC_FC_SIZEOF_INT_KINDS],[ +AC_REQUIRE([PAC_FC_AVAIL_KINDS]) +AC_MSG_CHECKING([sizeof of available INTEGER KINDs]) +AC_LANG_PUSH([Fortran]) +pack_int_sizeof="" +rm -f pac_fconftest.out + +for kind in `echo $pac_validIntKinds | sed -e 's/,/ /g'`; do + AC_LANG_CONFTEST([ + AC_LANG_SOURCE([ + PROGRAM main + USE ISO_C_BINDING + IMPLICIT NONE + INTEGER (KIND=$kind) a + OPEN(8, FILE='pac_fconftest.out', FORM='formatted') + WRITE(8,'(I0)') $FC_SIZEOF_A + CLOSE(8) + END + ]) + ]) + AC_RUN_IFELSE([],[ + if test -s pac_fconftest.out ; then + sizes="`cat pac_fconftest.out`" + pack_int_sizeof="$pack_int_sizeof $sizes," + else + AC_MSG_ERROR([No output from Fortran test program!]) + fi + rm -f pac_fconftest.out + ],[ + AC_MSG_ERROR([Fortran program fails to build or run!]) + ],[ + pack_int_sizeof="$2" + ]) +done +PAC_FC_ALL_INTEGER_KINDS_SIZEOF="{`echo $pack_int_sizeof | sed -e 's/,$//' | sed -e 's/ //g'`}" +AC_MSG_RESULT([$PAC_FC_ALL_INTEGER_KINDS_SIZEOF]) +AC_LANG_POP([Fortran]) +]) + +AC_DEFUN([PAC_FC_SIZEOF_REAL_KINDS],[ +AC_REQUIRE([PAC_FC_AVAIL_KINDS]) +AC_MSG_CHECKING([sizeof of available REAL KINDs]) +AC_LANG_PUSH([Fortran]) +pack_real_sizeof="" +rm -f pac_fconftest.out +for kind in `echo $pac_validRealKinds | sed -e 's/,/ /g'`; do + AC_LANG_CONFTEST([ + AC_LANG_SOURCE([ + PROGRAM main + USE ISO_C_BINDING + IMPLICIT NONE + REAL (KIND=$kind) :: a + OPEN(8, FILE='pac_fconftest.out', FORM='formatted') + WRITE(8,'(I0)') $FC_SIZEOF_A + CLOSE(8) + END + ]) + ]) + AC_RUN_IFELSE([],[ + if test -s pac_fconftest.out ; then + sizes="`cat pac_fconftest.out`" + pack_real_sizeof="$pack_real_sizeof $sizes," + else + AC_MSG_ERROR([No output from Fortran test program!]) + fi + rm -f pac_fconftest.out + ],[ + AC_MSG_ERROR([Fortran program fails to build or run!]) + ],[ + pack_real_sizeof="$2" + ]) +done +PAC_FC_ALL_REAL_KINDS_SIZEOF="{`echo $pack_real_sizeof | sed -e 's/,$//' | sed -e 's/ //g'`}" +AC_MSG_RESULT([$PAC_FC_ALL_REAL_KINDS_SIZEOF]) +AC_LANG_POP([Fortran]) +]) + +AC_DEFUN([PAC_FC_NATIVE_INTEGER],[ +AC_REQUIRE([PAC_FC_AVAIL_KINDS]) +AC_MSG_CHECKING([sizeof of native KINDS]) +AC_LANG_PUSH([Fortran]) +pack_int_sizeof="" +rm -f pac_fconftest.out + AC_LANG_CONFTEST([ + AC_LANG_SOURCE([ + PROGRAM main + USE ISO_C_BINDING + IMPLICIT NONE + INTEGER a + REAL b + DOUBLE PRECISION c + OPEN(8, FILE='pac_fconftest.out', FORM='formatted') + WRITE(8,*) $FC_SIZEOF_A + WRITE(8,*) KIND(a) + WRITE(8,*) $FC_SIZEOF_B + WRITE(8,*) KIND(b) + WRITE(8,*) $FC_SIZEOF_C + WRITE(8,*) KIND(c) + CLOSE(8) + END + ]) + ]) + AC_RUN_IFELSE([],[ + if test -s pac_fconftest.out ; then + PAC_FORTRAN_NATIVE_INTEGER_SIZEOF="`sed -n '1p' pac_fconftest.out`" + PAC_FORTRAN_NATIVE_INTEGER_KIND="`sed -n '2p' pac_fconftest.out`" + PAC_FORTRAN_NATIVE_REAL_SIZEOF="`sed -n '3p' pac_fconftest.out`" + PAC_FORTRAN_NATIVE_REAL_KIND="`sed -n '4p' pac_fconftest.out`" + PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF="`sed -n '5p' pac_fconftest.out`" + PAC_FORTRAN_NATIVE_DOUBLE_KIND="`sed -n '6p' pac_fconftest.out`" + else + AC_MSG_ERROR([No output from Fortran test program!]) + fi + rm -f pac_fconftest.out + ],[ + AC_MSG_ERROR([Fortran program fails to build or run!]) + ],[ + pack_int_sizeof="$2" + ]) +AC_MSG_RESULT([$pack_int_sizeof]) +AC_LANG_POP([Fortran]) +]) + +AC_DEFUN([PAC_FC_LDBL_DIG],[ +AC_MSG_CHECKING([maximum decimal precision for C]) +rm -f pac_Cconftest.out + AC_LANG_CONFTEST([ + AC_LANG_PROGRAM([ + #include <float.h> + #include <stdio.h> + #define CHECK_FLOAT128 $ac_cv_sizeof___float128 + #if CHECK_FLOAT128!=0 + # if $HAVE_QUADMATH!=0 + #include <quadmath.h> + # endif + # ifdef FLT128_DIG + #define C_FLT128_DIG FLT128_DIG + # else + #define C_FLT128_DIG 0 + # endif + #else + #define C_FLT128_DIG 0 + #endif + #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define C_LDBL_DIG DECIMAL_DIG + #else + #define C_LDBL_DIG LDBL_DIG + #endif + ],[[ + FILE * pFile; + pFile = fopen("pac_Cconftest.out","w"); + fprintf(pFile, "%d\n%d\n", C_LDBL_DIG, C_FLT128_DIG); + ]]) + ]) + AC_RUN_IFELSE([],[ + if test -s pac_Cconftest.out ; then + LDBL_DIG="`sed -n '1p' pac_Cconftest.out`" + FLT128_DIG="`sed -n '2p' pac_Cconftest.out`" + else + AC_MSG_ERROR([No output from C decimal precision program!]) + fi + rm -f pac_Cconftest.out + ],[ + AC_MSG_ERROR([C program fails to build or run!]) + ],[]) +]) + |