Returns the length of the character sequence without trailing spaces represented by the string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_type), | intent(in) | :: | string |
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