summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2009-03-23 20:04:55 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2009-03-23 20:04:55 (GMT)
commit9c9e2c6d7daae12fe44ffb1e66f2caaea65bc619 (patch)
tree66d7718485ced779ef0341e25d91e02dd6eeafa5 /hl
parent1598893d1403ff264bff1df49f647f3054b6f3f8 (diff)
downloadhdf5-9c9e2c6d7daae12fe44ffb1e66f2caaea65bc619.zip
hdf5-9c9e2c6d7daae12fe44ffb1e66f2caaea65bc619.tar.gz
hdf5-9c9e2c6d7daae12fe44ffb1e66f2caaea65bc619.tar.bz2
[svn-r16598] merge 16597 from trunk
#1047 (B1) The h5lt info routines are returning data in transposed form. ISSUE : the dimension array of the function h5ltget_dataset_info_f was not transposed (because of C-FORTRAN storage order, the FORTRAN function calls the C function with the same name). SOLUTION: transpose the array. ACTION: add a test case. added the note Fortran High-Level APIs: ------ - Lite: The h5ltget_dataset_info_f function (gets information about a dataset) was not correctly returning the dimension array (PVN - 2009/3/23) tested: linux
Diffstat (limited to 'hl')
-rwxr-xr-xhl/fortran/src/H5LTfc.c31
-rw-r--r--hl/fortran/test/tstlite.f9076
2 files changed, 86 insertions, 21 deletions
diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c
index 93d65ef..61c7547 100755
--- a/hl/fortran/src/H5LTfc.c
+++ b/hl/fortran/src/H5LTfc.c
@@ -1247,6 +1247,7 @@ nh5ltget_dataset_info_c(hid_t_f *loc_id,
size_t c_type_size;
hsize_t c_dims[32];
int i;
+ int c_rank;
/*
* Convert FORTRAN name to C name
@@ -1261,15 +1262,23 @@ nh5ltget_dataset_info_c(hid_t_f *loc_id,
c_loc_id = (hid_t)*loc_id;
ret = H5LTget_dataset_info(c_loc_id, c_name, c_dims, &c_classtype, &c_type_size);
+ if (ret < 0) return ret_value;
*type_class = c_classtype;
*type_size = (size_t_f)c_type_size;
- for (i = 0; i < 32 ; i++) {
- dims[i] = (hsize_t_f) c_dims[i];
- }
+ /*
+ * Transpose dimension arrays because of C-FORTRAN storage order
+ */
+ ret = H5LTget_dataset_ndims(c_loc_id, c_name, &c_rank);
if (ret < 0) return ret_value;
+
+ for (i = 0; i < c_rank ; i++) {
+ dims[i] = (hsize_t_f) c_dims[c_rank - i - 1];
+ }
+
+
ret_value = 0;
return ret_value;
}
@@ -1375,6 +1384,7 @@ nh5ltget_attribute_info_c(hid_t_f *loc_id,
size_t c_type_size;
hsize_t c_dims[32];
int i;
+ int c_rank;
/*
* Convert FORTRAN name to C name
@@ -1388,20 +1398,27 @@ nh5ltget_attribute_info_c(hid_t_f *loc_id,
if (c_attrname == NULL) return ret_value;
/*
- * Call H5LTget_dataset_ndims function.
+ * Call H5LTget_attribute_info function.
*/
c_loc_id = (hid_t)*loc_id;
ret = H5LTget_attribute_info(c_loc_id,c_name,c_attrname,c_dims,&c_classtype,&c_type_size);
+ if (ret < 0) return ret_value;
*type_class = c_classtype;
*type_size = (size_t_f)c_type_size;
- for (i = 0; i < 32 ; i++) {
- dims[i] = (hsize_t_f) c_dims[i];
- }
+/*
+ * Transpose dimension arrays because of C-FORTRAN storage order
+ */
+ ret = H5LTget_attribute_ndims(c_loc_id,c_name,c_attrname,&c_rank);
if (ret < 0) return ret_value;
+
+ for (i = 0; i < c_rank ; i++) {
+ dims[i] = (hsize_t_f) c_dims[c_rank - i - 1];
+ }
+
ret_value = 0;
return ret_value;
}
diff --git a/hl/fortran/test/tstlite.f90 b/hl/fortran/test/tstlite.f90
index c261ad8..9332c10 100644
--- a/hl/fortran/test/tstlite.f90
+++ b/hl/fortran/test/tstlite.f90
@@ -379,6 +379,7 @@ character(LEN=5), parameter :: dsetname3 = "dset3" ! Dataset name
character(LEN=5), parameter :: dsetname4 = "dset4" ! Dataset name
integer(HID_T) :: file_id ! File identifier
integer(HSIZE_T), dimension(3) :: dims = (/DIM1,DIM2,DIM3/) ! Dataset dimensions
+integer(HSIZE_T), dimension(3) :: dimsr ! Dataset dimensions
integer, dimension(DIM1*DIM2*DIM3) :: buf ! Data buffer
integer, dimension(DIM1*DIM2*DIM3) :: bufr ! Data buffer
integer, dimension(DIM1,DIM2,DIM3) :: buf2 ! Data buffer
@@ -390,6 +391,8 @@ double precision, dimension(DIM1,DIM2,DIM3) :: buf4r ! Data buffer
integer :: rank = 3 ! Dataset rank
integer :: errcode ! Error flag
integer :: i, j, k, n ! general purpose integers
+integer :: type_class
+integer(SIZE_T) :: type_size
call test_begin(' Make/Read datasets (3D) ')
@@ -537,6 +540,18 @@ do i = 1, dims(1)
end do
end do
+call h5ltget_dataset_info_f(file_id,dsetname4,dimsr,type_class,type_size,errcode )
+
+!
+! compare dimensions
+!
+do i = 1, rank
+ if ( dimsr(i) .ne. dims(i) ) then
+ print *, 'dimensions differ '
+ stop
+ endif
+end do
+
!
! Close the file.
!
@@ -574,6 +589,7 @@ character(LEN=5), parameter :: dsetname1 = "dset1" ! Dataset name
character(LEN=5), parameter :: dsetname2 = "dset2" ! Dataset name
character(LEN=5), parameter :: dsetname3 = "dset3" ! Dataset name
character(LEN=5), parameter :: dsetname4 = "dset4" ! Dataset name
+character(LEN=5), parameter :: dsetname5 = "dset5" ! Dataset name
integer(HSIZE_T), dimension(1) :: dims = (/DIM1/) ! Dataset dimensions
integer(HSIZE_T), dimension(1) :: dimsr ! Dataset dimensions
integer :: rank = 1 ! Dataset rank
@@ -701,7 +717,7 @@ end do
call passed()
-call test_begin(' Get dataset dimensions ')
+call test_begin(' Get dataset dimensions/info ')
!-------------------------------------------------------------------------
! h5ltget_dataset_ndims_f
@@ -713,20 +729,39 @@ if ( rankr .ne. rank ) then
stop
endif
-call passed()
!-------------------------------------------------------------------------
-! test find dataset function
+! test h5ltfind_dataset_f function
!-------------------------------------------------------------------------
-call test_begin(' Find dataset ')
+has = h5ltfind_dataset_f(file_id,dsetname4)
+if ( has .ne. 1 ) then
+ print *, 'h5ltfind_dataset_f return error'
+ stop
+endif
+
+!-------------------------------------------------------------------------
+! test h5ltget_dataset_info_f function
+!-------------------------------------------------------------------------
+
+
+call h5ltget_dataset_info_f(file_id,dsetname4,dimsr,type_class,type_size,errcode )
+
+!
+! compare dimensions
+!
+do i = 1, rank
+ if ( dimsr(i) .ne. dims(i) ) then
+ print *, 'dimensions differ '
+ stop
+ endif
+end do
-!has = h5ltfind_dataset_f(file_id,dsetname4)
-!if ( has .ne. 1 ) then
-! print *, 'h5ltfind_dataset_f return error'
-! stop
-!endif
+if ( type_class .ne. 1 ) then ! H5T_FLOAT
+ print *, 'wrong type class '
+ stop
+endif
!
! Close the file.
@@ -756,15 +791,16 @@ use HDF5 ! module of HDF5 library
implicit none
-character(len=9), parameter :: filename = "dsetf4.h5"! File name
+character(len=9), parameter :: filename = "dsetf5.h5"! File name
integer(HID_T) :: file_id ! File identifier
integer, parameter :: DIM1 = 10; ! Dimension of array
character(LEN=5), parameter :: attrname1 = "attr1" ! Attribute name
character(LEN=5), parameter :: attrname2 = "attr2" ! Attribute name
character(LEN=5), parameter :: attrname3 = "attr3" ! Attribute name
character(LEN=5), parameter :: attrname4 = "attr4" ! Attribute name
-character(LEN=8), parameter :: buf1 = "mystring" ! Data buffer
-character(LEN=8) :: bufr1 ! Data buffer
+character(LEN=5), parameter :: attrname5 = "attr5" ! Attribute name
+character(LEN=9), parameter :: buf1 = "mystring" ! Data buffer
+character(LEN=9) :: bufr1 ! Data buffer
integer, dimension(DIM1) :: buf2 ! Data buffer
integer, dimension(DIM1) :: bufr2 ! Data buffer
real, dimension(DIM1) :: buf3 ! Data buffer
@@ -900,12 +936,11 @@ end do
call passed()
-
!-------------------------------------------------------------------------
! get attribute rank
!-------------------------------------------------------------------------
-call test_begin(' Get attribute rank ')
+call test_begin(' Get attribute rank/info ')
call h5ltget_attribute_ndims_f(file_id,dsetname1,attrname2,rankr,errcode)
@@ -916,6 +951,19 @@ if ( rankr .ne. 1 ) then
endif
+call h5ltget_attribute_info_f(file_id,dsetname1,attrname2,dimsr,type_class,type_size,errcode)
+
+!
+! compare dimensions
+!
+do i = 1, rank
+ if ( dimsr(i) .ne. dims(i) ) then
+ print *, 'dimensions differ '
+ stop
+ endif
+end do
+
+
!
! Close the file.
!