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

Handling REALs in Internal WRITE Statement

kulachi
Beginner
492 Views
Hi,

I am writing a REAL to a string. The REAL can either be

0.00 < REAL < 99.99 [or] 100.01 < REAL < 999.99

However I don't know the value in advance. So when I use F5.2 and the number is above 99.99, the string shows: ****** and when I use F6.2 and the number is less than 100.01, the string shows a space before the number.

How do I correct this so that F5.2 or F6.2 is selected automatically and the string has no spaces nor ****. I can imagin there would be a simple solution for this, but I could not find it even after some effort.

Many thanks in advance.

-Kulachi
0 Kudos
1 Solution
JVanB
Valued Contributor II
492 Views

write(string,'(f0.2)') 99.99

View solution in original post

0 Kudos
4 Replies
JVanB
Valued Contributor II
493 Views

write(string,'(f0.2)') 99.99

0 Kudos
kulachi
Beginner
492 Views
Thanks!

Kulachi
0 Kudos
DavidWhite
Valued Contributor II
492 Views
Steve,

This solution to the posted question is clearly included in the documentation in the statement
"When the value of the field width is zero, the compiler selects the smallest possible positive actual field width that does not result in the field being filled with asterisks."

It would be helpful if this is added to the section of the documentation under "F Editing" because here the only statement is that "The w must be greater than or equal to d+3". There is no reference that w may be zero.

Regards,

David
0 Kudos
Steven_L_Intel1
Employee
492 Views
David,

Thanks for noticing that - I will be sure to pass that along to our writers.
0 Kudos
Reply