| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=hid_t), | intent(in) | :: | location |
hdf5 file or group id |
||
| character(len=*), | intent(in) | :: | dset_name | |||
| character(len=*), | intent(in) | :: | value(..) |
from rank 1 up to rank 3 |
||
| integer(kind=hid_t), | intent(out), | optional | :: | id_out |
subroutine write_str_arr(location,dset_name,value,id_out) integer(hid_t), intent(in) :: location !! hdf5 file or group id character(*), intent(in) :: dset_name character(*), intent(in) :: value(..) !! from rank 1 up to rank 3 integer(hid_t), optional, intent(out) :: id_out integer(hid_t) :: dspc_id, dset_id, tstr_id integer(hsize_t) :: dims(7),str_len integer :: err, rank_in rank_in = rank(value) dims = 0 dims(1:rank_in) = shape(value) select rank(value) rank(1) str_len = len(value(1)) rank(2) str_len = len(value(1,1)) rank(3) str_len = len(value(1,1,1)) rank default print *, "array can be only rank from 1 to 3" end select call h5tcopy_f(H5T_FORTRAN_S1, tstr_id, err) call h5tset_cset_f(tstr_id, H5T_CSET_ASCII_F, err) call h5tset_size_f(tstr_id, str_len, err) call h5screate_simple_f(rank_in, dims, dspc_id, err) call h5dcreate_f(location, dset_name, tstr_id, dspc_id, dset_id, err) select rank(value) rank(1) call h5dwrite_f(dset_id, tstr_id, value, dims, err, dspc_id) rank(2) call h5dwrite_f(dset_id, tstr_id, value, dims, err, dspc_id) rank(3) call h5dwrite_f(dset_id, tstr_id, value, dims, err, dspc_id) end select call h5tclose_f(tstr_id,err) call h5sclose_f(dspc_id,err) if (present(id_out)) then id_out = dset_id else call h5dclose_f(dset_id,err) endif end subroutine write_str_arr