write_str_arr Subroutine

private subroutine write_str_arr(location, dset_name, value, id_out)

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 rank 1 up to rank 3

integer(kind=hid_t), intent(out), optional :: id_out

Calls

proc~~write_str_arr~~CallsGraph proc~write_str_arr write_str_arr h5dclose_f h5dclose_f proc~write_str_arr->h5dclose_f h5dcreate_f h5dcreate_f proc~write_str_arr->h5dcreate_f h5dwrite_f h5dwrite_f proc~write_str_arr->h5dwrite_f h5sclose_f h5sclose_f proc~write_str_arr->h5sclose_f h5screate_simple_f h5screate_simple_f proc~write_str_arr->h5screate_simple_f h5tclose_f h5tclose_f proc~write_str_arr->h5tclose_f h5tcopy_f h5tcopy_f proc~write_str_arr->h5tcopy_f h5tset_cset_f h5tset_cset_f proc~write_str_arr->h5tset_cset_f h5tset_size_f h5tset_size_f proc~write_str_arr->h5tset_size_f

Called by

proc~~write_str_arr~~CalledByGraph proc~write_str_arr write_str_arr proc~hdf5_init hdf5_t%hdf5_init proc~hdf5_init->proc~write_str_arr

Source Code

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