HDFGroup / hdf5

Official HDF5® Library Repository
Other
549 stars 237 forks source link

H5DRead_f Bug while compilation #4557

Closed ErikP94 closed 1 month ago

ErikP94 commented 1 month ago

Problem I can't compile a minimal Fortran example with HDF5. The Problem is one specific function call - h5dread_f:

I compiled with: gfortran -o hdf5_test hdf5_test_min.f90 -I/usr/local/hdf5/include/ -L/usr/local/hdf5/lib/ -lhdf5_fortran -lhdf5

hdf5_test_min.f90:64:67:

   64 |   call h5dread_f(dataset_id, dtype_id, C_Loc(element_read(1)), err)
      |                                                                   1
Error: There is no specific subroutine for the generic ‘h5dread_f’ at (1)

The minimal example contains a simple process, in which dummy data is created, then written to a hdf5 file (which works) and then the data shall be read. Please note, that the h5dwrite_f function call works. I suspect, that the input arguments are okay, since the same example works under MacOS and also because the h5dwrite_f call works.

Platform

ErikP94 commented 1 month ago

Here is a minimal example to reproduce the (maybe?) bug. hdf5_test_min.f90.txt

brtnfld commented 1 month ago

Since it is expecting something to be returned, try passing a variable of type(C_PTR) instead:

TYPE(C_PTR) :: f_ptr
f_ptr = C_LOC(element_orig(1))
call h5dread_f(dataset_id, dtype_id, f_ptr, err)
ErikP94 commented 1 month ago

Hi @brtnfld, thanks for the quick reply. This indeed seems to solve my problem!

brtnfld commented 1 month ago

Glad it works now.