diff options
Diffstat (limited to 'fortran/test/tH5D.f90')
-rw-r--r-- | fortran/test/tH5D.f90 | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/fortran/test/tH5D.f90 b/fortran/test/tH5D.f90 index d71e61f..3e954d9 100644 --- a/fortran/test/tH5D.f90 +++ b/fortran/test/tH5D.f90 @@ -31,10 +31,13 @@ CHARACTER(LEN=5), PARAMETER :: filename = "dsetf" ! File name CHARACTER(LEN=80) :: fix_filename CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name + CHARACTER(LEN=9), PARAMETER :: null_dsetname = "null_dset" ! Dataset name INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: dset_id ! Dataset identifier + INTEGER(HID_T) :: null_dset ! Null dataset identifier INTEGER(HID_T) :: dspace_id ! Dataspace identifier + INTEGER(HID_T) :: null_dspace ! Null dataspace identifier INTEGER(HID_T) :: dtype_id ! Datatype identifier @@ -46,6 +49,8 @@ INTEGER :: i, j !general purpose integers INTEGER(HSIZE_T), DIMENSION(2) :: data_dims + INTEGER(HSIZE_T), DIMENSION(1) :: null_data_dim + INTEGER :: null_dset_data = 1 ! null data ! ! Initialize the dset_data array. @@ -74,6 +79,11 @@ ! CALL h5screate_simple_f(rank, dims, dspace_id, error) CALL check("h5screate_simple_f", error, total_error) + ! + ! Create null dataspace. + ! + CALL h5screate_f(H5S_NULL_F, null_dspace, error) + CALL check("h5screate_simple_f", error, total_error) ! @@ -82,6 +92,12 @@ CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, & dset_id, error) CALL check("h5dcreate_f", error, total_error) + ! + ! Create the null dataset. + ! + CALL h5dcreate_f(file_id, null_dsetname, H5T_NATIVE_INTEGER, null_dspace, & + null_dset, error) + CALL check("h5dcreate_f", error, total_error) ! ! Write the dataset. @@ -90,6 +106,12 @@ data_dims(2) = 6 CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, dset_data, data_dims, error) CALL check("h5dwrite_f", error, total_error) + ! + ! Write null dataset. Nothing can be written. + ! + null_data_dim(1) = 1 + CALL h5dwrite_f(null_dset, H5T_NATIVE_INTEGER, null_dset_data, null_data_dim, error) + CALL check("h5dwrite_f", error, total_error) ! @@ -97,12 +119,16 @@ ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) + CALL h5dclose_f(null_dset, 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) + CALL h5sclose_f(null_dspace, error) + CALL check("h5sclose_f", error, total_error) ! ! Close the file. @@ -121,6 +147,8 @@ ! CALL h5dopen_f(file_id, dsetname, dset_id, error) CALL check("h5dopen_f", error, total_error) + CALL h5dopen_f(file_id, null_dsetname, null_dset, error) + CALL check("h5dopen_f", error, total_error) ! ! Get the dataset type. @@ -139,6 +167,11 @@ ! CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error) CALL check("h5dread_f", error, total_error) + ! + ! Read the null dataset. Nothing should be read. + ! + CALL h5dread_f(null_dset, H5T_NATIVE_INTEGER, null_dset_data, null_data_dim, error) + CALL check("h5dread_f", error, total_error) ! !Compare the data. @@ -152,11 +185,20 @@ end do end do + ! + ! Check if no change to null_dset_data + ! + IF (null_dset_data .NE. 1) THEN + write(*, *) "null dataset test error occured" + END IF + ! ! End access to the dataset and release resources used by it. ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) + CALL h5dclose_f(null_dset, error) + CALL check("h5dclose_f", error, total_error) ! ! Terminate access to the data space. |