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

Evaluating an expression as real(KIND=8)

gregfi04
Beginner
651 Views
I need to store the following:

var1 = 1.2e-137 * 10 ** (0.285 * temp)

When I try to compile this, I get a warning saying, "The value was too small when converting to REAL(KIND=4); the result is zero."

My understanding is that it's trying to convert 1.2e-137 into a KIND=4 real, and then evaluate the expression. Is there any way to evaluate the whole expression as KIND=8?

Edit: I would prefer not to use the "-real-size" compiler flag.

Thanks,
Greg
0 Kudos
1 Reply
TimP
Honored Contributor III
651 Views
There are 1 or 2 compiler flags which might make a difference here, but the Fortran standard requires that 1.2e-137 be evaluated in default real kind, in the absence of such extensions. For this to be portable, you would require either the old d notation or the f90 _kind suffix on your constants. 1.2d-137, 0.285d0 in Fortran 66/77. While it's not portable to systems with a different KIND scheme, if you're serious about KIND=8, you would use the _8 suffix.
0 Kudos
Reply