Write 1d variable string array to hdf5 file
| 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 scalar up to rank 3 |
||
| integer(kind=size_t), | intent(in) | :: | length(:) | |||
| integer(kind=hid_t), | intent(out), | optional | :: | id_out |
subroutine write_vstr1d(location,dset_name,value,length,id_out) !! Write 1d variable string array to hdf5 file integer(hid_t), intent(in) :: location !! hdf5 file or group id character(*), intent(in) :: dset_name character(*), intent(in) :: value(:) !! from scalar up to rank 3 integer(size_t), intent(in) :: length(:) integer(hid_t), optional, intent(out) :: id_out integer(hid_t) :: dspc_id, dset_id, tstr_id integer(hsize_t) :: dims2(2),dims1(1) integer :: err dims2(1) = len(value) dims2(2) = size(value) dims1(1) = dims2(2) call h5tcopy_f(H5T_C_S1, tstr_id, err) call h5tset_size_f(tstr_id, -1_hsize_t, err) call h5screate_simple_f(1, dims1, dspc_id, err) call h5dcreate_f(location, dset_name, tstr_id, dspc_id, dset_id, err) call h5dwrite_vl_f(dset_id, tstr_id, value, dims2, length, err, dspc_id) 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_vstr1d