Trim an allocatable string or return a default if empty/unallocated.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=:), | intent(in), | allocatable | :: | s | ||
| character(len=*), | intent(in) | :: | default |
pure function trim_or_default(s, default) result(r) character(len=:), allocatable, intent(in) :: s character(len=*), intent(in) :: default character(len=:), allocatable :: r if (allocated(s)) then if (len_trim(s) > 0) then r = trim(s) else r = default end if else r = default end if end function trim_or_default