summaryrefslogtreecommitdiffstats
path: root/fortran/src
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2014-06-16 15:15:25 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2014-06-16 15:15:25 (GMT)
commit744bc7d236c18d65e9ac84e856f67e8ed145ef91 (patch)
tree7de2903b9bd1db3d387598ab47469e009db160e9 /fortran/src
parent588a733b189d7410ccf4dc7da56ef81f2b11604f (diff)
downloadhdf5-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/src')
-rw-r--r--fortran/src/CMakeLists.txt22
-rw-r--r--fortran/src/H5test_kind.f9024
-rw-r--r--fortran/src/H5test_kind_SIZEOF.f9024
-rw-r--r--fortran/src/H5test_kind_STORAGE_SIZE.f90230
-rw-r--r--fortran/src/Makefile.am4
-rw-r--r--fortran/src/Makefile.in15
6 files changed, 280 insertions, 39 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