hdf5_data_create Subroutine

private subroutine hdf5_data_create(tbl, group_id, time_id, name, vars, comps)

Arguments

Type IntentOptional Attributes Name
type(growing_h5_tbl_t), intent(inout) :: tbl
integer(kind=hid_t), intent(in) :: group_id
integer(kind=hid_t), intent(in) :: time_id
character(len=*), intent(in) :: name
character(len=*), intent(in) :: vars(:)
type(hdf_desc_p_t), intent(inout) :: comps(:)

Calls

proc~~hdf5_data_create~~CallsGraph proc~hdf5_data_create hdf5_data_create h5dclose_f h5dclose_f proc~hdf5_data_create->h5dclose_f h5dopen_f h5dopen_f proc~hdf5_data_create->h5dopen_f h5ltmake_dataset_f h5ltmake_dataset_f proc~hdf5_data_create->h5ltmake_dataset_f interface~to_str to_str proc~hdf5_data_create->interface~to_str proc~attach_scale attach_scale proc~hdf5_data_create->proc~attach_scale proc~tbl_h5_create_dbl tbl_h5_create_dbl proc~hdf5_data_create->proc~tbl_h5_create_dbl proc~write_atribute_int write_atribute_int proc~hdf5_data_create->proc~write_atribute_int proc~write_attribute_vstr1d write_attribute_vstr1d proc~hdf5_data_create->proc~write_attribute_vstr1d proc~write_vstr1d write_vstr1d proc~hdf5_data_create->proc~write_vstr1d proc~str_from_int str_from_int interface~to_str->proc~str_from_int proc~str_from_real str_from_real interface~to_str->proc~str_from_real h5dsattach_scale_f h5dsattach_scale_f proc~attach_scale->h5dsattach_scale_f h5dsset_label_f h5dsset_label_f proc~attach_scale->h5dsset_label_f h5dsset_scale_f h5dsset_scale_f proc~attach_scale->h5dsset_scale_f h5dcreate_f h5dcreate_f proc~tbl_h5_create_dbl->h5dcreate_f h5dwrite_f h5dwrite_f proc~tbl_h5_create_dbl->h5dwrite_f h5pclose_f h5pclose_f proc~tbl_h5_create_dbl->h5pclose_f h5pcreate_f h5pcreate_f proc~tbl_h5_create_dbl->h5pcreate_f h5pset_chunk_f h5pset_chunk_f proc~tbl_h5_create_dbl->h5pset_chunk_f h5sclose_f h5sclose_f proc~tbl_h5_create_dbl->h5sclose_f h5screate_simple_f h5screate_simple_f proc~tbl_h5_create_dbl->h5screate_simple_f h5aclose_f h5aclose_f proc~write_atribute_int->h5aclose_f h5acreate_f h5acreate_f proc~write_atribute_int->h5acreate_f h5awrite_f h5awrite_f proc~write_atribute_int->h5awrite_f proc~write_atribute_int->h5sclose_f proc~write_atribute_int->h5screate_simple_f proc~write_attribute_vstr1d->h5aclose_f proc~write_attribute_vstr1d->h5acreate_f proc~write_attribute_vstr1d->h5awrite_f proc~write_attribute_vstr1d->h5sclose_f proc~write_attribute_vstr1d->h5screate_simple_f h5tclose_f h5tclose_f proc~write_attribute_vstr1d->h5tclose_f h5tcopy_f h5tcopy_f proc~write_attribute_vstr1d->h5tcopy_f h5tset_size_f h5tset_size_f proc~write_attribute_vstr1d->h5tset_size_f proc~write_vstr1d->h5dclose_f proc~write_vstr1d->h5dcreate_f h5dwrite_vl_f h5dwrite_vl_f proc~write_vstr1d->h5dwrite_vl_f proc~write_vstr1d->h5sclose_f proc~write_vstr1d->h5screate_simple_f proc~write_vstr1d->h5tclose_f proc~write_vstr1d->h5tcopy_f proc~write_vstr1d->h5tset_size_f

Called by

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

Source Code

subroutine hdf5_data_create(tbl, group_id, time_id, name, vars, comps)
    type(growing_h5_tbl_t), intent(inout) :: tbl
    integer(hid_t),            intent(in) :: group_id, time_id
    character(*),              intent(in) :: name,vars(:)
    type(hdf_desc_p_t),       intent(inout) :: comps(:)

    type(hdf_desc_t), allocatable :: components(:)
    integer(hid_t)                :: x_id, var_id, name_id, cmp_id
    integer(hsize_t)              :: dims(8)
    real(dp),         allocatable :: x(:)
    integer(hsize_t), allocatable :: size_attr(:), size_cmp(:), size_name(:), size_var(:)
    integer,          allocatable :: int_attr(:)
    character(:),     allocatable :: str_attr(:), str_cmp(:), str_name(:), tmp_str
    character(9)                  :: num_str
    integer                       :: i,j,cell,cell_tot,err,str_trim

    cell_tot = 0
    allocate(components(size(comps)))
    do i = 1, size(comps)
        components(i) = comps(i)%p
        cell_tot = cell_tot + size(components(i)%node_x)
    enddo
    if (cell_tot == 0) return
    j = 0 ! finding longest component name and allocate required arrays
    do i = 1, size(components)
        j = max(j,len(components(i)%name))
    enddo
    allocate(character(j)   :: str_attr(size(components)))
    allocate(                  size_attr(size(components)))
    allocate(                  int_attr(size(components)))
    allocate(                  x(cell_tot))
    allocate(character(j)   :: str_cmp(cell_tot))
    allocate(                  size_cmp(cell_tot))
    allocate(character(j+9) :: str_name(cell_tot))
    allocate(                  size_name(cell_tot))

    size_var = len_trim(vars)
    cell = 0 ! fill arrays: loop over component and later on node
    do i = 1, size(components)
        j = size(components(i)%node_x)
        int_attr(i) = j
        x(cell+1:cell+j) = components(i)%node_x
        str_attr(i) = components(i)%name
        size_attr(i) = len(components(i)%name)
        write(num_str,'(i0)'),j
        str_trim = len_trim(num_str)
        str_cmp(cell+1:cell+j) = components(i)%name
        size_cmp(cell+1:cell+j) = len(components(i)%name)
        size_name(cell+1:cell+j) = len(components(i)%name) + str_trim + 1
        tmp_str = '(i'//to_str(str_trim+1)//'.'//to_str(str_trim)//')'
        do j = 1, size(components(i)%node_x)
            write(num_str,tmp_str),j
            str_name(cell+j) = components(i)%name//num_str
        enddo
        cell = cell + j - 1
    enddo

    call tbl_h5_create_dbl(tbl,group_id,name,tbl%data)
    call write_vstr1d(group_id,name//'_cmp',str_cmp,size_cmp,cmp_id)
    call write_vstr1d(group_id,name//'_name',str_name,size_name,name_id)
    dims = 0
    dims(1) = cell
    call h5ltmake_dataset_f(group_id,name//'_x',1,dims,H5T_NATIVE_DOUBLE,x,err)
    call h5dopen_f(group_id,name//'_x',x_id,err)
    call write_vstr1d(group_id,name//'_var',vars,size_var,var_id)

    call attach_scale(time_id, tbl%dset, 3, 't', 't')
    call attach_scale(var_id,  tbl%dset, 1, 'var','var')
    call attach_scale(x_id,    tbl%dset, 2, 'x')
    call attach_scale(cmp_id,  tbl%dset, 2, 'cmp')
    call attach_scale(name_id, tbl%dset, 2, 'name','name')

    ! Writing attributes
    call write_atribute_int(tbl%dset,'nodes',int_attr)
    call write_attribute_vstr1d(tbl%dset,'names',str_attr,size_attr)

    call h5dclose_f(var_id,err)
    call h5dclose_f(name_id,err)
    call h5dclose_f(x_id,err)
    call h5dclose_f(cmp_id,err)
end subroutine hdf5_data_create