Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Formatted time/date output

ingo_berg
Beginner
586 Views
Hi,

The following problem would take a single line of C++ code yet in fortran it seems nearly impossible to achive without extensive additional coding.

I want to output date and time into a string. I have 7 double precision variables holding the data:

fYear, fMonth, fDay, fHour, fMonth, fMin, fSec, fAbs

And I want do do the simple task of writing those to a time string like this:

"00h 00m 00.0s 00/00/00 (000000.00)"

(The order of the entries is: fHour, fMin, fSec, fDay, fMonth, fYear, fAbs)

Whatever I try either do I get "**" entries, leading zeros are not printed or commas appear where I dont want them.

Could anyone suggest me a format line that will do what I want? I need the leading zeros and i don't want comas to appear in the entries for hours minutes.... Even if they are technically floating point values.
0 Kudos
3 Replies
greldak
Beginner
586 Views
I2.2,'h',1X,I2.2,'m',1X,F04.2,1X,2(I2.2,'/'),I2.2,'(',F09.2,')'
should come close
You won't get any commas unless you put them in yourself although they may appear to be there if you use something like Excel to read the output - that would be down to the locale settings in Windows.
0 Kudos
ingo_berg
Beginner
586 Views
Thanks for your reply

Unfortunately it does not seem to work.
I need a way to output floating point values either with leading spaces or with leading zeros. I guess if there is a way to align the values on the right side of its output field it should work but I'm not sure if that is possible.

I'd like to use this for putting a time stamp on each frame in an animated sequence. In order for the timestemp to remain readable I need to make sure that the date fields keep their size.
0 Kudos
anthonyrichards
New Contributor III
586 Views
Have you looked at portability routines (that were available in CVF) such as
CLOCK, CTIME, DATE, DATE_AND_TIME etc.?
0 Kudos
Reply