Compile error while appending compound data type to chunked dataset FORTRAN


I am fairly new to HDF5 and I am trying to create a 2D dataset of a compound datatype. My goal is to create is such a way that each row can be appended to the dataset. I managed to create the dataset write once in it but when I try to append to the dataset later I get a compile error as follow
`s%dset_id, this%memtype, f_ptr, counts, this% error, mem_s, this%dspace_id)
Error: There is no specific subroutine for the generic ‘h5dwrite_f’ at (1)
Makefile:8: recipe for target ‘hdf5output.o’ failed``

My understanding of this is that the function has thinks I am giving in the wrong input to the subroutine. I would be really grateful if I could get any input on things I am doing incorrectly. I am not able to upload the simple test case program I created since I am new user. But here are the excerpts of some of the routines I call.

    call h5tcreate_f(H5T_COMPOUND_F, H5OFFSETOF(C_LOC(swrm(1)),C_LOC(swrm(2))), & 
                                                              file%memtype, file%error)
call h5tinsert_f(file%memtype, "id number", H5OFFSETOF(C_LOC(swrm(1)),C_LOC(swrm(1)%idnr)), &
                                                                              H5T_NATIVE_INTEGER, file%error)
call h5tinsert_f(file%memtype, "number of particles", H5OFFSETOF(C_LOC(swrm(1)),C_LOC(swrm(1)%npar)), &
                                                                              H5T_NATIVE_DOUBLE, file%error)
call h5tinsert_f(file%memtype, "cylindrical radius", H5OFFSETOF(C_LOC(swrm(1)),C_LOC(swrm(1)%rdis)), &
                                                                              H5T_NATIVE_DOUBLE, file%error)
call h5tinsert_f(file%memtype, "height above midplane", H5OFFSETOF(C_LOC(swrm(1)),C_LOC(swrm(1)%zdis)), &
                                                                              H5T_NATIVE_DOUBLE, file%error)
call h5tinsert_f(file%memtype, "Stokes number", H5OFFSETOF(C_LOC(swrm(1)),C_LOC(swrm(1)%stnr)), &
                                                                              H5T_NATIVE_DOUBLE, file%error) 
! initialize datapsace, dataset and write initial data

dims(1:rank-1) = shape(swrm)
dims(rank) = 1
chunkdims(1:rank-1) = shape(swrm)
chunkdims(rank) = 1
maxdims(1:rank-1) = shape(swrm)
maxdims(rank) = H5S_UNLIMITED_F

call h5screate_simple_f(rank, dims, file%dspace_id, file% error, maxdims) ! create chunked dataspace
call h5pcreate_f(H5P_DATASET_CREATE_F, file%prop_list, file%error) ! create chunkable dataset
call h5pset_chunk_f(file%prop_list, rank, chunkdims, file%error) ! chunk the dataset

!write data to the dataset
call h5dcreate_f(file%swarms, ‘swarm list’, file%memtype, file%dspace_id, file%dset_id, file% error, file%prop_list)
f_ptr = C_LOC(swrm(1))
call h5dwrite_f(file%dset_id, file%memtype, f_ptr, file% error)

call h5pclose_f(file%prop_list, file%error)
call h5dclose_f(file%dset_id, file% error)
call h5sclose_f(file%dspace_id, file% error)

!extend chunked dataset and append to it
call h5dopen_f(file%swarms, 'swarm list', file%dset_id, file%error)
call h5dget_space_f(file%dset_id, file%dspace_id, file%error)
call h5sget_simple_extent_dims_f(file%dspace_id, dims, maxdims, file%error)

extdims(1:rank-1) = dims(1:rank-1)
extdims(rank) = dims(rank) + 1

call h5dset_extent_f(file%dset_id, extdims, file%error)

offset(1:rank-1) = 0
offset(rank) = dims(rank)
counts(1:rank-1) = shape(swrm)
counts(rank) = 1

!create initialize dataspace for slice to be appended
call h5screate_simple_f(rank, counts, mem_space, file% error)
call h5sselect_hyperslab_f(file%dspace_id, H5S_SELECT_SET_F, offset, counts, file%error)
f_ptr = C_LOC(swrm(1))
call h5dwrite_f(file%dset_id, file%memtype, f_ptr, counts, file% error, mem_space, file%dspace_id)

Apologies if I missed some things, this is my first time posting on any programming forum.

Thank you!


You must remove the “counts” argument as there is no “counts” argument in the Fortran 2003 H5Dwrite_f call.


1 Like

Thank you. This solved it! Thanks a lot!