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

How Do You Flush to Zero for Output?

jackosullivan
Beginner
968 Views

Ihaven't been able to find a way toget really small numbers to become output zeros. Rather, they just mess up my output with the overflow/underflow asterisks.

It's a 100% IVF 10.1.013 (QuickWin) program, no optimizations (so that I can use walkbacks to find where my users screw up their data sets), and /fpe:0 which is supposed to kill me on everything but underflows. I've tried "Flush Denormal Results to Zero", but it has made no difference.

Computing is done with default Real(8) to help smooth out a lot of small-number decision-making, but very small numbers are meaningless in my final results. To keep from taking a lot of screen space, I've restricted output formats to single-digit exponents-- for example,E10.4E1. The WRITE statement says WRITE (6,9914) real (VDMAX(IS)*ft32vol,4), where both vdmax and ft32vol are default Real(8). Whenever the result absolute value comes to less than 1E-9, the output field is filled withasterisks, when I would really like to have it just tell me 0.0000E+0.

CommandLine: /nologo /Zi /Od /include:"Debug/" /fpscomp:filesfromcmd
/fpscomp:ioformat /fpscomp:logicals /fpscomp:general /error_limit:10
/warn:errors /warn:unused /warn:interfaces /real_size:64 /Qsave
/align:rec8byte /align:dcommons /assume:dummy_aliases /Qzero
/fpe:0 /iface:cvf /module:"Debug/" /object:"Debug/" /traceback
/check:bounds /check:format /libs:qwin /c

Surely there must be some switch or Format designator that would keep me from having to put

IF(variable.LT.1.d-9)variable = 0.d0

in front of every potential output underflow.

Any help would be very much appreciated.

Thanks and God bless!

Jack

0 Kudos
2 Replies
Steven_L_Intel1
Employee
968 Views
No, there's no switch or format. The switches you have been using all relate to computations, not formatting.

What I suggest is writing a small function that does the "flush".
Something like this:

real(8) function zflush (val)
real(8), intent(in) :: val
zflush = val
if (abs(val) < 1.0D-9) zflush = 0.0D0
return
end function zflush

Then use zflush(val) instead of val in your output list.
0 Kudos
jackosullivan
Beginner
968 Views

Steve,

Thanks ever so much for your as-usual excellent and quick response.

Happy New Year and Happy Whatever Else You Want to Celebrate!

God bless!

jack

0 Kudos
Reply