diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2015-08-14 19:58:54 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2015-08-14 19:58:54 (GMT) |
commit | c27d1808480a4ffae4af5ff5384993f63ea6b5d4 (patch) | |
tree | 251081393f02ad4fb6767af9d23be50971761d79 /hl/fortran/test | |
parent | 37b14fd3ed8aae8f3b83df03ca29f82178c25f8f (diff) | |
parent | d3e931c772a1fea1d8d0676dd6dd3fe95b000d9e (diff) | |
download | hdf5-c27d1808480a4ffae4af5ff5384993f63ea6b5d4.zip hdf5-c27d1808480a4ffae4af5ff5384993f63ea6b5d4.tar.gz hdf5-c27d1808480a4ffae4af5ff5384993f63ea6b5d4.tar.bz2 |
[svn-r27507] Merge of r27237-27500 from the trunk.
Tested w/ h5committest
NOTES: - The manifest may still be messed up.
- Cmake fails since the dual binary work needs to be merged with
this repo's CMake externals.
Diffstat (limited to 'hl/fortran/test')
-rw-r--r-- | hl/fortran/test/CMakeLists.txt | 80 | ||||
-rw-r--r-- | hl/fortran/test/CMakeTests.cmake | 31 | ||||
-rw-r--r-- | hl/fortran/test/Makefile.am | 8 | ||||
-rw-r--r-- | hl/fortran/test/tstds.F90 (renamed from hl/fortran/test/tstds.f90) | 0 | ||||
-rw-r--r-- | hl/fortran/test/tstimage.F90 (renamed from hl/fortran/test/tstimage.f90) | 0 | ||||
-rw-r--r-- | hl/fortran/test/tstlite.F90 (renamed from hl/fortran/test/tstlite.f90) | 275 | ||||
-rw-r--r-- | hl/fortran/test/tsttable.F90 (renamed from hl/fortran/test/tsttable.f90) | 136 |
7 files changed, 384 insertions, 146 deletions
diff --git a/hl/fortran/test/CMakeLists.txt b/hl/fortran/test/CMakeLists.txt index 55fb987..a1d1386 100644 --- a/hl/fortran/test/CMakeLists.txt +++ b/hl/fortran/test/CMakeLists.txt @@ -7,39 +7,87 @@ PROJECT (HDF5_HL_FORTRAN_TESTS C CXX Fortran) INCLUDE_DIRECTORIES (${CMAKE_Fortran_MODULE_DIRECTORY} ${HDF5_F90_BINARY_DIR} ${HDF5_F90_SRC_DIR}/src) #-- Adding test for hl_f90_tstds -add_executable (hl_f90_tstds tstds.f90) -TARGET_NAMING (hl_f90_tstds ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tstds ${LIB_TYPE} " " " ") +add_executable (hl_f90_tstds tstds.F90) +TARGET_NAMING (hl_f90_tstds STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tstds STATIC " " " ") target_link_libraries (hl_f90_tstds ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tstds PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tstds PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tstds PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tstds PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tstds-shared tstds.F90) + TARGET_NAMING (hl_f90_tstds-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tstds-shared SHARED " " " ") + target_link_libraries (hl_f90_tstds-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tstds-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tstds-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for hl_f90_tstlite -add_executable (hl_f90_tstlite tstlite.f90) -TARGET_NAMING (hl_f90_tstlite ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tstlite ${LIB_TYPE} " " " ") +add_executable (hl_f90_tstlite tstlite.F90) +TARGET_NAMING (hl_f90_tstlite STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tstlite STATIC " " " ") target_link_libraries (hl_f90_tstlite ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tstlite PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tstlite PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tstlite PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tstlite PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tstlite-shared tstlite.F90) + TARGET_NAMING (hl_f90_tstlite-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tstlite-shared SHARED " " " ") + target_link_libraries (hl_f90_tstlite-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tstlite-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tstlite-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for hl_f90_tstimage -add_executable (hl_f90_tstimage tstimage.f90) -TARGET_NAMING (hl_f90_tstimage ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tstimage ${LIB_TYPE} " " " ") +add_executable (hl_f90_tstimage tstimage.F90) +TARGET_NAMING (hl_f90_tstimage STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tstimage STATIC " " " ") target_link_libraries (hl_f90_tstimage ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tstimage PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tstimage PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tstimage PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tstimage PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tstimage-shared tstimage.F90) + TARGET_NAMING (hl_f90_tstimage-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tstimage-shared SHARED " " " ") + target_link_libraries (hl_f90_tstimage-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tstimage-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tstimage-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for hl_f90_tsttable -add_executable (hl_f90_tsttable tsttable.f90) -TARGET_NAMING (hl_f90_tsttable ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tsttable ${LIB_TYPE} " " " ") +add_executable (hl_f90_tsttable tsttable.F90) +TARGET_NAMING (hl_f90_tsttable STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tsttable STATIC " " " ") target_link_libraries (hl_f90_tsttable ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tsttable PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tsttable PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tsttable PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tsttable PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tsttable-shared tsttable.F90) + TARGET_NAMING (hl_f90_tsttable-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tsttable-shared SHARED " " " ") + target_link_libraries (hl_f90_tsttable-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tsttable-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tsttable-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) include (CMakeTests.cmake) diff --git a/hl/fortran/test/CMakeTests.cmake b/hl/fortran/test/CMakeTests.cmake index 3676d24..38181bf 100644 --- a/hl/fortran/test/CMakeTests.cmake +++ b/hl/fortran/test/CMakeTests.cmake @@ -31,3 +31,34 @@ set_tests_properties (HL_FORTRAN_f90_tstimage PROPERTIES DEPENDS HL_FORTRAN_test add_test (NAME HL_FORTRAN_f90_tsttable COMMAND $<TARGET_FILE:hl_f90_tsttable>) set_tests_properties (HL_FORTRAN_f90_tsttable PROPERTIES DEPENDS HL_FORTRAN_test-clear-objects) + +if (BUILD_SHARED_LIBS) + add_test ( + NAME HL_FORTRAN_test-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + dsetf1.h5 + dsetf2.h5 + dsetf3.h5 + dsetf4.h5 + dsetf5.h5 + f1img.h5 + f1tab.h5 + tstds.h5 + ) + set_tests_properties (HL_FORTRAN_test-shared-clear-objects + PROPERTIES DEPENDS "HL_FORTRAN_f90_tsttable;HL_FORTRAN_f90_tstimage;HL_FORTRAN_f90_tstlite;HL_FORTRAN_f90_tstds" + ) + + add_test (NAME HL_FORTRAN_f90_tstds-shared COMMAND $<TARGET_FILE:hl_f90_tstds-shared>) + set_tests_properties (HL_FORTRAN_f90_tstds-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) + + add_test (NAME HL_FORTRAN_f90_tstlite-shared COMMAND $<TARGET_FILE:hl_f90_tstlite-shared>) + set_tests_properties (HL_FORTRAN_f90_tstlite-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) + + add_test (NAME HL_FORTRAN_f90_tstimage-shared COMMAND $<TARGET_FILE:hl_f90_tstimage-shared>) + set_tests_properties (HL_FORTRAN_f90_tstimage-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) + + add_test (NAME HL_FORTRAN_f90_tsttable-shared COMMAND $<TARGET_FILE:hl_f90_tsttable-shared>) + set_tests_properties (HL_FORTRAN_f90_tsttable-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) +endif (BUILD_SHARED_LIBS) diff --git a/hl/fortran/test/Makefile.am b/hl/fortran/test/Makefile.am index fa3a803..18fdaf3 100644 --- a/hl/fortran/test/Makefile.am +++ b/hl/fortran/test/Makefile.am @@ -39,10 +39,10 @@ check_PROGRAMS=$(TEST_PROG) LDADD= $(LIBH5F_HL) $(LIBH5F) $(LIBH5_HL) $(LIBHDF5) # Source files for the programs -tstds_SOURCES=tstds.f90 -tstlite_SOURCES=tstlite.f90 -tstimage_SOURCES=tstimage.f90 -tsttable_SOURCES=tsttable.f90 +tstds_SOURCES=tstds.F90 +tstlite_SOURCES=tstlite.F90 +tstimage_SOURCES=tstimage.F90 +tsttable_SOURCES=tsttable.F90 # Temporary files. CHECK_CLEANFILES+=dsetf[1-5].h5 f1img.h5 f1tab.h5 tstds.h5 diff --git a/hl/fortran/test/tstds.f90 b/hl/fortran/test/tstds.F90 index cbf6c38..cbf6c38 100644 --- a/hl/fortran/test/tstds.f90 +++ b/hl/fortran/test/tstds.F90 diff --git a/hl/fortran/test/tstimage.f90 b/hl/fortran/test/tstimage.F90 index 0bff6b2..0bff6b2 100644 --- a/hl/fortran/test/tstimage.f90 +++ b/hl/fortran/test/tstimage.F90 diff --git a/hl/fortran/test/tstlite.f90 b/hl/fortran/test/tstlite.F90 index d035b89..0eb005b 100644 --- a/hl/fortran/test/tstlite.f90 +++ b/hl/fortran/test/tstlite.F90 @@ -16,6 +16,7 @@ ! ! This file contains the FORTRAN90 tests for H5LT ! +#include <H5config_f.inc> PROGRAM lite_test @@ -38,6 +39,7 @@ END PROGRAM lite_test SUBROUTINE test_dataset1D() +USE, INTRINSIC :: ISO_C_BINDING USE H5LT ! module of H5LT USE HDF5 ! module of HDF5 library @@ -55,11 +57,12 @@ INTEGER, DIMENSION(DIM1) :: buf1 ! Data buffer INTEGER, DIMENSION(DIM1) :: bufr1 ! Data buffer REAL, DIMENSION(DIM1) :: buf2 ! Data buffer REAL, DIMENSION(DIM1) :: bufr2 ! Data buffer -DOUBLE PRECISION, DIMENSION(DIM1) :: buf3 ! Data buffer -DOUBLE PRECISION, DIMENSION(DIM1) :: bufr3 ! Data buffer +DOUBLE PRECISION, DIMENSION(DIM1), TARGET :: buf3 ! Data buffer +DOUBLE PRECISION, DIMENSION(DIM1), TARGET :: bufr3 ! Data buffer INTEGER :: errcode ! Error flag INTEGER :: i ! general purpose integer - +TYPE(C_PTR) :: f_ptr +integer(HID_T) :: mytype CALL test_begin(' Make/Read datasets (1D) ') @@ -101,7 +104,7 @@ CALL h5ltread_dataset_f(file_id, dsetname1, H5T_NATIVE_INTEGER, bufr1, dims, err ! DO i = 1, DIM1 IF ( buf1(i) .NE. bufr1(i) ) THEN - PRINT *, 'read buffer differs from write buffer' + PRINT *, 'read buffer differs from write buffer (I)' PRINT *, bufr1(i), ' and ', buf1(i) STOP ENDIF @@ -126,7 +129,7 @@ CALL h5ltread_dataset_f(file_id, dsetname2, H5T_NATIVE_REAL, bufr2, dims, errcod ! DO i = 1, DIM1 IF ( buf2(i) .NE. bufr2(i) ) THEN - PRINT *, 'read buffer differs from write buffer' + PRINT *, 'read buffer differs from write buffer (R)' PRINT *, bufr2(i), ' and ', buf2(i) STOP ENDIF @@ -139,19 +142,26 @@ END DO ! ! write dataset. ! -CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_DOUBLE, buf3, errcode) - +f_ptr = C_LOC(buf3(1)) +mytype = h5kind_to_type(KIND(buf3(1)), H5_REAL_KIND) +CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, & + mytype, f_ptr, errcode) +!CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_DOUBLE, buf3, errcode) +! h5kind_to_type(KIND(buf3(1)), H5_REAL_KIND) ! ! read dataset. ! -CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_DOUBLE, bufr3, dims, errcode) +f_ptr = C_LOC(bufr3(1)) +CALL h5ltread_dataset_f(file_id, dsetname3, & + h5kind_to_type(KIND(bufr3(1)), H5_REAL_KIND), f_ptr, errcode) +!CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_DOUBLE, bufr3, dims, errcode) ! ! compare read and write buffers. ! DO i = 1, DIM1 IF ( buf3(i) .NE. bufr3(i) ) THEN - PRINT *, 'read buffer differs from write buffer' + PRINT *, 'read buffer differs from write buffer (D)' PRINT *, bufr3(i), ' and ', buf3(i) STOP ENDIF @@ -179,6 +189,7 @@ END SUBROUTINE test_dataset1D SUBROUTINE test_dataset2D() +USE, INTRINSIC :: ISO_C_BINDING USE H5LT ! module of H5LT USE HDF5 ! module of HDF5 library @@ -199,12 +210,13 @@ INTEGER, DIMENSION(DIM1*DIM2) :: buf ! Data buffer INTEGER, DIMENSION(DIM1*DIM2) :: bufr ! Data buffer INTEGER, DIMENSION(DIM1,DIM2) :: buf2 ! Data buffer INTEGER, DIMENSION(DIM1,DIM2) :: buf2r ! Data buffer -REAL, DIMENSION(DIM1,DIM2) :: buf3 ! Data buffer -REAL, DIMENSION(DIM1,DIM2) :: buf3r ! Data buffer -DOUBLE PRECISION, DIMENSION(DIM1,DIM2) :: buf4 ! Data buffer -DOUBLE PRECISION, DIMENSION(DIM1,DIM2) :: buf4r ! Data buffer +REAL, DIMENSION(DIM1,DIM2), TARGET :: buf3 ! Data buffer +REAL, DIMENSION(DIM1,DIM2), TARGET :: buf3r ! Data buffer +DOUBLE PRECISION, DIMENSION(DIM1,DIM2), TARGET :: buf4 ! Data buffer +DOUBLE PRECISION, DIMENSION(DIM1,DIM2), TARGET :: buf4r ! Data buffer INTEGER :: errcode ! Error flag INTEGER(HSIZE_T) :: i, j, n ! general purpose integers +TYPE(C_PTR) :: f_ptr CALL test_begin(' Make/Read datasets (2D) ') @@ -296,12 +308,16 @@ END DO ! ! write dataset. ! -CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_REAL, buf3, errcode) +f_ptr = C_LOC(buf3(1,1)) +CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_REAL, f_ptr, errcode) +!CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_REAL, buf3, errcode) ! ! read dataset. ! -CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, buf3r, dims, errcode) +f_ptr = C_LOC(buf3r(1,1)) +CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, f_ptr, errcode) +!CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, buf3r, dims, errcode) ! ! compare read and write buffers. @@ -323,12 +339,16 @@ END DO ! ! write dataset. ! -CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims, H5T_NATIVE_DOUBLE, buf4, errcode) +f_ptr = C_LOC(buf4(1,1)) +CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims, H5T_NATIVE_DOUBLE, f_ptr, errcode) +!CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims, H5T_NATIVE_DOUBLE, buf4, errcode) ! ! read dataset. -! -CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, buf4r, dims, errcode) +f_ptr = C_LOC(buf4r(1,1)) +CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, f_ptr, errcode) + +!CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, buf4r, dims, errcode) ! ! compare read and write buffers. @@ -366,7 +386,7 @@ END SUBROUTINE test_dataset2D SUBROUTINE test_dataset3D() - +USE, INTRINSIC :: ISO_C_BINDING USE H5LT ! module of H5LT USE HDF5 ! module of HDF5 library @@ -387,16 +407,16 @@ INTEGER, DIMENSION(DIM1*DIM2*DIM3) :: buf ! Data buffer INTEGER, DIMENSION(DIM1*DIM2*DIM3) :: bufr ! Data buffer INTEGER, DIMENSION(DIM1,DIM2,DIM3) :: buf2 ! Data buffer INTEGER, DIMENSION(DIM1,DIM2,DIM3) :: buf2r ! Data buffer -REAL, DIMENSION(DIM1,DIM2,DIM3) :: buf3 ! Data buffer -REAL, DIMENSION(DIM1,DIM2,DIM3) :: buf3r ! Data buffer -DOUBLE PRECISION, DIMENSION(DIM1,DIM2,DIM3) :: buf4 ! Data buffer -DOUBLE PRECISION, DIMENSION(DIM1,DIM2,DIM3) :: buf4r ! Data buffer +REAL, DIMENSION(DIM1,DIM2,DIM3), TARGET :: buf3 ! Data buffer +REAL, DIMENSION(DIM1,DIM2,DIM3), TARGET :: buf3r ! Data buffer +DOUBLE PRECISION, DIMENSION(DIM1,DIM2,DIM3), TARGET :: buf4 ! Data buffer +DOUBLE PRECISION, DIMENSION(DIM1,DIM2,DIM3), TARGET :: buf4r ! Data buffer INTEGER :: rank = 3 ! Dataset rank INTEGER :: errcode ! Error flag INTEGER(HSIZE_T) :: i, j, k, n ! general purpose integers INTEGER :: type_class INTEGER(SIZE_T) :: type_size - +TYPE(C_PTR) :: f_ptr CALL test_begin(' Make/Read datasets (3D) ') @@ -492,12 +512,16 @@ END DO ! ! write dataset. ! -CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_REAL, buf3, errcode) +f_ptr = C_LOC(buf3(1,1,1)) +CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_REAL, f_ptr, errcode) +!CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_REAL, buf3, errcode) ! ! read dataset. ! -CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, buf3r, dims, errcode) +f_ptr = C_LOC(buf3r(1,1,1)) +CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, f_ptr, errcode) +!CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, buf3r, dims, errcode) ! ! compare read and write buffers. @@ -521,12 +545,14 @@ END DO ! ! write dataset. ! -CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims, H5T_NATIVE_DOUBLE, buf4, errcode) +f_ptr = C_LOC(buf4(1,1,1)) +CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims, H5T_NATIVE_DOUBLE, f_ptr, errcode) ! ! read dataset. ! -CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, buf4r, dims, errcode) +f_ptr = C_LOC(buf4r(1,1,1)) +CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, f_ptr, errcode) ! ! compare read and write buffers. @@ -578,6 +604,7 @@ END SUBROUTINE test_dataset3D SUBROUTINE test_datasetND(rank) + USE, INTRINSIC :: ISO_C_BINDING USE H5LT ! module of H5LT USE HDF5 ! module of HDF5 library @@ -598,36 +625,37 @@ SUBROUTINE test_datasetND(rank) CHARACTER(LEN=5), PARAMETER :: dsetname4 = "dset4" ! Dataset name INTEGER(HID_T) :: file_id ! File identifier INTEGER(HSIZE_T), DIMENSION(7) :: dims - INTEGER(HSIZE_T), DIMENSION(7) :: dimsr ! Dataset dimensions - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:) :: ibuf_4 ! Data buffer - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:) :: ibufr_4 ! Data buffer - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:) :: ibuf_5 ! Data buffer - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:) :: ibufr_5 ! Data buffer - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: ibuf_6 ! Data buffer - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: ibufr_6 ! Data buffer - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: ibuf_7 ! Data buffer - INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: ibufr_7 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:) :: rbuf_4 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:) :: rbufr_4 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:) :: rbuf_5 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:) :: rbufr_5 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: rbuf_6 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: rbufr_6 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: rbuf_7 ! Data buffer - REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: rbufr_7 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:) :: dbuf_4 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:) :: dbufr_4 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:) :: dbuf_5 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:) :: dbufr_5 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: dbuf_6 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: dbufr_6 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: dbuf_7 ! Data buffer - DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: dbufr_7 ! Data buffer + INTEGER(HSIZE_T), DIMENSION(7) :: dimsr ! Dataset dimensions + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:) :: ibuf_4 ! Data buffer + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:) :: ibufr_4 ! Data buffer + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:), TARGET :: ibuf_5 ! Data buffer + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:), TARGET :: ibufr_5 ! Data buffer + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: ibuf_6 ! Data buffer + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:) :: ibufr_6 ! Data buffer + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: ibuf_7 ! Data buffer + INTEGER, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:) :: ibufr_7 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:), TARGET :: rbuf_4 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:), TARGET :: rbufr_4 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:), TARGET :: rbuf_5 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:), TARGET :: rbufr_5 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:), TARGET :: rbuf_6 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:), TARGET :: rbufr_6 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:), TARGET :: rbuf_7 ! Data buffer + REAL, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:), TARGET :: rbufr_7 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:), TARGET :: dbuf_4 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:), TARGET :: dbufr_4 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:), TARGET :: dbuf_5 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:), TARGET :: dbufr_5 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:), TARGET :: dbuf_6 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:), TARGET :: dbufr_6 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:), TARGET :: dbuf_7 ! Data buffer + DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:,:,:,:), TARGET :: dbufr_7 ! Data buffer INTEGER :: errcode ! Error flag INTEGER(HSIZE_T) :: i, j, k, l, m, n, o, nn ! general purpose integers INTEGER :: type_class INTEGER(SIZE_T) :: type_size CHARACTER(LEN=1) :: ichr1 + TYPE(C_PTR) :: f_ptr WRITE(ichr1,'(I1.1)') rank CALL test_begin(' Make/Read datasets ('//ichr1//'D) ') @@ -768,7 +796,8 @@ SUBROUTINE test_datasetND(rank) IF(rank.EQ.4)THEN CALL h5ltmake_dataset_f(file_id, dsetname2, rank, dims(1:rank), H5T_NATIVE_INTEGER, ibuf_4, errcode) ELSE IF(rank.EQ.5)THEN - CALL h5ltmake_dataset_f(file_id, dsetname2, rank, dims(1:rank), H5T_NATIVE_INTEGER, ibuf_5, errcode) + f_ptr = C_LOC(ibuf_5(1,1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname2, rank, dims(1:rank), H5T_NATIVE_INTEGER, f_ptr, errcode) ELSE IF(rank.EQ.6)THEN CALL h5ltmake_dataset_f(file_id, dsetname2, rank, dims(1:rank), H5T_NATIVE_INTEGER, ibuf_6, errcode) ELSE IF(rank.EQ.7)THEN @@ -782,7 +811,8 @@ SUBROUTINE test_datasetND(rank) IF(rank.EQ.4)THEN CALL h5ltread_dataset_f(file_id, dsetname2, H5T_NATIVE_INTEGER, ibufr_4, dims(1:rank), errcode) ELSE IF(rank.EQ.5)THEN - CALL h5ltread_dataset_f(file_id, dsetname2, H5T_NATIVE_INTEGER, ibufr_5, dims(1:rank), errcode) + f_ptr = C_LOC(ibufr_5(1,1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname2, H5T_NATIVE_INTEGER, f_ptr, errcode) ELSE IF(rank.EQ.6)THEN CALL h5ltread_dataset_f(file_id, dsetname2, H5T_NATIVE_INTEGER, ibufr_6, dims(1:rank), errcode) ELSE IF(rank.EQ.7)THEN @@ -842,13 +872,20 @@ SUBROUTINE test_datasetND(rank) ! write dataset. ! IF(rank.EQ.4)THEN - CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, rbuf_4, errcode) + f_ptr = C_LOC(rbuf_4(1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, f_ptr, errcode) + ! CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, rbuf_4, errcode) ELSE IF(rank.EQ.5)THEN - CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, rbuf_5, errcode) + f_ptr = C_LOC(rbuf_5(1,1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, f_ptr, errcode) ELSE IF(rank.EQ.6)THEN - CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, rbuf_6, errcode) + f_ptr = C_LOC(rbuf_6(1,1,1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, f_ptr, errcode) + !CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, rbuf_6, errcode) ELSE IF(rank.EQ.7)THEN - CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, rbuf_7, errcode) + f_ptr = C_LOC(rbuf_7(1,1,1,1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, f_ptr, errcode) + !CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims(1:rank), H5T_NATIVE_REAL, rbuf_7, errcode) ENDIF @@ -856,13 +893,17 @@ SUBROUTINE test_datasetND(rank) ! read dataset. ! IF(rank.EQ.4)THEN - CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, rbufr_4, dims(1:rank), errcode) + f_ptr = C_LOC(rbufr_4(1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, f_ptr, errcode) ELSE IF(rank.EQ.5)THEN - CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, rbufr_5, dims(1:rank), errcode) + f_ptr = C_LOC(rbufr_5(1,1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, f_ptr, errcode) ELSE IF(rank.EQ.6)THEN - CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, rbufr_6, dims(1:rank), errcode) + f_ptr = C_LOC(rbufr_6(1,1,1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, f_ptr, errcode) ELSE IF(rank.EQ.7)THEN - CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, rbufr_7, dims(1:rank), errcode) + f_ptr = C_LOC(rbufr_7(1,1,1,1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, f_ptr, errcode) ENDIF ! @@ -919,13 +960,17 @@ SUBROUTINE test_datasetND(rank) ! write dataset. ! IF(rank.EQ.4)THEN - CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, dbuf_4, errcode) + f_ptr = C_LOC(dbuf_4(1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, f_ptr, errcode) ELSE IF(rank.EQ.5)THEN - CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, dbuf_5, errcode) + f_ptr = C_LOC(dbuf_5(1,1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, f_ptr, errcode) ELSE IF(rank.EQ.6)THEN - CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, dbuf_6, errcode) + f_ptr = C_LOC(dbuf_6(1,1,1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, f_ptr, errcode) ELSE IF(rank.EQ.7)THEN - CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, dbuf_7, errcode) + f_ptr = C_LOC(dbuf_7(1,1,1,1,1,1,1)) + CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims(1:rank), H5T_NATIVE_DOUBLE, f_ptr, errcode) ENDIF @@ -933,13 +978,17 @@ SUBROUTINE test_datasetND(rank) ! read dataset. ! IF(rank.EQ.4)THEN - CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, dbufr_4, dims(1:rank), errcode) + f_ptr = C_LOC(dbufr_4(1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, f_ptr, errcode) ELSE IF(rank.EQ.5)THEN - CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, dbufr_5, dims(1:rank), errcode) + f_ptr = C_LOC(dbufr_5(1,1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, f_ptr, errcode) ELSE IF(rank.EQ.6)THEN - CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, dbufr_6, dims(1:rank), errcode) + f_ptr = C_LOC(dbufr_6(1,1,1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, f_ptr, errcode) ELSE IF(rank.EQ.7)THEN - CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, dbufr_7, dims(1:rank), errcode) + f_ptr = C_LOC(dbufr_7(1,1,1,1,1,1,1)) + CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, f_ptr, errcode) ENDIF ! @@ -1036,6 +1085,7 @@ END SUBROUTINE test_datasetND SUBROUTINE test_datasets() + USE, INTRINSIC :: ISO_C_BINDING USE H5LT ! module of H5LT USE HDF5 ! module of HDF5 library @@ -1058,10 +1108,10 @@ SUBROUTINE test_datasets() CHARACTER(LEN=8) :: buf1r ! Data buffer INTEGER, DIMENSION(DIM1) :: buf2 ! Data buffer INTEGER, DIMENSION(DIM1) :: bufr2 ! Data buffer - REAL, DIMENSION(DIM1) :: buf3 ! Data buffer - REAL, DIMENSION(DIM1) :: bufr3 ! Data buffer - DOUBLE PRECISION, DIMENSION(DIM1) :: buf4 ! Data buffer - DOUBLE PRECISION, DIMENSION(DIM1) :: bufr4 ! Data buffer + REAL, DIMENSION(DIM1), TARGET :: buf3 ! Data buffer + REAL, DIMENSION(DIM1) , TARGET :: bufr3 ! Data buffer + DOUBLE PRECISION, DIMENSION(DIM1), TARGET :: buf4 ! Data buffer + DOUBLE PRECISION, DIMENSION(DIM1), TARGET :: bufr4 ! Data buffer INTEGER :: i, n ! general purpose integer INTEGER :: has ! general purpose integer INTEGER :: type_class @@ -1069,6 +1119,7 @@ SUBROUTINE test_datasets() LOGICAL :: path_valid ! status of the path CHARACTER(LEN=6) :: chr_exact CHARACTER(LEN=8) :: chr_lg + TYPE(C_PTR) :: f_ptr ! ! Initialize FORTRAN predefined datatypes. @@ -1131,12 +1182,14 @@ SUBROUTINE test_datasets() ! ! write dataset. ! - CALL h5ltmake_dataset_float_f(file_id, dsetname3, rank, dims, buf3, errcode) + f_ptr = C_LOC(buf3(1)) + CALL h5ltmake_dataset_f(file_id, dsetname3, rank, dims, H5T_NATIVE_REAL, f_ptr, errcode) ! ! read dataset. ! - CALL h5ltread_dataset_float_f(file_id, dsetname3, bufr3, dims, errcode) + f_ptr = C_LOC(bufr3(1)) + CALL h5ltread_dataset_f(file_id, dsetname3, H5T_NATIVE_REAL, f_ptr, errcode) ! ! compare read and write buffers. @@ -1161,13 +1214,18 @@ SUBROUTINE test_datasets() ! ! write dataset. ! + !f_ptr = C_LOC(buf4(1)) + !CALL h5ltmake_dataset_f(file_id, dsetname4, rank, dims, H5T_NATIVE_DOUBLE, f_ptr, errcode) CALL h5ltmake_dataset_double_f(file_id, dsetname4, rank, dims, buf4, errcode) ! ! read dataset. ! + !f_ptr = C_LOC(buf4(1)) + !CALL h5ltread_dataset_f(file_id, dsetname4, H5T_NATIVE_DOUBLE, f_ptr, errcode) CALL h5ltread_dataset_double_f(file_id, dsetname4, bufr4, dims, errcode) + ! ! compare read and write buffers. ! @@ -1335,6 +1393,7 @@ END SUBROUTINE test_datasets SUBROUTINE test_attributes() + USE, INTRINSIC :: ISO_C_BINDING USE H5LT ! module of H5LT USE HDF5 ! module of HDF5 library @@ -1358,10 +1417,10 @@ SUBROUTINE test_attributes() ! CHARACTER(LEN=18) :: bufr_c_lg ! Data buffer INTEGER, DIMENSION(DIM1) :: buf2 ! Data buffer INTEGER, DIMENSION(DIM1) :: bufr2 ! Data buffer - REAL, DIMENSION(DIM1) :: buf3 ! Data buffer - REAL, DIMENSION(DIM1) :: bufr3 ! Data buffer - DOUBLE PRECISION, DIMENSION(DIM1) :: buf4 ! Data buffer - DOUBLE PRECISION, DIMENSION(DIM1) :: bufr4 ! Data buffer + REAL, DIMENSION(DIM1), target :: buf3 ! Data buffer + REAL, DIMENSION(DIM1), target :: bufr3 ! Data buffer + DOUBLE PRECISION, DIMENSION(DIM1), TARGET :: buf4 ! Data buffer + DOUBLE PRECISION, DIMENSION(DIM1), TARGET :: bufr4 ! Data buffer INTEGER :: errcode ! Error flag INTEGER :: i, n ! general purpose integer INTEGER(SIZE_T) size ! size of attribute array @@ -1373,7 +1432,8 @@ SUBROUTINE test_attributes() INTEGER :: rank = 1 ! Dataset rank CHARACTER(LEN=5), PARAMETER :: dsetname1 = "dset1" ! Dataset name INTEGER, DIMENSION(DIM1) :: buf ! Data buffer - + INTEGER(SIZE_T) :: SizeOf_buf_type + TYPE(C_PTR) :: f_ptr ! ! Initialize FORTRAN predefined datatypes. @@ -1441,11 +1501,26 @@ SUBROUTINE test_attributes() ! ! write attribute. ! - CALL h5ltset_attribute_float_f(file_id,dsetname1,attrname3,buf3,size,errcode) +#ifdef H5_FORTRAN_HAVE_STORAGE_SIZE + SizeOf_buf_type = STORAGE_SIZE(buf3(1), c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t) +#else + SizeOf_buf_type = SIZEOF(buf3(1)) +#endif + f_ptr = C_LOC(buf3(1)) + CALL h5ltset_attribute_f(file_id,dsetname1,attrname3,f_ptr,"REAL", SizeOf_buf_type, size,errcode) + !CALL h5ltset_attribute_float_f(file_id,dsetname1,attrname3,buf3,size,errcode) ! ! read attribute. ! - CALL h5ltget_attribute_float_f(file_id,dsetname1,attrname3,bufr3,errcode) +#ifdef H5_FORTRAN_HAVE_STORAGE_SIZE + SizeOf_buf_type = STORAGE_SIZE(bufr3(1), c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t) +#else + SizeOf_buf_type = SIZEOF(bufr3(1)) +#endif + + f_ptr = C_LOC(bufr3(1)) + CALL h5ltget_attribute_f(file_id,dsetname1,attrname3,f_ptr,"REAL",SizeOf_buf_type,errcode) + !CALL h5ltget_attribute_float_f(file_id,dsetname1,attrname3,bufr3,errcode) ! ! compare read and write buffers. @@ -1464,17 +1539,36 @@ SUBROUTINE test_attributes() ! double !------------------------------------------------------------------------- +#ifdef H5_FORTRAN_HAVE_STORAGE_SIZE + SizeOf_buf_type = STORAGE_SIZE(buf4(1), c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t) +#else + SizeOf_buf_type = SIZEOF(buf4(1)) +#endif + + IF(SizeOf_buf_type.LT.16)THEN ! MSB can't handle 16 byte reals + CALL test_begin(' Set/Get attributes double ') - + ! ! write attribute. ! - CALL h5ltset_attribute_double_f(file_id,dsetname1,attrname4,buf4,size,errcode) + f_ptr = C_LOC(buf4(1)) + CALL h5ltset_attribute_f(file_id,dsetname1,attrname4,f_ptr,"real", SizeOf_buf_type, size, errcode) + +! CALL h5ltset_attribute_double_f(file_id,dsetname1,attrname4,buf4, size, errcode) ! ! read attribute. ! - CALL h5ltget_attribute_double_f(file_id,dsetname1,attrname4,bufr4,errcode) + +#ifdef H5_FORTRAN_HAVE_STORAGE_SIZE + SizeOf_buf_type = STORAGE_SIZE(bufr4(1), c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t) +#else + SizeOf_buf_type = SIZEOF(bufr4(1)) +#endif + + f_ptr = C_LOC(bufr4(1)) + CALL h5ltget_attribute_f(file_id,dsetname1,attrname4,f_ptr,"REAL",SizeOf_buf_type,errcode) ! ! compare read and write buffers. @@ -1489,6 +1583,8 @@ SUBROUTINE test_attributes() CALL passed() + ENDIF + !------------------------------------------------------------------------- ! string !------------------------------------------------------------------------- @@ -1604,11 +1700,6 @@ SUBROUTINE test_attributes() ! END SUBROUTINE test_attributes - - - - - !------------------------------------------------------------------------- ! test_begin !------------------------------------------------------------------------- diff --git a/hl/fortran/test/tsttable.f90 b/hl/fortran/test/tsttable.F90 index bb88abf..74029a5 100644 --- a/hl/fortran/test/tsttable.f90 +++ b/hl/fortran/test/tsttable.F90 @@ -16,12 +16,12 @@ ! ! This file contains the FORTRAN90 tests for H5LT ! +#include <H5config_f.inc> PROGRAM table_test CALL test_table1() - END PROGRAM table_test @@ -71,7 +71,24 @@ SUBROUTINE test_table1() INTEGER(SIZE_T), DIMENSION(1:nfields) :: field_sizesr ! field sizes INTEGER(SIZE_T) :: type_sizeout = 0 ! size of the datatype INTEGER :: maxlen = 0 ! max chararter length of a field name - + INTEGER :: Cs_sizeof_double = H5_SIZEOF_DOUBLE ! C's sizeof double + INTEGER :: SIZEOF_X + LOGICAL :: Exclude_double + + ! Find size of DOUBLE PRECISION +#ifdef H5_FORTRAN_HAVE_STORAGE_SIZE + SIZEOF_X = storage_size(bufd(1))/storage_size(c_char_'a') +#else + SIZEOF_X = SIZEOF(bufd(1)) +#endif + + ! If Fortran DOUBLE PRECISION and C DOUBLE sizeofs don't match then disable + ! creating a DOUBLE RECISION field, and instead create a REAL field. This + ! is needed to handle when DOUBLE PRECISION is promoted via a compiler flag. + Exclude_double = .FALSE. + IF(Cs_sizeof_double.NE.SIZEOF_X)THEN + Exclude_double = .TRUE. + ENDIF ! ! Initialize the data arrays. @@ -111,7 +128,11 @@ SUBROUTINE test_table1() CALL h5tset_size_f(type_id_c, type_size, errcode) CALL h5tget_size_f(type_id_c, type_sizec, errcode) CALL h5tget_size_f(H5T_NATIVE_INTEGER, type_sizei, errcode) - CALL h5tget_size_f(H5T_NATIVE_DOUBLE, type_sized, errcode) + IF(exclude_double)THEN + CALL h5tget_size_f(H5T_NATIVE_REAL, type_sized, errcode) + ELSE + CALL h5tget_size_f(H5T_NATIVE_DOUBLE, type_sized, errcode) + ENDIF CALL h5tget_size_f(H5T_NATIVE_REAL, type_sizer, errcode) type_size = type_sizec + type_sizei + type_sized + type_sizer @@ -120,7 +141,11 @@ SUBROUTINE test_table1() ! field_types(1) = type_id_c field_types(2) = H5T_NATIVE_INTEGER - field_types(3) = H5T_NATIVE_DOUBLE + IF(exclude_double)THEN + field_types(3) = H5T_NATIVE_REAL + ELSE + field_types(3) = H5T_NATIVE_DOUBLE + ENDIF field_types(4) = H5T_NATIVE_REAL ! @@ -168,9 +193,13 @@ SUBROUTINE test_table1() CALL h5tbwrite_field_name_f(file_id,dsetname1,field_names(2),start,nrecords,type_sizei,& bufi,errcode) - - CALL h5tbwrite_field_name_f(file_id,dsetname1,field_names(3),start,nrecords,type_sized,& - bufd,errcode) + IF(exclude_double)THEN + CALL h5tbwrite_field_name_f(file_id,dsetname1,field_names(3),start,nrecords,type_sized,& + bufr,errcode) + ELSE + CALL h5tbwrite_field_name_f(file_id,dsetname1,field_names(3),start,nrecords,type_sized,& + bufd,errcode) + ENDIF CALL h5tbwrite_field_name_f(file_id,dsetname1,field_names(4),start,nrecords,type_sizer,& bufr,errcode) @@ -214,7 +243,6 @@ SUBROUTINE test_table1() CALL h5tbread_field_name_f(file_id,dsetname1,field_names(2),start,nrecords,type_sizei,& bufir,errcode) - ! ! compare read and write buffers. ! @@ -226,19 +254,39 @@ SUBROUTINE test_table1() ENDIF END DO - CALL h5tbread_field_name_f(file_id,dsetname1,field_names(3),start,nrecords,type_sized,& - bufdr,errcode) + IF(exclude_double)THEN + + CALL h5tbread_field_name_f(file_id,dsetname1,field_names(3),start,nrecords,type_sized,& + bufrr,errcode) ! ! compare read and write buffers. ! - DO i = 1, nrecords - IF ( bufdr(i) .NE. bufd(i) ) THEN - PRINT *, 'read buffer differs from write buffer' - PRINT *, bufdr(i), ' and ', bufd(i) - STOP - ENDIF - END DO + DO i = 1, nrecords + IF ( bufrr(i) .NE. bufr(i) ) THEN + PRINT *, 'read buffer differs from write buffer' + PRINT *, bufrr(i), ' and ', bufr(i) + STOP + ENDIF + END DO + + ELSE + CALL h5tbread_field_name_f(file_id,dsetname1,field_names(3),start,nrecords,type_sized,& + bufdr,errcode) + + ! + ! compare read and write buffers. + ! + DO i = 1, nrecords + IF ( bufdr(i) .NE. bufd(i) ) THEN + PRINT *, 'read buffer differs from write buffer' + PRINT *, bufdr(i), ' and ', bufd(i) + STOP + ENDIF + END DO + ENDIF + + CALL h5tbread_field_name_f(file_id,dsetname1,field_names(4),start,nrecords,type_sizer,& bufrr,errcode) @@ -254,9 +302,9 @@ SUBROUTINE test_table1() ENDIF END DO - CALL passed() + !------------------------------------------------------------------------- ! write field !------------------------------------------------------------------------- @@ -269,8 +317,13 @@ SUBROUTINE test_table1() CALL h5tbwrite_field_index_f(file_id,dsetname1,2,start,nrecords,type_sizei,& bufi,errcode) - CALL h5tbwrite_field_index_f(file_id,dsetname1,3,start,nrecords,type_sized,& - bufd,errcode) + IF(exclude_double)THEN + CALL h5tbwrite_field_index_f(file_id,dsetname1,3,start,nrecords,type_sized,& + bufr,errcode) + ELSE + CALL h5tbwrite_field_index_f(file_id,dsetname1,3,start,nrecords,type_sized,& + bufd,errcode) + ENDIF CALL h5tbwrite_field_index_f(file_id,dsetname1,4,start,nrecords,type_sizer,& bufr,errcode) @@ -308,20 +361,35 @@ SUBROUTINE test_table1() STOP ENDIF END DO - - CALL h5tbread_field_index_f(file_id,dsetname1,3,start,nrecords,type_sized,& - bufdr,errcode) - - ! - ! compare read and write buffers. - ! - DO i = 1, nrecords - IF ( bufdr(i) .NE. bufd(i) ) THEN - PRINT *, 'read buffer differs from write buffer' - PRINT *, bufdr(i), ' and ', bufd(i) - STOP - ENDIF - END DO + IF(exclude_double)THEN + CALL h5tbread_field_index_f(file_id,dsetname1,3,start,nrecords,type_sized,& + bufrr,errcode) + + ! + ! compare read and write buffers. + ! + DO i = 1, nrecords + IF ( bufrr(i) .NE. bufr(i) ) THEN + PRINT *, 'read buffer differs from write buffer' + PRINT *, bufrr(i), ' and ', bufr(i) + STOP + ENDIF + END DO + ELSE + CALL h5tbread_field_index_f(file_id,dsetname1,3,start,nrecords,type_sized,& + bufdr,errcode) + + ! + ! compare read and write buffers. + ! + DO i = 1, nrecords + IF ( bufdr(i) .NE. bufd(i) ) THEN + PRINT *, 'read buffer differs from write buffer' + PRINT *, bufdr(i), ' and ', bufd(i) + STOP + ENDIF + END DO + ENDIF CALL h5tbread_field_index_f(file_id,dsetname1,4,start,nrecords,type_sizer,& bufrr,errcode) |