I am writing a function to return a string
function doc () Result s
character (Len=65) :: s
...
end function
Is it possible to have a variable length string, where I can allocate the length of the string being returned. I know I can do it using a subroutine, but not for a function.
Function discl (nm) Result (s)
Character (Len=:), Allocatable :: s
Character (Len=*), Intent (In) :: nm
Integer :: n
Character (Len=65) :: stamp
stamp = "Thu May 7 15:13:48 BST 2015"
n = Len_trim (stamp)
Allocate (Character (n) :: s)
s = Trim (fstamp)
End Subroutine discl