[HDF5] problem of h5ltread_dataset_f and short integer

Hello,

I try to use the function h5ltread_dataset_f to read a integer(kind=1)
array.

An example of my code is at :
https://code.google.com/p/amelet-hdf/source/browse/amelethdf-fortran/trunk/src/amelethdf/unstructuredmesh.f90#107

I have to read values in a temporary integer(kind=4) array otherwise the
compiler says there is no function to read the dataset :

! Elements definition

type unstructured_mesh_t
...
integer(kind=1), dimension(:), allocatable :: elements
...
end type unstructured_mesh_t

....
! Elements reading

integer, dimension(:), allocatable :: tmpelements

allocate(umesh%elements(one_dims(1)))

allocate(tmpelements(one_dims(1)))

call h5ltread_dataset_f(file_id, path, H5T_NATIVE_INTEGER_4, &

tmpelements, one_dims, hdferr)

umesh%elements = tmpelements

deallocate(tmpelements)

I thought I could write :

call h5ltread_dataset_f(file_id, path, H5T_NATIVE_INTEGER_1, &

umesh%elements, one_dims, hdferr)

Is there anything I do wrong ?

I use HDF5 1.8.6 with ifort under Linux Ubuntu 10.04

Thanks a lot,

Best regards,

Cyril.

Currently you can only use the high level functions for reading the default integer type (i.e. 4 bytes or if -i8, 8 bytes) since the input buffer is declared
INTEGER, INTENT(inout), ..... :: buf.

The lower level function h5dread_f also only supports reading the default integer for the same reason.

There is a Fortran 2003 hdf5 function for h5dread_f where the call would be:

     USE ISO_C_BINDING
     TYPE(C_PTR) :: f_ptr

     f_ptr = C_LOC(umesh%elements(1))
     CALL H5Dread_f(dataset, H5T_NATIVE_INTEGER_1, f_ptr, error)

but it's currently only available in a development branch and only for the lower level functions.

BTW, kind=1 is not standard since it's up to the compiler vendor to determine if kind=bytes or not, you should select the integer kind using selected_integer_kind, which will also tell you if integer*1 is available.

···

On 03/15/2011 05:59 AM, Giraudon Cyril wrote:

Hello,

I try to use the function h5ltread_dataset_f to read a integer(kind=1)
array.

An example of my code is at :
https://code.google.com/p/amelet-hdf/source/browse/amelethdf-fortran/trunk/src/amelethdf/unstructuredmesh.f90#107

I have to read values in a temporary integer(kind=4) array otherwise the
compiler says there is no function to read the dataset :

! Elements definition

type unstructured_mesh_t
...
integer(kind=1), dimension(:), allocatable :: elements
...
end type unstructured_mesh_t

....
! Elements reading

integer, dimension(:), allocatable :: tmpelements

allocate(umesh%elements(one_dims(1)))

allocate(tmpelements(one_dims(1)))

call h5ltread_dataset_f(file_id, path, H5T_NATIVE_INTEGER_4,&

tmpelements, one_dims, hdferr)

umesh%elements = tmpelements

deallocate(tmpelements)

I thought I could write :

call h5ltread_dataset_f(file_id, path, H5T_NATIVE_INTEGER_1,&

umesh%elements, one_dims, hdferr)

Is there anything I do wrong ?

I use HDF5 1.8.6 with ifort under Linux Ubuntu 10.04

Thanks a lot,

Best regards,

Cyril.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--

M. Scot Breitenfeld
The HDF Group
1800 South Oak Street
Suite 203
Champaign, IL 61820

brtnfld@hdfgroup.org
(217)531-6100 (office)
(217)333-9049 (fax)

Scot,

Thank you for the tip about selected_integer_kind.
I didn't know kind=1 is vendor dependent.

Regards,

Cyril.

Le 15/03/2011 17:02, Scot Breitenfeld a �crit :

···

Currently you can only use the high level functions for reading the
default integer type (i.e. 4 bytes or if -i8, 8 bytes) since the input
buffer is declared
INTEGER, INTENT(inout), ..... :: buf.

The lower level function h5dread_f also only supports reading the
default integer for the same reason.

There is a Fortran 2003 hdf5 function for h5dread_f where the call
would be:

    USE ISO_C_BINDING
    TYPE(C_PTR) :: f_ptr

    f_ptr = C_LOC(umesh%elements(1))
    CALL H5Dread_f(dataset, H5T_NATIVE_INTEGER_1, f_ptr, error)

but it's currently only available in a development branch and only for
the lower level functions.

BTW, kind=1 is not standard since it's up to the compiler vendor to
determine if kind=bytes or not, you should select the integer kind
using selected_integer_kind, which will also tell you if integer*1 is
available.

On 03/15/2011 05:59 AM, Giraudon Cyril wrote:

Hello,

I try to use the function h5ltread_dataset_f to read a integer(kind=1)
array.

An example of my code is at :
https://code.google.com/p/amelet-hdf/source/browse/amelethdf-fortran/trunk/src/amelethdf/unstructuredmesh.f90#107

I have to read values in a temporary integer(kind=4) array otherwise the
compiler says there is no function to read the dataset :

! Elements definition

type unstructured_mesh_t
...
integer(kind=1), dimension(:), allocatable :: elements
...
end type unstructured_mesh_t

....
! Elements reading

integer, dimension(:), allocatable :: tmpelements

allocate(umesh%elements(one_dims(1)))

allocate(tmpelements(one_dims(1)))

call h5ltread_dataset_f(file_id, path, H5T_NATIVE_INTEGER_4,&

tmpelements, one_dims, hdferr)

umesh%elements = tmpelements

deallocate(tmpelements)

I thought I could write :

call h5ltread_dataset_f(file_id, path, H5T_NATIVE_INTEGER_1,&

umesh%elements, one_dims, hdferr)

Is there anything I do wrong ?

I use HDF5 1.8.6 with ifort under Linux Ubuntu 10.04

Thanks a lot,

Best regards,

Cyril.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org