tem_r2str_arr Function

private function tem_r2str_arr(val, sep, logger) result(str)

Converts a real "array" to a single string according to the format provided in the logger.

Arguments

Type IntentOptional Attributes Name
real(kind=single_k), intent(in) :: val(:)

array to convert

character(len=*), intent(in) :: sep

seperator between array elements

type(tem_logging_type), intent(in), optional :: logger

logger type which provides output format

Return Value character(len=SolSpecLen)

output string


Called by

proc~~tem_r2str_arr~~CalledByGraph proc~tem_r2str_arr tem_r2str_arr interface~tem_tostr tem_toStr interface~tem_tostr->proc~tem_r2str_arr proc~identify_lists identify_lists proc~identify_lists->interface~tem_tostr proc~load_spatial_parabol load_spatial_parabol proc~load_spatial_parabol->interface~tem_tostr proc~load_spatial_predefined load_spatial_predefined proc~load_spatial_predefined->interface~tem_tostr proc~load_spatial_predefined->proc~load_spatial_parabol proc~tem_comm_dumptype tem_comm_dumpType proc~tem_comm_dumptype->interface~tem_tostr proc~tem_load_onecanonicalnd tem_load_oneCanonicalND proc~tem_load_onecanonicalnd->interface~tem_tostr proc~tem_load_spatial tem_load_spatial proc~tem_load_spatial->interface~tem_tostr proc~tem_load_spatial->proc~load_spatial_predefined proc~tem_print_array tem_print_array proc~tem_print_array->interface~tem_tostr proc~tem_shape_initbylevels tem_shape_initByLevels proc~tem_shape_initbylevels->interface~tem_tostr proc~tem_shape_load_level tem_shape_load_level proc~tem_shape_load_level->interface~tem_tostr proc~tem_stencilheader_dump tem_stencilHeader_dump proc~tem_stencilheader_dump->interface~tem_tostr interface~tem_load_canonicalnd tem_load_canonicalND interface~tem_load_canonicalnd->proc~tem_load_onecanonicalnd proc~tem_load_canonicalnd_vec tem_load_canonicalND_vec interface~tem_load_canonicalnd->proc~tem_load_canonicalnd_vec interface~tem_stencil_dump tem_stencil_dump interface~tem_stencil_dump->proc~tem_stencilheader_dump proc~communicate_elements communicate_elements proc~communicate_elements->proc~identify_lists proc~redefine_halos redefine_halos proc~communicate_elements->proc~redefine_halos proc~load_spacetime_predefined load_spacetime_predefined proc~load_spacetime_predefined->proc~tem_load_spatial proc~redefine_halos->proc~tem_comm_dumptype proc~tem_find_allelements tem_find_allElements proc~tem_find_allelements->proc~identify_lists proc~tem_find_allelements->proc~communicate_elements proc~tem_load_canonicalnd_vec->proc~tem_load_onecanonicalnd proc~tem_load_ic tem_load_ic proc~tem_load_ic->proc~tem_load_spatial proc~tem_load_shape_single tem_load_shape_single proc~tem_load_shape_single->proc~tem_shape_load_level proc~tem_load_shape_single->interface~tem_load_canonicalnd proc~tem_shape2subtree tem_shape2subTree proc~tem_shape2subtree->proc~tem_shape_initbylevels interface~tem_load_shape tem_load_shape interface~tem_load_shape->proc~tem_load_shape_single proc~tem_create_leveldesc tem_create_levelDesc proc~tem_create_leveldesc->proc~tem_find_allelements proc~tem_create_subtree_of tem_create_subTree_of proc~tem_create_subtree_of->proc~tem_shape2subtree proc~tem_dimbydim_construction tem_dimByDim_construction proc~tem_dimbydim_construction->interface~tem_stencil_dump proc~tem_element_dump tem_element_dump proc~tem_element_dump->interface~tem_stencil_dump proc~tem_load_shapes tem_load_shapes proc~tem_load_shapes->proc~tem_load_shape_single proc~tem_load_spacetime_single tem_load_spacetime_single proc~tem_load_spacetime_single->proc~load_spacetime_predefined

Source Code

  function tem_r2str_arr( val, sep, logger) result(str)
    ! ---------------------------------------------------------------------------
    !> array to convert
    real(kind=single_k), intent(in) :: val(:)
    !> seperator between array elements
    character(len=*), intent(in)    :: sep
    !> logger type which provides output format
    type(tem_logging_type), optional, intent(in) :: logger
    !> output string
    character(len=SolSpecLen) :: str
    ! ---------------------------------------------------------------------------
    character(len=SolSpecLen)     :: temp_str
    character(len=form_len)       :: form
    integer                       :: iter, idx, offset, off_sep
    integer                       :: instrlen, maxstrlen
    ! ---------------------------------------------------------------------------

    if (present(logger)) then
      form = logger%real_form
    else
      form = primary%real_form
    end if

    maxstrlen = 10
    instrlen = size(val)
    off_sep = len(sep)
    offset = 0

    str = ''
    idx = 1
    ! If the length of input string is within limits
    if( instrlen .le. maxstrlen ) then
      do iter=1, instrlen
        ! Convert the ith element of array into character
        write(temp_str, '(' // trim(form) // ')') val(iter)
        ! Append the above obtained character to string followed by separator
        offset = len_trim(temp_str)
        str(idx:idx+offset-1) = trim(temp_str(1:offset) )
        if( iter .ne. instrlen ) then
          str(idx+offset:idx+offset+off_sep) = sep(1:off_sep)
        end if
        idx = idx + offset + off_sep + 1
      end do
      ! Clip the final string to removed unwanted stuff
      str = str(1:instrlen*(offset+off_sep+1)-off_sep-1)
    ! If not then print 1,2,3,...,last
    else
      do iter=1, 3
        write(temp_str, '(' // trim(form) // ')') val(iter)
        offset = len_trim(temp_str)
        str(idx:idx+offset-1) = trim(temp_str(1:offset) )
        str(idx+offset:idx+offset+off_sep) = sep(1:off_sep)
        idx = idx + offset + off_sep + 1
      end do
      ! Now add ,..., and the last entry of array
      str(idx:idx+2)           = '...'
      str(idx+3:idx+3+off_sep) = sep
      write(temp_str, '(' // trim(form) // ')') val(instrlen)
      offset = len_trim(temp_str)
      str(idx+4+off_sep:idx+4+off_sep+offset) = trim(temp_str(1:offset) )
      ! Clip the final string to removed unwanted stuff
      str = str(1:4*(offset+off_sep)-off_sep+4)
    end if

  end function tem_r2str_arr