56 character(len=1024),
intent(in) :: outfile
57 real(dp),
intent(in) :: arr(:)
58 character(len=*),
intent(in) :: dsetname
61 integer(hid_t) :: file_id
62 integer(hid_t) :: dset_id
64 integer(hid_t) :: dspace_id
65 integer(hsize_t),
dimension(1) :: data_dims1
70 integer :: filter_info
71 integer :: filter_info_both
72 integer(hid_t) :: dcpl
73 integer :: chunkingfactor
74 integer(hsize_t),
dimension(1) :: chunk1
90 call h5zfilter_avail_f(h5z_filter_deflate_f, avail, error)
92 write(*,
'("gzip filter not available.",/)')
95 call h5zget_filter_info_f(h5z_filter_deflate_f, filter_info, error)
96 filter_info_both=ior(h5z_filter_encode_enabled_f,h5z_filter_decode_enabled_f)
97 if (filter_info .ne. filter_info_both)
then 98 write(*,
'("gzip filter not available for encoding and decoding.",/)')
104 call h5fcreate_f(trim(adjustl(outfile)), h5f_acc_trunc_f,file_id,error)
108 call h5fopen_f(trim(adjustl(outfile)), h5f_acc_rdwr_f, file_id, error)
116 data_dims1=shape(arr)
117 chunk1 = data_dims1/chunkingfactor
121 call h5screate_simple_f (rank, data_dims1, dspace_id, error)
125 call h5pcreate_f(h5p_dataset_create_f, dcpl, error)
126 call h5pset_deflate_f(dcpl, 9, error)
127 call h5pset_chunk_f(dcpl, rank, chunk1, error)
130 call h5dcreate_f(file_id, dsetname, h5t_ieee_f64le, dspace_id, &
131 dset_id, error, dcpl)
134 call h5dwrite_f(dset_id,h5t_ieee_f64le, arr, data_dims1, error)
137 call h5pclose_f(dcpl,error)
139 call h5sclose_f(dspace_id, error)
141 call h5dclose_f(dset_id, error)
148 call h5fclose_f(file_id, error)
150 call h5close_f(error)
159 character(len=1024),
intent(in) :: outfile
160 real(dp),
intent(in) :: arr(:,:)
161 character(len=*),
intent(in) :: dsetname
164 integer(hid_t) :: file_id
165 integer(hid_t) :: dset_id
167 integer(hid_t) :: dspace_id
168 integer(hsize_t),
dimension(2) :: data_dims2
173 integer :: filter_info
174 integer :: filter_info_both
175 integer(hid_t) :: dcpl
176 integer :: chunkingfactor
177 integer(hsize_t),
dimension(2) :: chunk2
193 call h5zfilter_avail_f(h5z_filter_deflate_f, avail, error)
195 write(*,
'("gzip filter not available.",/)')
198 call h5zget_filter_info_f(h5z_filter_deflate_f, filter_info, error)
199 filter_info_both=ior(h5z_filter_encode_enabled_f,h5z_filter_decode_enabled_f)
200 if (filter_info .ne. filter_info_both)
then 201 write(*,
'("gzip filter not available for encoding and decoding.",/)')
207 call h5fcreate_f(trim(adjustl(outfile)), h5f_acc_trunc_f,file_id,error)
211 call h5fopen_f(trim(adjustl(outfile)), h5f_acc_rdwr_f, file_id, error)
219 data_dims2=shape(arr)
220 chunk2 = data_dims2/chunkingfactor
224 call h5screate_simple_f(rank, data_dims2, dspace_id, error)
228 call h5pcreate_f(h5p_dataset_create_f, dcpl, error)
229 call h5pset_deflate_f(dcpl, 9, error)
230 call h5pset_chunk_f(dcpl, rank, chunk2, error)
233 call h5dcreate_f(file_id, dsetname, h5t_ieee_f64le, dspace_id, &
234 dset_id, error, dcpl)
237 call h5dwrite_f(dset_id,h5t_ieee_f64le, arr, data_dims2, error)
240 call h5pclose_f(dcpl,error)
242 call h5sclose_f(dspace_id, error)
244 call h5dclose_f(dset_id, error)
251 call h5fclose_f(file_id, error)
253 call h5close_f(error)
263 character(len=1024),
intent(in) :: inpfile
264 real(dp),
allocatable,
intent(inout) :: arr(:)
265 character(len=*),
intent(in) :: dsetname
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(:)
277 CALL h5fopen_f(trim(inpfile), h5f_acc_rdonly_f, file_id, error)
280 write(*,*)
"Error opening file from hdf5. " 281 write(*,*)
"filename: ",trim(inpfile)
286 call h5dopen_f(file_id, trim(dsetname), dset_id, error)
289 write(*,*)
"Error opening file from hdf5. " 290 write(*,*)
"err dsetname: ",trim(dsetname)
294 call h5dget_space_f(dset_id, dataspace_id, error)
296 call h5sget_simple_extent_ndims_f(dataspace_id, rank, error)
297 allocate(data_dims(rank),maxdims(rank))
299 call h5sget_simple_extent_dims_f(dataspace_id, data_dims, maxdims, error)
303 allocate(arr(data_dims(1)))
304 print*,
"Reading ",trim(dsetname),
" with shape ", data_dims
306 CALL h5dread_f(dset_id, h5t_ieee_f64le, arr, data_dims, error)
308 CALL h5dclose_f(dset_id, error)
312 CALL h5fclose_f(file_id, error)
314 CALL h5close_f(error)
324 character(len=1024),
intent(in) :: inpfile
325 real(dp),
allocatable,
intent(inout) :: arr(:,:)
326 character(len=*),
intent(in) :: dsetname
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(:)
338 CALL h5fopen_f(trim(inpfile), h5f_acc_rdonly_f, file_id, error)
341 write(*,*)
"Error opening file from hdf5. " 342 write(*,*)
"filename: ",trim(inpfile)
347 call h5dopen_f(file_id, trim(dsetname), dset_id, error)
350 write(*,*)
"Error opening file from hdf5. " 351 write(*,*)
"err dsetname: ",trim(dsetname)
355 call h5dget_space_f(dset_id, dataspace_id, error)
357 call h5sget_simple_extent_ndims_f(dataspace_id, rank, error)
358 allocate(data_dims(rank),maxdims(rank))
360 call h5sget_simple_extent_dims_f(dataspace_id, data_dims, maxdims, error)
364 allocate(arr(data_dims(1),data_dims(2)))
365 print*,
"Reading ",trim(dsetname),
" with shape ", data_dims
367 CALL h5dread_f(dset_id, h5t_ieee_f64le, arr, data_dims, error)
369 CALL h5dclose_f(dset_id, error)
373 CALL h5fclose_f(file_id, error)
375 CALL h5close_f(error)
388 integer(hsize_t),
dimension(:),
intent(inout) :: chunk
390 where ( chunk < 1 ) chunk=1
subroutine checkchunking(chunk)
subroutine writereal1darrh5(outfile, dsetname, arr)
Module to read and write HDF5 files.
subroutine readreal2darrh5(inpfile, dsetname, arr)
subroutine writereal2darrh5(outfile, dsetname, arr)
This file contains the parallel OpenMPI (distributed memory) version of KronLinInv. OpenMPI and LAPACK libraries are required to be installed in the system.
logical, private h5firsttimeread
subroutine readreal1darrh5(inpfile, dsetname, arr)