連結已複製
5 回應
There is no Fortran format that will do this - sorry. If you need this, you'll have to write into a character variable using internal write and then "post-process" the string replacing leading blanks with zeroes.
Steve
Steve
Thanks Steve
Can users define new formats?
I can print the real number x = 12.3 as "0012.3" by doing
write(*, '(i4.4,f2.1)') floor(x), x - floor(x).
Can I define a format MY_FORMAT so as to
achieve the same result with
write(*, MY_FORMAT) x?
Can users define new formats?
I can print the real number x = 12.3 as "0012.3" by doing
write(*, '(i4.4,f2.1)') floor(x), x - floor(x).
Can I define a format MY_FORMAT so as to
achieve the same result with
write(*, MY_FORMAT) x?
Thanks kdkeefer,
I am afraid your message does address
the issue I am raising.
Note that the format '(i4.4,f2.1)' takes two
inputs, which in my usage happen to be related.
The format MY_FORMAT I am seeking would achieve
the same result with just one input.
(By the way, what is LRM; what does this acronym mean?)
I am afraid your message does address
the issue I am raising.
Note that the format '(i4.4,f2.1)' takes two
inputs, which in my usage happen to be related.
The format MY_FORMAT I am seeking would achieve
the same result with just one input.
(By the way, what is LRM; what does this acronym mean?)
LRM = Language Reference Manual.
No, you cannot invent your own format codes. You could write a function that returns a character result with the value formatted as you like (then display it with the A format.)
Steve
No, you cannot invent your own format codes. You could write a function that returns a character result with the value formatted as you like (then display it with the A format.)
Steve
