This is my code:
Program String_Triming
Implicit none
Open(15, File = 'Output.txt')
Write(15,'(A,1x,"j",1x,A)') Ispis(20.45),Ispis(20.45)
Write(15,'(A,1x,"j",1x,A)') Ispis(-20.45),Ispis(-20.45)
Close(15)
Contains
Function Ispis ( Deg ) result ( Str )
Real,intent(in)::Deg
Character(len=16):: Str
If ( Deg > 0 ) then
Write(Str,'(F0.3)') 1000.0 + Deg
Str = Str(2:)
Else
Write(Str,'(F8.3)') 1000.0 + abs(Deg)
Write(Str,'("-",A)') Str(3:)
End If
End Function Ispis
End program String_Triming
The content of Output.txt
file is:
020.450 j 020.450
-20.450 j -20.450
The result I want to get from this code is:
020.450 j 020.450
-20.450 j -20.450
How do I get that result? Is there way to trim the length of Str
to Len=8
which is the length of 020.450
?