Hello

 

I’m have a hdf5, filled with some fill values, that is compressed. 

 

Now I need to had slices of information to this  hdf5 files. 

 

For this I used hyperslab and it works. 

 

My problem is that when I write the first slice it “seems to keep the
original compression” but when I write the second slice it loses
compression. 

 

A file that should have around 127 Mb has 193 Mb, below is the code that I’m
using:

 

NumType = H5T_NATIVE_DOUBLE

        

!Opens the Group

call h5gopen_f      (Me%FileID, GroupName, gr_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR10'

 

!Opens the DataSet

if (present(OutputNumber)) then

    call ConstructDSName (Name, OutputNumber, AuxChar)

else

    AuxChar = Name

endif

 

!Opens the Dataset

call h5dopen_f      (gr_id, trim(adjustl(AuxChar)), dset_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR20'

 

!Gets the data type id

call h5dget_type_f (dset_id, datatype_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR30'

 

call h5tget_class_f(datatype_id, class_id, STAT_CALL) 

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR40'

 

!Gets a handle of the dataspace

call h5dget_space_f (dset_id, space_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR50'

 

!Gets the rank

call h5sget_simple_extent_ndims_f (space_id, rank, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR60'

 

!Gets the size

call h5sget_simple_extent_dims_f  (space_id, dims, maxdims, STAT_CALL)

if (STAT_CALL < SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR70'

 

lower_bound(:) = FillValueInt

upper_bound(:) = FillValueInt

 

lower_bound(1) = Me%Limits%ILB

upper_bound(1) = Me%Limits%IUB

 

if (rank >=2) then

    lower_bound(2) = Me%Limits%JLB

    upper_bound(2) = Me%Limits%JUB

endif

 

if (rank >=3) then

    lower_bound(3) = Me%Limits%KLB

    upper_bound(3) = Me%Limits%KUB

endif

 

allocate (offset_in (rank))

allocate (count_in  (rank))

 

if (present(OffSet1)) then

    offset_in(1) = OffSet1

else    

    offset_in(1) = lower_bound(1) - 1    

endif

 

if (Rank >=2) then

    if (present(OffSet2)) then

        offset_in(2) = OffSet2

    else    

        offset_in(2) = lower_bound(2) - 1    

    endif

endif    

 

if (Rank >=3) then

    stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR80'

endif

 

count_in (1:rank) = upper_bound(1:rank) - lower_bound(1:rank) + 1

 

!Defines the hyperslab in the dataset

call h5sselect_hyperslab_f        (space_id, H5S_SELECT_SET_F, offset_in,
count_in, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR90'

 

!Defines the memory dataspace

dims_mem(1) = upper_bound(1)-lower_bound(1) + 1

dims_mem(2) = upper_bound(2)-lower_bound(2) + 1

 

call h5screate_simple_f (rank, dims_mem, memspace_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR100'

 

call h5dwrite_f (dset_id, NumType, Array2D, dims_mem, STAT_CALL,
memspace_id, space_id)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR110'

 

!Deallocates temporary matrixes

deallocate (offset_in )

deallocate (count_in  )

 

!Closes data space

call h5sclose_f  (space_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR120'

 

!End access to the dataset

call h5dclose_f  (dset_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR130'

 

!Closes group

call h5gclose_f  (gr_id, STAT_CALL)

if (STAT_CALL /= SUCCESS_) stop 'HDF5WriteWindowR8_2D - ModuleHDF5 - ERR140'

 

How can I keep the compression in the final hdf5 file?

 

Regards

João Ribeiro

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

Reply via email to