KronLinInv  0.3
Kronecker-product-based linear inversion

◆ readreal1darrh5()

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

Definition at line 261 of file rdwrhdf5.f08.

261 
262  implicit none
263  character(len=1024),intent(in) :: inpfile
264  real(dp),allocatable,intent(inout) :: arr(:)
265  character(len=*),intent(in) :: dsetname
266 
267  ! filename length must be the same than in dummy variable
268  integer(hid_t) :: file_id,dset_id
269  integer :: rank,error
270  integer(hid_t) :: dataspace_id
271  integer(hsize_t),allocatable :: data_dims(:),maxdims(:)
272 
273  ! Initialize FORTRAN interface.
274  CALL h5open_f(error)
275  ! Open an existing file.
276  !print*, 'Reading ',trim(inpfile)
277  CALL h5fopen_f(trim(inpfile), h5f_acc_rdonly_f, file_id, error)
278  if (error/=0) then
279  write(*,*)
280  write(*,*) "Error opening file from hdf5. "
281  write(*,*) "filename: ",trim(inpfile)
282  stop
283  endif
284 
285  ! Open an existing dataset.
286  call h5dopen_f(file_id, trim(dsetname), dset_id, error)
287  if (error/=0) then
288  write(*,*)
289  write(*,*) "Error opening file from hdf5. "
290  write(*,*) "err dsetname: ",trim(dsetname)
291  stop
292  endif
293  ! get the dataspace id
294  call h5dget_space_f(dset_id, dataspace_id, error)
295  ! get the rank of the dataset
296  call h5sget_simple_extent_ndims_f(dataspace_id, rank, error)
297  allocate(data_dims(rank),maxdims(rank))
298  ! get the dimensions of the dataset
299  call h5sget_simple_extent_dims_f(dataspace_id, data_dims, maxdims, error)
300  !print*,'rank:',rank,'maxdims:',maxdims
301  ! get the datatype
302  !call h5dget_type_f(dset_id, datatype_id, error)
303  allocate(arr(data_dims(1)))
304  print*,"Reading ",trim(dsetname), " with shape ", data_dims
305  ! read data
306  CALL h5dread_f(dset_id, h5t_ieee_f64le, arr, data_dims, error)
307  ! Close the dataset.
308  CALL h5dclose_f(dset_id, error)
309  ! close the datatype
310 
311  ! Close the file.
312  CALL h5fclose_f(file_id, error)
313  ! Close FORTRAN interface.
314  CALL h5close_f(error)
315 
316  return
Here is the caller graph for this function: