mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r16597] #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.
tested: h5committest
This commit is contained in:
parent
9fe1810527
commit
a75fb8d898
@ -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];
|
||||
}
|
||||
|
||||
|
||||
if (ret < 0) return ret_value;
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
if (ret < 0) return ret_value;
|
||||
ret_value = 0;
|
||||
return ret_value;
|
||||
}
|
||||
|
@ -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
|
||||
!-------------------------------------------------------------------------
|
||||
|
||||
|
||||
!has = h5ltfind_dataset_f(file_id,dsetname4)
|
||||
!if ( has .ne. 1 ) then
|
||||
! print *, 'h5ltfind_dataset_f return error'
|
||||
! stop
|
||||
!endif
|
||||
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
|
||||
|
||||
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.
|
||||
!
|
||||
|
Loading…
Reference in New Issue
Block a user