integer_type_mismatch


#1

I am new in HDF - I want to compile a fortran program with HDF.
The source code contains the following:

   integer(hid_t)                      :: loc_id
   integer(hid_t)                      :: type_id
   character(LEN=*)                :: dsetname
   integer                                 :: length,n1
   character(LEN=length)        :: array
   
   integer            :: ierr
   integer(hid_t)  :: h5_dset
   
   integer(hsize_t), dimension(1) :: dims
 
   dims = (/ 1 /)
  
   call H5Tcopy_f(H5T_NATIVE_CHARACTER,type_id,ierr)
   call H5Tset_size_f(type_id,length,ierr)

   call H5Dopen_f(loc_id,trim(dsetname),h5_dset,ierr)
   call H5Dread_f(h5_dset,type_id,array,dims,ierr)
   call H5Dclose_f(h5_dset,ierr)

However, the compiler returns :

Type mismatch in argument ‘size’ at (1); passed INTEGER(4) to INTEGER(8)

(where at (1) means the end of the row " call H5Tset_size_f(type_id,length,ierr)")

Does anybody know where might be a problem??

Petr


#2

‘length’ should be integer(size_t), https://portal.hdfgroup.org/display/HDF5/H5T_SET_SIZE

SUBROUTINE h5tset_size_f(type_id, size, hdferr) 
  IMPLICIT NONE
  INTEGER(HID_T), INTENT(IN) :: type_id  ! Datatype identifier 
  INTEGER(SIZE_T), INTENT(IN) :: size    ! Datatype size
  INTEGER, INTENT(OUT) :: hdferr         ! Error code
                                         ! 0 on success and -1 on failure
END SUBROUTINE h5tset_size_f

#3

Hi brtnfld, now it works !!

However, there immediately emerged another bunch of errors, that I tried to solve in a similar way but still with no success:
The declaration of variables looks like:

integer, parameter :: nb_int=23,nb_real=5
integer, dimension(nb_int) :: para_int
integer, dimension(3 ) :: nx_p
integer :: nl1,nl2,nl3
integer :: i,j,k,l,NNx,NNy,NNz,ish
integer(HID_T) :: file_id !< File identifiers
integer :: error !< Flag to check operation success
integer :: n1,n2,n3,n4
double precision, dimension(nb_real) :: para_real
real, dimension(:,:,:), allocatable :: T1
real :: U,P,T
character(len=23) :: filename
character(len=5 ) :: para_string

It gives the following error messages and warnings:

…/src/hdf/rd_restart_h5.f90:149:63:

call get_1d_array_string_h5(file_id,“geometry”,para_string,5)
1
Error: Type mismatch in argument ‘length’ at (1); passed INTEGER(4) to INTEGER(8)
…/src/hdf/rd_restart_h5.f90:162:20:

u_M = para_real(6)
1
Warning: Array reference at (1) is out of bounds (6 > 5) in dimension 1
…/src/hdf/rd_restart_h5.f90:163:20:

u_L = para_real(7)
1
Warning: Array reference at (1) is out of bounds (7 > 5) in dimension 1
…/src/hdf/rd_restart_h5.f90:164:20:

u_T = para_real(8)
1
Warning: Array reference at (1) is out of bounds (8 > 5) in dimension 1
…/src/hdf/rd_restart_h5.f90:167:78:

call get_1d_array_h5(file_id,“x_glob”,x_glob(1:nx_glob(1)+1,1),nx_glob(1)+1)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:170:82:

all get_1d_array_h5(file_id,“y_glob”,x_glob(1:nx_glob(2)+1,2)/u_L,nx_glob(2)+1)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:173:82:

all get_1d_array_h5(file_id,“z_glob”,x_glob(1:nx_glob(2)+1,3)/u_L,nx_glob(3)+1)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:176:62:

call get_1d_array_h5(file_id,“x”,x(1:nx(1)+1,1)/u_L,nx(1)+1)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:179:62:

call get_1d_array_h5(file_id,“y”,x(1:nx(2)+1,2)/u_L,nx(2)+1)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:182:62:

call get_1d_array_h5(file_id,“z”,x(1:nx(3)+1,3)/u_L,nx(3)+1)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:185:64:

call get_1d_array_h5(file_id,“shift_gr”,shift_gr(1:ndim),ndim)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:191:50:

call get_3d_array_h5(file_id,“rho”,rho,n1,n2,n3)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:195:55:

call get_4d_array_h5(file_id,“rhou”,rhou,n1,n2,n3,n4)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:198:46:

call get_3d_array_h5(file_id,“E”,E,n1,n2,n3)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:204:54:

  call get_4d_array_h5(file_id,"fx",fx,n1,n2,n3,n4)
                                                  1

Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:210:51:

  call get_3d_array_h5(file_id,"er",er,n1,n2,n3)
                                               1

Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:213:54:

  call get_4d_array_h5(file_id,"fr",fr,n1,n2,n3,n4)
                                                  1

Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:218:53:

  call get_3d_array_h5(file_id,"erd",erd,n1,n2,n3)
                                                 1

Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
…/src/hdf/rd_restart_h5.f90:224:49:

call get_4d_array_h5(file_id,“B”,B,n1,n2,n3,n4)
1
Error: Type mismatch in argument ‘array’ at (1); passed REAL(8) to REAL(16)
Makefile:159: recipe for target ‘rd_restart_h5.o’ failed
make: *** [rd_restart_h5.o] Error 1

Can you please give me a hint ??

Thanks Petr


#4

I would have to see the declarations of the subroutines, but in general, your data types are not matching what the subroutine expects.

For example, when you are passing a constant number, you will need to specify the type,

call get_1d_array_string_h5(file_id,“geometry”,para_string,INT(5,size_t) )

or

call get_1d_array_string_h5(file_id,“geometry”,para_string, 5_size_t )

Scot


#5

Thanks! I have rewritten the data types in the fortran code and now it seems this works well.
Anyway, there emerged another problem with “undefined references” which looks like this:

rdwrt_h5.o: In function __rdwrt_h5_MOD_get_1d_array_string_h5': rdwrt_h5.f90:(.text+0x19): undefined reference to__h5global_MOD_h5t_native_character’
rdwrt_h5.f90:(.text+0x43): undefined reference to __h5t_MOD_h5tcopy_f' rdwrt_h5.f90:(.text+0x55): undefined reference to__h5t_MOD_h5tset_size_f’
rdwrt_h5.f90:(.text+0x8e): undefined reference to __h5d_MOD_h5dopen_f' rdwrt_h5.f90:(.text+0xc2): undefined reference to__h5d_MOD_h5dread_char_scalar’ …

and a lot of other similar statements …

Petr


#6

Regarding the last answer - I guess the problem is in the path specification : I will try yet to improve the paths to hdf modules in the fortran calls

Thanks, Petr


#7

I have declared the paths to the hdf routines in the makefile:

F90_ = gfortran
F90_ = /usr/bin/mpif90 -DPARA=$(PARA)
LIBS_ = -llapack -lblas
PARALIBS_ = -L/usr/lib/mpich -I/usr/include/mpich
CPPFLAGS_ = -x f95-cpp-input -DSYSTEM
FFLAGS_ = -ffast-math -fdefault-real-8 -ffree-line-length-0 -O3

FFLAGS_ = -ffast-math -fdefault-real-8 -ffree-line-length-0 -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow,underflow -Wall

HDFINC_ = -I/usr/lib/x86_64-linux-gnu/hdf5/openmpi/include
HDFLIB_ = -L/usr/lib/x86_64-linux-gnu/hdf5/openmpi/lib -lhdf5 -lz

It neverhtheless returns the error messages of undefined references. I do not know how to improve it at the moment.

Thanks, Petr


#8

You can always look at the “h5pfc" wrapper in the “bin" install directory for the correct compilation command.

Scot