len_trim_string Function

private elemental function len_trim_string(string) result(length)

Returns the length of the character sequence without trailing spaces represented by the string.

Arguments

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

Return Value integer


Called by

proc~~len_trim_string~~CalledByGraph proc~len_trim_string len_trim_string interface~len_trim len_trim interface~len_trim->proc~len_trim_string

Source Code

elemental function len_trim_string(string) result(length)
   type(string_type), intent(in) :: string
   integer :: length

   ! Not `merge(len_trim(string%raw), 0, allocated(string%raw))`: MERGE is
   ! an ordinary function reference, so both value arguments are evaluated
   ! regardless of the mask, and `len_trim(string%raw)` references an
   ! unallocated allocatable (F2018 9.7.1) whenever the mask is false.
   ! `len_string` just above already uses this shape.
   if (allocated(string%raw)) then
      length = len_trim(string%raw)
   else
      length = 0
   end if

end function len_trim_string