I have a user-defined integer x
which I am casting to a string 'xs' as
integer :: x
read (*,*) x
character xs*4
write (xs, '(I4.4)') x
If x
is less than 4 digits in length, i.e. x=25
, then xs
becomes
0025
I don't want this, and simply want xs='25'
. However, I do not know before hand how long x
is actually going to be (it is set by the user), just that it will be at most 4 digits. Can I remove the leading zeros? Can I change them to leading whitespace, and then call trim()
?