Reputation: 428
I am specifying a filename to my Fortran77 program from the command line. However, I get a newline character appended to the filename string (obtained using getarg
).
How can I remove the new line character?
Upvotes: 3
Views: 1615
Reputation: 60078
You can use an alternative to len_trim
from https://stackoverflow.com/a/1259426/721644 adapted to find the newline character
integer function findnl(s)
character(len=*) :: s
integer i
findnl = len(s)+1
do i = 1, len(s)
if (s(i:i) .eq. achar(10)) then
findln = i
return
end if
end do
end function
After that, change the rest of the string to spaces
l = findnl(str)
if (l .le. len(str)) str(l:) = " "
Upvotes: 3