write_vstr1d Subroutine

private subroutine write_vstr1d(location, dset_name, value, length, id_out)

Write 1d variable string array to hdf5 file

Arguments

Type IntentOptional 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

Calls

proc~~write_vstr1d~~CallsGraph proc~write_vstr1d write_vstr1d h5dclose_f h5dclose_f proc~write_vstr1d->h5dclose_f h5dcreate_f h5dcreate_f proc~write_vstr1d->h5dcreate_f h5dwrite_vl_f h5dwrite_vl_f proc~write_vstr1d->h5dwrite_vl_f h5sclose_f h5sclose_f proc~write_vstr1d->h5sclose_f h5screate_simple_f h5screate_simple_f proc~write_vstr1d->h5screate_simple_f h5tclose_f h5tclose_f proc~write_vstr1d->h5tclose_f h5tcopy_f h5tcopy_f proc~write_vstr1d->h5tcopy_f h5tset_size_f h5tset_size_f proc~write_vstr1d->h5tset_size_f

Called by

proc~~write_vstr1d~~CalledByGraph proc~write_vstr1d write_vstr1d proc~hdf5_data_create hdf5_data_create proc~hdf5_data_create->proc~write_vstr1d proc~hdf5_init hdf5_t%hdf5_init proc~hdf5_init->proc~hdf5_data_create

Source Code

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