summaryrefslogtreecommitdiffstats
path: root/fortran/test
diff options
context:
space:
mode:
Diffstat (limited to 'fortran/test')
-rw-r--r--fortran/test/fortranlib_test.f9010
-rw-r--r--fortran/test/tH5P.f90216
2 files changed, 226 insertions, 0 deletions
diff --git a/fortran/test/fortranlib_test.f90 b/fortran/test/fortranlib_test.f90
index b41de81..1db0f82 100644
--- a/fortran/test/fortranlib_test.f90
+++ b/fortran/test/fortranlib_test.f90
@@ -39,6 +39,7 @@
INTEGER :: basic_datatype_total_error = 0
INTEGER :: enum_total_error = 0
INTEGER :: external_total_error = 0
+ INTEGER :: multi_file_total_error = 0
INTEGER :: attribute_total_error = 0
INTEGER :: identifier_total_error = 0
INTEGER :: group_total_error = 0
@@ -231,6 +232,15 @@
write(*, fmt = e_format) error_string
total_error = total_error + external_total_error
+ error_string = failure
+ cleanup = .FALSE.
+ CALL multi_file_test(cleanup, multi_file_total_error)
+ IF (multi_file_total_error == 0) error_string = success
+ write(*, fmt = '(23a)', advance = 'no') ' Multi file driver test'
+ write(*, fmt = '(47x,a)', advance = 'no') ' '
+ write(*, fmt = e_format) error_string
+ total_error = total_error + multi_file_total_error
+
! write(*,*)
! write(*,*) '========================================='
! write(*,*) 'Testing ATTRIBUTE interface '
diff --git a/fortran/test/tH5P.f90 b/fortran/test/tH5P.f90
index 2c8ad2e..7f61b43 100644
--- a/fortran/test/tH5P.f90
+++ b/fortran/test/tH5P.f90
@@ -134,3 +134,219 @@
RETURN
END SUBROUTINE external_test
+ SUBROUTINE multi_file_test(cleanup, total_error)
+ USE HDF5 ! This module contains all necessary modules
+
+ IMPLICIT NONE
+ LOGICAL, INTENT(IN) :: cleanup
+ INTEGER, INTENT(OUT) :: total_error
+
+ CHARACTER(LEN=9), PARAMETER :: filename = "multidset" ! File name
+ CHARACTER(LEN=80) :: fix_filename
+ CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name
+
+ INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: dset_id ! Dataset identifier
+ INTEGER(HID_T) :: dspace_id ! Dataspace identifier
+ INTEGER(HID_T) :: dtype_id ! Datatype identifier
+ INTEGER(HID_T) :: fapl, fapl_1 ! File access property list identifier
+ INTEGER, DIMENSION(0:H5FD_MEM_NTYPES_F-1) :: memb_map, memb_map_out
+ INTEGER(HID_T), DIMENSION(0:H5FD_MEM_NTYPES_F-1) :: memb_fapl, memb_fapl_out
+ CHARACTER(LEN=20), DIMENSION(0:H5FD_MEM_NTYPES_F-1) :: memb_name, memb_name_out
+ REAL, DIMENSION(0:H5FD_MEM_NTYPES_F-1) :: memb_addr, memb_addr_out
+ !INTEGER(HADDR_T), DIMENSION(0:H5FD_MEM_NTYPES_F) :: memb_addr
+ LOGICAL :: relax = .TRUE.
+ LOGICAL :: relax_out = .TRUE.
+
+ INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions
+ INTEGER :: rank = 2 ! Dataset rank
+
+ INTEGER, DIMENSION(4,6) :: dset_data, data_out ! Data buffers
+ INTEGER :: error ! Error flag
+
+ INTEGER :: i, j !general purpose integers
+ INTEGER(HSIZE_T), DIMENSION(7) :: data_dims_b
+ INTEGER, DIMENSION(7) :: data_dims
+ memb_fapl = H5P_DEFAULT_F
+ memb_map = H5FD_MEM_SUPER_F
+ memb_addr = 0.
+ memb_map(H5FD_MEM_SUPER_F) = H5FD_MEM_SUPER_F
+ memb_addr(H5FD_MEM_SUPER_F) = 0.
+ memb_map(H5FD_MEM_BTREE_F) = H5FD_MEM_BTREE_F
+ memb_addr(H5FD_MEM_BTREE_F) = 0.1
+ memb_map(H5FD_MEM_DRAW_F) = H5FD_MEM_DRAW_F
+ memb_addr(H5FD_MEM_DRAW_F) = 0.5
+ memb_map(H5FD_MEM_GHEAP_F) = H5FD_MEM_GHEAP_F
+ memb_addr(H5FD_MEM_GHEAP_F) = 0.2
+ memb_map(H5FD_MEM_LHEAP_F) = H5FD_MEM_LHEAP_F
+ memb_addr(H5FD_MEM_LHEAP_F) = 0.3
+ memb_map(H5FD_MEM_OHDR_F) = H5FD_MEM_OHDR_F
+ memb_addr(H5FD_MEM_OHDR_F) = 0.4
+
+ memb_name = ''
+ memb_name(H5FD_MEM_SUPER_F) = '%s-s.h5'
+ memb_name(H5FD_MEM_BTREE_F) = '%s-b.h5'
+ memb_name(H5FD_MEM_DRAW_F) = '%s-r.h5'
+ memb_name(H5FD_MEM_GHEAP_F) = '%s-g.h5'
+ memb_name(H5FD_MEM_LHEAP_F) = '%s-l.h5'
+ memb_name(H5FD_MEM_OHDR_F) = '%s-o.h5'
+
+ !
+ ! Initialize the dset_data array.
+ !
+ do i = 1, 4
+ do j = 1, 6
+ dset_data(i,j) = (i-1)*6 + j;
+ end do
+ end do
+
+ !
+ ! Create a new file using default properties.
+ !
+ CALL h5_fixname_f(filename, fix_filename, H5P_DEFAULT_F, error)
+ if (error .ne. 0) then
+ write(*,*) "Cannot modify filename"
+ stop
+ endif
+ CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error)
+ CALL check("h5pcreate_f", error, total_error)
+ CALL h5pset_fapl_multi_f(fapl, memb_map, memb_fapl, memb_name, memb_addr, relax, error)
+ CALL check("h5pset_fapl_multi_f", error, total_error)
+ CALL h5pget_fapl_multi_f(fapl, memb_map_out, memb_fapl_out, memb_name_out, &
+ memb_addr_out, relax_out, error)
+ CALL check("h5pget_fapl_multi_f", error, total_error)
+ CALL h5fcreate_f(fix_filename, H5F_ACC_TRUNC_F, file_id, error, access_prp = fapl)
+ CALL check("h5fcreate_f", error, total_error)
+
+
+ !
+ ! Create the dataspace.
+ !
+ CALL h5screate_simple_f(rank, dims, dspace_id, error)
+ CALL check("h5screate_simple_f", error, total_error)
+
+
+ !
+ ! Create the dataset with default properties.
+ !
+ CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, &
+ dset_id, error)
+ CALL check("h5dcreate_f", error, total_error)
+
+ !
+ ! Write the dataset.
+ !
+ data_dims_b(1) = 4
+ data_dims_b(2) = 6
+ CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, dset_data, data_dims_b, error)
+ CALL check("h5dwrite_f", error, total_error)
+
+
+ !
+ ! End access to the dataset and release resources used by it.
+ !
+ CALL h5dclose_f(dset_id, error)
+ CALL check("h5dclose_f", error, total_error)
+
+ !
+ ! Terminate access to the data space.
+ !
+ CALL h5sclose_f(dspace_id, error)
+ CALL check("h5sclose_f", error, total_error)
+
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+ CALL check("h5fclose_f", error, total_error)
+ CALL h5pclose_f(fapl, error)
+ CALL check("h5pclose_f", error, total_error)
+
+ !
+ ! Open the existing file.
+ !
+ CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error)
+ CALL check("h5pcreate_f", error, total_error)
+ CALL h5pset_fapl_multi_f(fapl, relax, error)
+ CALL check("h5pset_fapl_multi_f", error, total_error)
+ CALL h5fopen_f (fix_filename, H5F_ACC_RDWR_F, file_id, error, access_prp = fapl)
+ CALL check("h5fopen_f", error, total_error)
+ !
+ !It looks like a bug in the C Library
+ !CALL h5fget_access_plist_f(file_id, fapl_1, error)
+ ! CALL check("h5fget_access_plist_f", error, total_error)
+ !CALL h5pget_fapl_multi_f(fapl_1, memb_map_out, memb_fapl_out, memb_name_out, &
+ ! memb_addr_out, relax_out, error)
+ ! write(*,*) memb_map_out
+ ! write(*,*) memb_fapl_out
+ ! write(*,*) memb_name_out
+ ! write(*,*) memb_addr_out
+ ! CALL check("h5pget_fapl_multi_f", error, total_error)
+
+ !
+ ! Open the existing dataset.
+ !
+ CALL h5dopen_f(file_id, dsetname, dset_id, error)
+ CALL check("h5dopen_f", error, total_error)
+
+ !
+ ! Get the dataset type.
+ !
+ CALL h5dget_type_f(dset_id, dtype_id, error)
+ CALL check("h5dget_type_f", error, total_error)
+
+ !
+ ! Get the data space.
+ !
+ CALL h5dget_space_f(dset_id, dspace_id, error)
+ CALL check("h5dget_space_f", error, total_error)
+
+ !
+ ! Read the dataset.
+ !
+ CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error)
+ CALL check("h5dread_f", error, total_error)
+
+ !
+ !Compare the data.
+ !
+ do i = 1, 4
+ do j = 1, 6
+ IF (data_out(i,j) .NE. dset_data(i, j)) THEN
+ write(*, *) "dataset test error occured"
+ write(*,*) "data read is not the same as the data writen"
+ END IF
+ end do
+ end do
+
+ !
+ ! End access to the dataset and release resources used by it.
+ !
+ CALL h5dclose_f(dset_id, error)
+ CALL check("h5dclose_f", error, total_error)
+
+ !
+ ! Terminate access to the data space.
+ !
+ CALL h5sclose_f(dspace_id, error)
+ CALL check("h5sclose_f", error, total_error)
+
+ !
+ ! Terminate access to the data type.
+ !
+ CALL h5tclose_f(dtype_id, error)
+ CALL check("h5tclose_f", error, total_error)
+ !
+ ! Close the file.
+ !
+ CALL h5fclose_f(file_id, error)
+ CALL check("h5fclose_f", error, total_error)
+ CALL h5pclose_f(fapl, error)
+ CALL check("h5pclose_f", error, total_error)
+ CALL h5pclose_f(fapl_1, error)
+ CALL check("h5pclose_f", error, total_error)
+ if(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error)
+ CALL check("h5_cleanup_f", error, total_error)
+
+ RETURN
+ END SUBROUTINE multi_file_test