padr_string_default Function

private pure function padr_string_default(string, output_length) result(res)

Right pad the input string with ” ” (1 whitespace)

Returns a new string

Arguments

Type IntentOptional Attributes Name
type(string_type), intent(in) :: string
integer, intent(in) :: output_length

Return Value type(string_type)


Called by

proc~~padr_string_default~~CalledByGraph proc~padr_string_default padr_string_default interface~padr padr interface~padr->proc~padr_string_default proc~padr_string_pad_with padr_string_pad_with interface~padr->proc~padr_string_pad_with proc~padr_string_pad_with->interface~padr

Variables

Type Visibility Attributes Name Initial
character(kind=output_length), len=max), private :: char_output

Source Code

   pure function padr_string_default(string, output_length) result(res)
      type(string_type), intent(in) :: string
      integer, intent(in) :: output_length
      character(len=max(slen(string), output_length)) :: char_output
      type(string_type) :: res

      ! We're taking advantage of `char_output` being longer than `string` and
      ! initialized with whitespaces. By casting `string` to a `character`
      ! type and back to `string_type`, we're effectively right-padding
      ! `string` with spaces, so we don't need to pad explicitly.
      char_output = char(string)
      res = string_type(char_output)

   end function padr_string_default