I'm attempting to get a time stamp with DATE_AND_TIME(), but Fortran returns an excessive amount of spaces, and I can't seem to trim these spaces because functions like TRIM() and ADJUST() work on strings only. Fortran appears to not have a function to convert integers to strings or at least I haven't been able to find one so far. I'd like to use the date-time stamp in a file name, so the included spaces are a problem. Can anyone show me how to remove these additional spaces?
Unfortunately I have to use Fortran, although I believe other versions of Fortran are acceptable.
Code:
program
character(8) :: date
character(10) :: time
character(5) :: zone
integer, dimension(8) :: values
zone = "+01"
call date_and_time(ZONE=zone,VALUES=values)
print *, "values(1)", values(1), "-"
Returns (including text before and after values(1)
to show spacing):
values(1) 2017 -
As shown above there seem to be about 6 spaces before the number.
I'm compiling this in gfortran, version is: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5)