KronLinInv  0.3
Kronecker-product-based linear inversion

◆ readreal2darrh5()

subroutine readwriteh5::readreal2darrh5 ( character(len=1024), intent(in)  inpfile,
character(len=*), intent(in)  dsetname,
real(dp), dimension(:,:), intent(inout), allocatable  arr 
)

Definition at line 322 of file rdwrhdf5.f08.

322 
323  implicit none
324  character(len=1024),intent(in) :: inpfile
325  real(dp),allocatable,intent(inout) :: arr(:,:)
326  character(len=*),intent(in) :: dsetname
327 
328  ! filename length must be the same than in dummy variable
329  integer(hid_t) :: file_id,dset_id
330  integer :: rank,error
331  integer(hid_t) :: dataspace_id
332  integer(hsize_t),allocatable :: data_dims(:),maxdims(:)
333 
334  ! Initialize FORTRAN interface.
335  CALL h5open_f(error)
336  ! Open an existing file.
337  !print*, 'Reading ',trim(inpfile)
338  CALL h5fopen_f(trim(inpfile), h5f_acc_rdonly_f, file_id, error)
339  if (error/=0) then
340  write(*,*)
341  write(*,*) "Error opening file from hdf5. "
342  write(*,*) "filename: ",trim(inpfile)
343  stop
344  endif
345 
346  ! Open an existing dataset.
347  call h5dopen_f(file_id, trim(dsetname), dset_id, error)
348  if (error/=0) then
349  write(*,*)
350  write(*,*) "Error opening file from hdf5. "
351  write(*,*) "err dsetname: ",trim(dsetname)
352  stop
353  endif
354  ! get the dataspace id
355  call h5dget_space_f(dset_id, dataspace_id, error)
356  ! get the rank of the dataset
357  call h5sget_simple_extent_ndims_f(dataspace_id, rank, error)
358  allocate(data_dims(rank),maxdims(rank))
359  ! get the dimensions of the dataset
360  call h5sget_simple_extent_dims_f(dataspace_id, data_dims, maxdims, error)
361  !print*,'rank:',rank,'maxdims:',maxdims
362  ! get the datatype
363  !call h5dget_type_f(dset_id, datatype_id, error)
364  allocate(arr(data_dims(1),data_dims(2)))
365  print*,"Reading ",trim(dsetname), " with shape ", data_dims
366  ! read data
367  CALL h5dread_f(dset_id, h5t_ieee_f64le, arr, data_dims, error)
368  ! Close the dataset.
369  CALL h5dclose_f(dset_id, error)
370  ! close the datatype
371 
372  ! Close the file.
373  CALL h5fclose_f(file_id, error)
374  ! Close FORTRAN interface.
375  CALL h5close_f(error)
376 
377  return
Here is the caller graph for this function: