diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2014-06-16 15:15:25 (GMT) |
---|---|---|
committer | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2014-06-16 15:15:25 (GMT) |
commit | 744bc7d236c18d65e9ac84e856f67e8ed145ef91 (patch) | |
tree | 7de2903b9bd1db3d387598ab47469e009db160e9 /fortran | |
parent | 588a733b189d7410ccf4dc7da56ef81f2b11604f (diff) | |
download | hdf5-744bc7d236c18d65e9ac84e856f67e8ed145ef91.zip hdf5-744bc7d236c18d65e9ac84e856f67e8ed145ef91.tar.gz hdf5-744bc7d236c18d65e9ac84e856f67e8ed145ef91.tar.bz2 |
[svn-r25286] Fix for:
HDFFV-8653
replace non-standard sizeof in the fortran tests with c_sizeof
Tested: jam (gnu, intel) with make and cmake.
Diffstat (limited to 'fortran')
-rw-r--r-- | fortran/src/CMakeLists.txt | 22 | ||||
-rw-r--r-- | fortran/src/H5test_kind.f90 | 24 | ||||
-rw-r--r-- | fortran/src/H5test_kind_SIZEOF.f90 | 24 | ||||
-rw-r--r-- | fortran/src/H5test_kind_STORAGE_SIZE.f90 | 230 | ||||
-rw-r--r-- | fortran/src/Makefile.am | 4 | ||||
-rw-r--r-- | fortran/src/Makefile.in | 15 | ||||
-rw-r--r-- | fortran/test/CMakeLists.txt | 8 | ||||
-rw-r--r-- | fortran/test/Makefile.am | 14 | ||||
-rw-r--r-- | fortran/test/Makefile.in | 35 | ||||
-rw-r--r-- | fortran/test/tH5P_F03.f90 | 23 | ||||
-rw-r--r-- | fortran/test/tH5T_F03.f90 | 13 | ||||
-rw-r--r-- | fortran/test/tf.f90 | 4 | ||||
-rw-r--r-- | fortran/test/tf_F03.f90 | 126 | ||||
-rw-r--r-- | fortran/test/tf_F08.f90 | 139 |
14 files changed, 610 insertions, 71 deletions
diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 723e930..f0d8996 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -19,19 +19,25 @@ endif (WIN32) #----------------------------------------------------------------------------- # Setup the Fortran auto-detection utilities -# H5test_kind(_SIZEOF).f90 used to generate H5fortran_detect.f90 +# H5test_kind(_SIZEOF,_STORAGE_SIZE).f90 used to generate H5fortran_detect.f90 # H5fortran_detect.f90 used to generate H5fort_type_defines.h # H5fort_type_defines.h used to generate H5f90i_gen.h + H5fortran_types.f90 #----------------------------------------------------------------------------- -if (FORTRAN_HAVE_SIZEOF) +if (FORTRAN_HAVE_STORAGE_SIZE) add_executable (H5test_FortranHavekind - ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind_SIZEOF.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind_STORAGE_SIZE.f90 ) -else (FORTRAN_HAVE_SIZEOF) - add_executable (H5test_FortranHavekind - ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind.f90 - ) -endif (FORTRAN_HAVE_SIZEOF) +else (FORTRAN_HAVE_STORAGE_SIZE) + if (FORTRAN_HAVE_SIZEOF) + add_executable (H5test_FortranHavekind + ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind_SIZEOF.f90 + ) + else (FORTRAN_HAVE_SIZEOF) + add_executable (H5test_FortranHavekind + ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind.f90 + ) + endif (FORTRAN_HAVE_SIZEOF) +endif (FORTRAN_HAVE_STORAGE_SIZE) if (WIN32 AND MSVC) if (BUILD_SHARED_LIBS) set_target_properties (H5test_FortranHavekind diff --git a/fortran/src/H5test_kind.f90 b/fortran/src/H5test_kind.f90 index 3182853..1a1a0ec 100644 --- a/fortran/src/H5test_kind.f90 +++ b/fortran/src/H5test_kind.f90 @@ -23,18 +23,18 @@ ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! 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 files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! 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 files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! AUTHOR diff --git a/fortran/src/H5test_kind_SIZEOF.f90 b/fortran/src/H5test_kind_SIZEOF.f90 index 7a58b0e..468086a 100644 --- a/fortran/src/H5test_kind_SIZEOF.f90 +++ b/fortran/src/H5test_kind_SIZEOF.f90 @@ -24,18 +24,18 @@ ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -! Copyright by The HDF Group. * -! Copyright by the Board of Trustees of the University of Illinois. * -! 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 files COPYING and Copyright.html. COPYING can be found at the root * -! of the source code distribution tree; Copyright.html can be found at the * -! root level of an installed copy of the electronic HDF5 document set and * -! is linked from the top-level documents page. It can also be found at * -! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -! access to either file, you may request a copy from help@hdfgroup.org. * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! 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 files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! AUTHOR diff --git a/fortran/src/H5test_kind_STORAGE_SIZE.f90 b/fortran/src/H5test_kind_STORAGE_SIZE.f90 new file mode 100644 index 0000000..89c904c --- /dev/null +++ b/fortran/src/H5test_kind_STORAGE_SIZE.f90 @@ -0,0 +1,230 @@ +!****p* Program/H5test_kind_STORAGE_SIZE +! +! NAME +! Executable: H5test_kind +! +! FILE +! fortran/src/H5test_kind_STORAGE_SIZE.f90 +! +! PURPOSE +! This stand alone program is used at build time to generate the program +! H5fortran_detect.f90. It cycles through all the available KIND parameters for +! integers and reals. The appropriate program and subroutines are then generated +! depending on which of the KIND values are found. +! +! NOTES +! This program is used in place of H5test_kind.f90 or H5test_kind_SIZEOF.f90 when +! the Fortran 2008 intrinsic function STORAGE_SIZE is available. It generates code +! that makes use of STORAGE_SIZE in H5fortran_detect.f90, which will be standard +! compliant. This program is the preferred method. +! +! The availability of STORAGE_SIZE is checked at configure time and the TRUE/FALSE +! condition is set in the configure variable "FORTRAN_HAVE_STORAGE_SIZE". +! +! The use of C_SIZOF(X) is not used since the argument X must be an interoperable +! data entity. +! +! COPYRIGHT +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! 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 files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! AUTHOR +! M. Scot Breitenfeld +! +!***** + +PROGRAM test_kind + IMPLICIT NONE + INTEGER :: i, j, ii, ir, last, ikind_numbers(10), rkind_numbers(10) + INTEGER :: ji, jr, jd + last = -1 + ii = 0 + + ikind_numbers = 0 + rkind_numbers = 0 + + DO i = 1,100 + j = SELECTED_INT_KIND(i) + IF(j .NE. last) THEN + IF(last .NE. -1) THEN + ii = ii + 1 + ikind_numbers(ii) = last + ENDIF + last = j + IF(j .EQ. -1) EXIT + ENDIF + ENDDO + + last = -1 + ir = 0 + DO i = 1,100 + j = SELECTED_REAL_KIND(i) + IF(j .NE. last) THEN + IF(last .NE. -1) THEN + ir = ir + 1 + rkind_numbers(ir) = last + ENDIF + last = j + IF(j .EQ. -1) EXIT + ENDIF + ENDDO + +! Generate program information: + +WRITE(*,'(40(A,/))') & +'!****h* ROBODoc/H5fortran_detect.f90',& +'!',& +'! NAME',& +'! H5fortran_detect',& +'! ',& +'! PURPOSE',& +'! This stand alone program is used at build time to generate the header file',& +'! H5fort_type_defines.h. The source code itself was automatically generated by',& +'! the program H5test_kind_STORAGE_SIZE.f90',& +'!',& +'! NOTES',& +'! This source code makes use of the Fortran intrinsic function STORAGE_SIZE because',& +'! the availability of the intrinsic function was determined to be available at',& +'! configure time',& +'!',& +'! COPYRIGHT',& +'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',& +'! Copyright by The HDF Group. *',& +'! Copyright by the Board of Trustees of the University of Illinois. *',& +'! 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 files COPYING and Copyright.html. COPYING can be found at the root *',& +'! of the source code distribution tree; Copyright.html can be found at the *',& +'! root level of an installed copy of the electronic HDF5 document set and *',& +'! is linked from the top-level documents page. It can also be found at *',& +'! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *',& +'! access to either file, you may request a copy from help@hdfgroup.org. *',& +'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',& +'!',& +'! AUTHOR',& +'! H5test_kind_C_SIZEOF.f90',& +'!',& +'!*****' + +! GENERATE A PROGRAM +! +! (a) Generate the module + + WRITE(*,*) "MODULE H5test_kind_STORAGE_SIZE_mod" + WRITE(*,*) "USE ISO_C_BINDING" + WRITE(*,*) "IMPLICIT NONE" + WRITE(*,*) "CONTAINS" + j = 0 + ji = KIND(1) + WRITE(*, "("" SUBROUTINE i"", i2.2,""()"")") j + WRITE(*,*)" IMPLICIT NONE" + WRITE(*,*)" INTEGER :: a" + WRITE(*,*)" INTEGER(C_SIZE_T) :: a_size" + WRITE(*,*)" CHARACTER(LEN=2) :: ichr2, jchr2" + WRITE(*,*)" a_size = STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)" + WRITE(*,*)" WRITE(ichr2,'(I2)') a_size" + WRITE(*,'(A,I0)')" WRITE(jchr2,'(I2)') ",ji + WRITE(*,'(A)')' WRITE(*,*) "#define H5_FORTRAN_HAS_NATIVE_"'// & + "//TRIM(ADJUSTL(ichr2))//"//'"_KIND "'//"//ADJUSTL(jchr2)" + WRITE(*,*)" RETURN" + WRITE(*,*)"END SUBROUTINE" + jr = 0 + j = KIND(1.0) + WRITE(*, "("" SUBROUTINE r"", i2.2,""()"")") jr + WRITE(*,*)" IMPLICIT NONE" + WRITE(*,*)" REAL :: a" + WRITE(*,*)" INTEGER(C_SIZE_T) :: a_size" + WRITE(*,*)" CHARACTER(LEN=2) :: ichr2, jchr2" + WRITE(*,*)" a_size = STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)" + WRITE(*,*)" WRITE(ichr2,'(I2)') a_size" + WRITE(*,'(A,I0)')" WRITE(jchr2,'(I2)') ",j + WRITE(*,'(A)')' WRITE(*,*) "#define H5_FORTRAN_HAS_REAL_NATIVE_"'// & + "//TRIM(ADJUSTL(ichr2))//"//'"_KIND "'//"//ADJUSTL(jchr2)" + WRITE(*,*)" RETURN" + WRITE(*,*)"END SUBROUTINE" + jd = 0 + j = KIND(1.d0) + WRITE(*, "("" SUBROUTINE d"", i2.2,""()"")") jd + WRITE(*,*)" IMPLICIT NONE" + WRITE(*,*)" DOUBLE PRECISION :: a" + WRITE(*,*)" INTEGER(C_SIZE_T) :: a_size" + WRITE(*,*)" CHARACTER(LEN=2) :: ichr2, jchr2" + WRITE(*,*)" a_size = STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)" + WRITE(*,*)" WRITE(ichr2,'(I2)') a_size" + WRITE(*,'(A,I0)')" WRITE(jchr2,'(I2)') ",j + WRITE(*,'(A)')' WRITE(*,*) "#define H5_FORTRAN_HAS_DOUBLE_NATIVE_"'// & + "//TRIM(ADJUSTL(ichr2))//"//'"_KIND "'//"//ADJUSTL(jchr2)" + WRITE(*,*)" RETURN" + WRITE(*,*)"END SUBROUTINE" + DO i = 1, ii + j = ikind_numbers(i) + WRITE(*, "("" SUBROUTINE i"", i2.2,""()"")") j + WRITE(*,*)" IMPLICIT NONE" + WRITE(*,'(A,I0,A)')" INTEGER(KIND=",j,") :: a" + WRITE(*,*)" INTEGER(C_SIZE_T) :: a_size" + WRITE(*,*)" CHARACTER(LEN=2) :: ichr2, jchr2" + WRITE(*,*)" a_size = STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)" + WRITE(*,*)" WRITE(ichr2,'(I2)') a_size" + WRITE(*,'(A,I0)')" WRITE(jchr2,'(I2)') ",j + WRITE(*,'(A)')' WRITE(*,*) "#define H5_FORTRAN_HAS_INTEGER_"'// & + "//TRIM(ADJUSTL(ichr2))//"//'"_KIND "'//"//ADJUSTL(jchr2)" + WRITE(*,*)" RETURN" + WRITE(*,*)"END SUBROUTINE" + ENDDO + DO i = 1, ir + j = rkind_numbers(i) + WRITE(*, "("" SUBROUTINE r"", i2.2,""()"")") j + WRITE(*,*)" IMPLICIT NONE" + WRITE(*,'(A,I0,A)')" REAL(KIND= ",j,") :: a" + WRITE(*,*)" INTEGER(C_SIZE_T) :: a_size" + WRITE(*,*)" CHARACTER(LEN=2) :: ichr2, jchr2" + WRITE(*,*)" a_size = STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)" + WRITE(*,*)" WRITE(ichr2,'(I2)') a_size" + WRITE(*,'(A,I0)')" WRITE(jchr2,'(I2)') ", j + WRITE(*,'(A)')' WRITE(*,*) "#define H5_FORTRAN_HAS_REAL_"'// & + "//TRIM(ADJUSTL(ichr2))//"//'"_KIND "'//"//ADJUSTL(jchr2)" + WRITE(*,*)" RETURN" + WRITE(*,*)"END SUBROUTINE" + ENDDO + WRITE(*,*) "END MODULE H5test_kind_STORAGE_SIZE_mod" + WRITE(*,*) "" + + ! (b) generate the main program + + WRITE(*,*) "PROGRAM H5test_kind_STORAGE_SIZE" + WRITE(*,*) "USE H5test_kind_STORAGE_SIZE_mod" + WRITE(*,*) "WRITE(*,*) "" /*generating header file*/ """ + ji = 0 + WRITE(*, "("" CALL i"", i2.2,""()"")") ji + jr = 0 + WRITE(*, "("" CALL r"", i2.2,""()"")") jr + jd = 0 + WRITE(*, "("" CALL d"", i2.2,""()"")") jd + DO i = 1, ii + j = ikind_numbers(i) + WRITE(*, "("" CALL i"", i2.2,""()"")") j + ENDDO + DO i = 1, ir + j = rkind_numbers(i) + WRITE(*, "("" CALL r"", i2.2,""()"")") j + ENDDO + WRITE(*,*) "END PROGRAM H5test_kind_STORAGE_SIZE" + +END PROGRAM test_kind + + + diff --git a/fortran/src/Makefile.am b/fortran/src/Makefile.am index af0e6ee..a4b3843 100644 --- a/fortran/src/Makefile.am +++ b/fortran/src/Makefile.am @@ -176,11 +176,15 @@ H5fortran_detect.f90: H5test_kind$(EXEEXT) # H5test_kind.f90 is included in the distribution, and Automake knows # how to compile a fortran program given its sources. +if FORTRAN_HAVE_STORAGE_SIZE + H5test_kind_SOURCES = H5test_kind_STORAGE_SIZE.f90 +else if FORTRAN_HAVE_SIZEOF H5test_kind_SOURCES = H5test_kind_SIZEOF.f90 else H5test_kind_SOURCES = H5test_kind.f90 endif +endif # Mark this directory as part of the Fortran API FORTRAN_API=yes diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index 88fb0e7..54a2532 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -189,11 +189,11 @@ H5fortran_detect_LDADD = $(LDADD) H5match_types_SOURCES = H5match_types.c H5match_types_OBJECTS = H5match_types.$(OBJEXT) H5match_types_LDADD = $(LDADD) -am__H5test_kind_SOURCES_DIST = H5test_kind.f90 H5test_kind_SIZEOF.f90 -@FORTRAN_HAVE_SIZEOF_FALSE@am_H5test_kind_OBJECTS = \ -@FORTRAN_HAVE_SIZEOF_FALSE@ H5test_kind.$(OBJEXT) -@FORTRAN_HAVE_SIZEOF_TRUE@am_H5test_kind_OBJECTS = \ -@FORTRAN_HAVE_SIZEOF_TRUE@ H5test_kind_SIZEOF.$(OBJEXT) +am__H5test_kind_SOURCES_DIST = H5test_kind.f90 H5test_kind_SIZEOF.f90 \ + H5test_kind_STORAGE_SIZE.f90 +@FORTRAN_HAVE_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_FALSE@am_H5test_kind_OBJECTS = H5test_kind.$(OBJEXT) +@FORTRAN_HAVE_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_FALSE@am_H5test_kind_OBJECTS = H5test_kind_SIZEOF.$(OBJEXT) +@FORTRAN_HAVE_STORAGE_SIZE_TRUE@am_H5test_kind_OBJECTS = H5test_kind_STORAGE_SIZE.$(OBJEXT) H5test_kind_OBJECTS = $(am_H5test_kind_OBJECTS) H5test_kind_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) @@ -799,11 +799,12 @@ BUILT_SOURCES = H5f90i_gen.h # Automake knows how to build fortran programs if we tell it the source # files. H5fortran_detect_SOURCES = H5fortran_detect.f90 -@FORTRAN_HAVE_SIZEOF_FALSE@H5test_kind_SOURCES = H5test_kind.f90 +@FORTRAN_HAVE_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_FALSE@H5test_kind_SOURCES = H5test_kind.f90 +@FORTRAN_HAVE_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_FALSE@H5test_kind_SOURCES = H5test_kind_SIZEOF.f90 # H5test_kind.f90 is included in the distribution, and Automake knows # how to compile a fortran program given its sources. -@FORTRAN_HAVE_SIZEOF_TRUE@H5test_kind_SOURCES = H5test_kind_SIZEOF.f90 +@FORTRAN_HAVE_STORAGE_SIZE_TRUE@H5test_kind_SOURCES = H5test_kind_STORAGE_SIZE.f90 # Mark this directory as part of the Fortran API FORTRAN_API = yes diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 28b2ae1..7c31fe4 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -21,7 +21,13 @@ set_target_properties (${HDF5_F90_C_TEST_LIB_TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) -add_library (${HDF5_F90_TEST_LIB_TARGET} ${LIB_TYPE} tf.f90) +if (FORTRAN_HAVE_STORAGE_SIZE AND FORTRAN_HAVE_C_SIZEOF) + add_library (${HDF5_F90_TEST_LIB_TARGET} ${LIB_TYPE} tf_F08.f90 tf.f90) +else (FORTRAN_HAVE_STORAGE_SIZE AND FORTRAN_HAVE_C_SIZEOF) + add_library (${HDF5_F90_TEST_LIB_TARGET} ${LIB_TYPE} tf_F03.f90 tf.f90) +endif (FORTRAN_HAVE_STORAGE_SIZE AND FORTRAN_HAVE_C_SIZEOF) + + set (SHARED_LINK_FLAGS " ") if (WIN32) if (BUILD_SHARED_LIBS) diff --git a/fortran/test/Makefile.am b/fortran/test/Makefile.am index c0b5395..9a04106 100644 --- a/fortran/test/Makefile.am +++ b/fortran/test/Makefile.am @@ -53,7 +53,19 @@ endif check_PROGRAMS=$(TEST_PROG) -libh5test_fortran_la_SOURCES= tf.f90 t.c +if FORTRAN_HAVE_STORAGE_SIZE +if FORTRAN_HAVE_C_SIZEOF + libh5test_fortran_la_SOURCES = tf_F08.f90 +else + libh5test_fortran_la_SOURCES = tf_F03.f90 +endif +else + libh5test_fortran_la_SOURCES = tf_F03.f90 +endif + +# tf.f90 depends on either tf_F08.f90 or tf_F03.f90 so they need to be +# compiled first +libh5test_fortran_la_SOURCES += tf.f90 t.c # Source files are used for both the library and fortranlib_test. # Automake will complain about this without the following workaround. diff --git a/fortran/test/Makefile.in b/fortran/test/Makefile.in index 89db8f4..42eecef 100644 --- a/fortran/test/Makefile.in +++ b/fortran/test/Makefile.in @@ -101,7 +101,16 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libh5test_fortran_la_LIBADD = -am_libh5test_fortran_la_OBJECTS = tf.lo t.lo +am__libh5test_fortran_la_SOURCES_DIST = tf_F03.f90 tf.f90 t.c \ + tf_F08.f90 +@FORTRAN_HAVE_C_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@am_libh5test_fortran_la_OBJECTS = tf_F03.lo \ +@FORTRAN_HAVE_C_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ tf.lo \ +@FORTRAN_HAVE_C_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ t.lo +@FORTRAN_HAVE_C_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@am_libh5test_fortran_la_OBJECTS = tf_F08.lo \ +@FORTRAN_HAVE_C_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ tf.lo \ +@FORTRAN_HAVE_C_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ t.lo +@FORTRAN_HAVE_STORAGE_SIZE_FALSE@am_libh5test_fortran_la_OBJECTS = \ +@FORTRAN_HAVE_STORAGE_SIZE_FALSE@ tf_F03.lo tf.lo t.lo libh5test_fortran_la_OBJECTS = $(am_libh5test_fortran_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -213,9 +222,9 @@ am__v_FCLD_1 = SOURCES = $(libh5test_fortran_la_SOURCES) $(fflush1_SOURCES) \ $(fflush2_SOURCES) $(fortranlib_test_SOURCES) \ $(fortranlib_test_1_8_SOURCES) $(fortranlib_test_F03_SOURCES) -DIST_SOURCES = $(libh5test_fortran_la_SOURCES) $(fflush1_SOURCES) \ - $(fflush2_SOURCES) $(fortranlib_test_SOURCES) \ - $(fortranlib_test_1_8_SOURCES) \ +DIST_SOURCES = $(am__libh5test_fortran_la_SOURCES_DIST) \ + $(fflush1_SOURCES) $(fflush2_SOURCES) \ + $(fortranlib_test_SOURCES) $(fortranlib_test_1_8_SOURCES) \ $(am__fortranlib_test_F03_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ @@ -739,7 +748,23 @@ noinst_LTLIBRARIES = libh5test_fortran.la # Our main targets, the tests themselves TEST_PROG = fortranlib_test fflush1 fflush2 fortranlib_test_1_8 \ $(am__append_2) -libh5test_fortran_la_SOURCES = tf.f90 t.c + +# tf.f90 depends on either tf_F08.f90 or tf_F03.f90 so they need to be +# compiled first +@FORTRAN_HAVE_C_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@libh5test_fortran_la_SOURCES = tf_F03.f90 \ +@FORTRAN_HAVE_C_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ tf.f90 \ +@FORTRAN_HAVE_C_SIZEOF_FALSE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ t.c + +# tf.f90 depends on either tf_F08.f90 or tf_F03.f90 so they need to be +# compiled first +@FORTRAN_HAVE_C_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@libh5test_fortran_la_SOURCES = tf_F08.f90 \ +@FORTRAN_HAVE_C_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ tf.f90 \ +@FORTRAN_HAVE_C_SIZEOF_TRUE@@FORTRAN_HAVE_STORAGE_SIZE_TRUE@ t.c + +# tf.f90 depends on either tf_F08.f90 or tf_F03.f90 so they need to be +# compiled first +@FORTRAN_HAVE_STORAGE_SIZE_FALSE@libh5test_fortran_la_SOURCES = \ +@FORTRAN_HAVE_STORAGE_SIZE_FALSE@ tf_F03.f90 tf.f90 t.c # Source files are used for both the library and fortranlib_test. # Automake will complain about this without the following workaround. diff --git a/fortran/test/tH5P_F03.f90 b/fortran/test/tH5P_F03.f90 index 6039a52..0f2f3de 100644 --- a/fortran/test/tH5P_F03.f90 +++ b/fortran/test/tH5P_F03.f90 @@ -106,20 +106,12 @@ SUBROUTINE test_create(total_error) INTEGER(hsize_t), DIMENSION(1:5), PARAMETER :: ch_size= (/1, 1, 1, 4, 1/) CHARACTER(LEN=14) :: filename ='test_create.h5' - ! /* compound datatype operations */ - TYPE, BIND(C) :: comp_datatype - REAL :: a - INTEGER :: x - DOUBLE PRECISION :: y - CHARACTER(LEN=1) :: z - END TYPE comp_datatype - TYPE(comp_datatype), TARGET :: rd_c, fill_ctype INTEGER :: error INTEGER(SIZE_T) :: h5off TYPE(C_PTR) :: f_ptr LOGICAL :: differ1, differ2 - + !/* ! * Create a file. ! */ @@ -136,8 +128,7 @@ SUBROUTINE test_create(total_error) CALL check("h5pset_chunk_f",error, total_error) ! /* Create a compound datatype */ - - CALL h5tcreate_f(H5T_COMPOUND_F, INT(SIZEOF(fill_ctype),size_t), comp_type_id, error) + CALL h5tcreate_f(H5T_COMPOUND_F, H5_SIZEOF(fill_ctype), comp_type_id, error) CALL check("h5tcreate_f", error, total_error) h5off = H5OFFSETOF(C_LOC(fill_ctype), C_LOC(fill_ctype%a)) CALL h5tinsert_f(comp_type_id, "a", h5off , H5T_NATIVE_REAL, error) @@ -412,7 +403,7 @@ SUBROUTINE test_h5p_file_image(total_error) ! Set file image f_ptr = C_LOC(buffer(1)) - size = SIZEOF(buffer) + size = H5_SIZEOF(buffer) CALL h5pset_file_image_f(fapl_1, f_ptr, size, error) CALL check("h5pset_file_image_f", error, total_error) @@ -505,13 +496,13 @@ SUBROUTINE external_test_offset(cleanup,total_error) ! Create the dataset CALL h5pcreate_f(H5P_DATASET_CREATE_F, dcpl, error) CALL check("h5pcreate_f", error, total_error) - CALL h5pset_external_f(dcpl, "extern_1a.raw", INT(0,off_t), INT(SIZEOF(part), hsize_t), error) + CALL h5pset_external_f(dcpl, "extern_1a.raw", INT(0,off_t), INT(H5_SIZEOF(part), hsize_t), error) CALL check("h5pset_external_f",error,total_error) - CALL h5pset_external_f(dcpl, "extern_2a.raw", INT(10,off_t), INT(SIZEOF(part), hsize_t), error) + CALL h5pset_external_f(dcpl, "extern_2a.raw", INT(10,off_t), INT(H5_SIZEOF(part), hsize_t), error) CALL check("h5pset_external_f",error,total_error) - CALL h5pset_external_f(dcpl, "extern_3a.raw", INT(20,off_t), INT(SIZEOF(part), hsize_t), error) + CALL h5pset_external_f(dcpl, "extern_3a.raw", INT(20,off_t), INT(H5_SIZEOF(part), hsize_t), error) CALL check("h5pset_external_f",error,total_error) - CALL h5pset_external_f(dcpl, "extern_4a.raw", INT(30,off_t), INT(SIZEOF(part), hsize_t), error) + CALL h5pset_external_f(dcpl, "extern_4a.raw", INT(30,off_t), INT(H5_SIZEOF(part), hsize_t), error) CALL check("h5pset_external_f",error,total_error) cur_size(1) = 100 diff --git a/fortran/test/tH5T_F03.f90 b/fortran/test/tH5T_F03.f90 index fc3ebd0..f15424d 100644 --- a/fortran/test/tH5T_F03.f90 +++ b/fortran/test/tH5T_F03.f90 @@ -661,9 +661,6 @@ END SUBROUTINE test_array_compound_atomic USE ISO_C_BINDING IMPLICIT NONE - INTEGER, PARAMETER :: r_k4 = SELECTED_REAL_KIND(5) - INTEGER, PARAMETER :: r_k8 = SELECTED_REAL_KIND(10) - INTEGER, INTENT(INOUT) :: total_error INTEGER, PARAMETER :: LENGTH = 5 @@ -685,8 +682,8 @@ END SUBROUTINE test_array_compound_atomic TYPE CmpField_struct INTEGER, DIMENSION(1:ALEN) :: a - REAL(KIND=r_k4), DIMENSION(1:ALEN) :: b - REAL(KIND=r_k8), DIMENSION(1:ALEN) :: c + REAL(KIND=sp), DIMENSION(1:ALEN) :: b + REAL(KIND=dp), DIMENSION(1:ALEN) :: c ENDTYPE CmpField_struct TYPE(CmpField_struct), DIMENSION(1:LENGTH), TARGET :: cf @@ -702,7 +699,7 @@ END SUBROUTINE test_array_compound_atomic TYPE(CmpDTSinfo_struct) :: dtsinfo TYPE fld_t_struct - REAL(KIND=r_k4), DIMENSION(1:ALEN) :: b + REAL(KIND=sp), DIMENSION(1:ALEN) :: b END TYPE fld_t_struct INTEGER(SIZE_T) :: type_sizei ! Size of the integer datatype @@ -741,10 +738,10 @@ END SUBROUTINE test_array_compound_atomic ! ----------------------- CALL h5tget_size_f(H5T_NATIVE_INTEGER, type_sizei, error) CALL check("h5tget_size_f", error, total_error) - IF(sizeof(cf(1)%b(1)).EQ.4)THEN + IF(h5_sizeof(cf(1)%b(1)).EQ.4_size_t)THEN CALL h5tget_size_f(H5T_NATIVE_REAL_4, type_sizer, error) CALL check("h5tget_size_f", error, total_error) - ELSE IF(sizeof(cf(1)%b(1)).EQ.8)THEN + ELSE IF(h5_sizeof(cf(1)%b(1)).EQ.8_size_t)THEN CALL h5tget_size_f(H5T_NATIVE_REAL_8, type_sizer, error) CALL check("h5tget_size_f", error, total_error) ENDIF diff --git a/fortran/test/tf.f90 b/fortran/test/tf.f90 index 2964840..063e93d 100644 --- a/fortran/test/tf.f90 +++ b/fortran/test/tf.f90 @@ -29,7 +29,9 @@ !***** MODULE TH5_MISC - INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15, 307) + USE TH5_MISC_PROVISIONAL + + IMPLICIT NONE CONTAINS diff --git a/fortran/test/tf_F03.f90 b/fortran/test/tf_F03.f90 new file mode 100644 index 0000000..365879a --- /dev/null +++ b/fortran/test/tf_F03.f90 @@ -0,0 +1,126 @@ +!****h* root/fortran/test/tf_F08.f90 +! +! NAME +! tf_F08.f90 +! +! FUNCTION +! Contains Functions that are part of the F2008 standard and needed by +! the hdf5 fortran tests. +! +! COPYRIGHT +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! 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 files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! CONTAINS SUBROUTINES +! H5_SIZEOF +! +!***** +MODULE TH5_MISC_PROVISIONAL + IMPLICIT NONE + + INTEGER, PARAMETER :: sp = KIND(0.0) + INTEGER, PARAMETER :: dp = KIND(0.D0) + + ! generic compound datatype + TYPE, BIND(C) :: comp_datatype + REAL :: a + INTEGER :: x + DOUBLE PRECISION :: y + CHARACTER(LEN=1) :: z + END TYPE comp_datatype + + PUBLIC :: H5_SIZEOF + INTERFACE H5_SIZEOF + MODULE PROCEDURE H5_SIZEOF_CMPD + MODULE PROCEDURE H5_SIZEOF_CHR + MODULE PROCEDURE H5_SIZEOF_I, H5_SIZEOF_IV + MODULE PROCEDURE H5_SIZEOF_SP,H5_SIZEOF_DP + END INTERFACE + +CONTAINS + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_cmpd +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_CMPD(a) + IMPLICIT NONE + TYPE(comp_datatype), INTENT(in) :: a + + H5_SIZEOF_CMPD = SIZEOF(a) + + END FUNCTION H5_SIZEOF_CMPD + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_chr +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_CHR(a) + IMPLICIT NONE + CHARACTER(LEN=*), INTENT(in):: a + + H5_SIZEOF_CHR = SIZEOF(a) + + END FUNCTION H5_SIZEOF_CHR + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_i +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_I(a) + IMPLICIT NONE + INTEGER, INTENT(in):: a + + H5_SIZEOF_I = SIZEOF(a) + + END FUNCTION H5_SIZEOF_I + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_iv +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_IV(a) + IMPLICIT NONE + INTEGER, DIMENSION(:), INTENT(in):: a + + H5_SIZEOF_IV = SIZEOF(a) + + END FUNCTION H5_SIZEOF_IV + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_sp +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_SP(a) + IMPLICIT NONE + REAL(sp), INTENT(in):: a + + H5_SIZEOF_SP = SIZEOF(a) + + END FUNCTION H5_SIZEOF_SP + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_dp +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_DP(a) + IMPLICIT NONE + REAL(dp), INTENT(in):: a + + H5_SIZEOF_DP = SIZEOF(a) + + END FUNCTION H5_SIZEOF_DP + +END MODULE TH5_MISC_PROVISIONAL diff --git a/fortran/test/tf_F08.f90 b/fortran/test/tf_F08.f90 new file mode 100644 index 0000000..3ad2820 --- /dev/null +++ b/fortran/test/tf_F08.f90 @@ -0,0 +1,139 @@ +!****h* root/fortran/test/tf_F08.f90 +! +! NAME +! tf_F08.f90 +! +! FUNCTION +! Contains functions that are part of the F2008 standard and needed by +! the hdf5 fortran tests. +! +! COPYRIGHT +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! Copyright by The HDF Group. * +! Copyright by the Board of Trustees of the University of Illinois. * +! 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 files COPYING and Copyright.html. COPYING can be found at the root * +! of the source code distribution tree; Copyright.html can be found at the * +! root level of an installed copy of the electronic HDF5 document set and * +! is linked from the top-level documents page. It can also be found at * +! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +! access to either file, you may request a copy from help@hdfgroup.org. * +! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +! +! CONTAINS SUBROUTINES +! H5_SIZEOF +! +! NOTES +! This file contains "sizeof" functions that are F2008 standard compliant +! and replace the non-standard 'SIZEOF' functions found in the file tf_F03. +! Unfortunity we need to wrap the C_SIZEOF/STORAGE_SIZE functions to handle different +! data types from the various tests. +! +! F08+TS29113 requires C interoperable variable as argument for C_SIZEOF. +! +! This file will be build instead of tf_F03.f90 if the intrinsic fortran +! function C_SIZEOF/STORAGE_SIZE is found during configure. +! +!***** +MODULE TH5_MISC_PROVISIONAL + + USE ISO_C_BINDING + IMPLICIT NONE + + INTEGER, PARAMETER :: sp = KIND(0.0) + INTEGER, PARAMETER :: dp = KIND(0.D0) + + ! generic compound datatype + TYPE, BIND(C) :: comp_datatype + REAL :: a + INTEGER :: x + DOUBLE PRECISION :: y + CHARACTER(LEN=1) :: z + END TYPE comp_datatype + + PUBLIC :: H5_SIZEOF + INTERFACE H5_SIZEOF + MODULE PROCEDURE H5_SIZEOF_CMPD + MODULE PROCEDURE H5_SIZEOF_CHR + MODULE PROCEDURE H5_SIZEOF_I, H5_SIZEOF_IV + MODULE PROCEDURE H5_SIZEOF_SP,H5_SIZEOF_DP + END INTERFACE + +CONTAINS + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_cmpd +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_CMPD(a) + IMPLICIT NONE + TYPE(comp_datatype), INTENT(in) :: a + + H5_SIZEOF_CMPD = C_SIZEOF(a) + + END FUNCTION H5_SIZEOF_CMPD + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_chr +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_CHR(a) + IMPLICIT NONE + CHARACTER(LEN=*), INTENT(in) :: a + + H5_SIZEOF_CHR = storage_size(a, c_size_t)/storage_size(c_char_'a',c_size_t) + + END FUNCTION H5_SIZEOF_CHR + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_i +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_I(a) + IMPLICIT NONE + INTEGER, INTENT(in):: a + + H5_SIZEOF_I = storage_size(a, c_size_t)/storage_size(c_char_'a',c_size_t) + + END FUNCTION H5_SIZEOF_I + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_iv +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_IV(a) + IMPLICIT NONE + INTEGER, DIMENSION(:), INTENT(in):: a + + H5_SIZEOF_IV = SIZE(a)*storage_size(a(1), c_size_t)/storage_size(c_char_'a',c_size_t) + + END FUNCTION H5_SIZEOF_IV + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_sp +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_SP(a) + IMPLICIT NONE + REAL(sp), INTENT(in):: a + + H5_SIZEOF_SP = storage_size(a, c_size_t)/storage_size(c_char_'a',c_size_t) + + END FUNCTION H5_SIZEOF_SP + +!This definition is needed for Windows DLLs +!DEC$if defined(BUILD_HDF5_DLL) +!DEC$attributes dllexport :: h5_sizeof_dp +!DEC$endif + INTEGER(C_SIZE_T) FUNCTION H5_SIZEOF_DP(a) + IMPLICIT NONE + REAL(dp), INTENT(in):: a + + H5_SIZEOF_DP = storage_size(a, c_size_t)/storage_size(c_char_'a',c_size_t) + + END FUNCTION H5_SIZEOF_DP + +END MODULE TH5_MISC_PROVISIONAL |