[J3] Question on overflow and run-time detection of infinity?
Clune, Thomas L. (GSFC-6101)
thomas.l.clune at nasa.gov
Mon Nov 26 12:30:59 EST 2018
Thanks Steve.
Cheers,
- Tom
> On Nov 23, 2018, at 10:04 AM, Steven G. Kargl <kargl at troutmask.apl.washington.edu> wrote:
>
> On Fri, Nov 23, 2018 at 02:09:51PM +0000, Clune, Thomas L. (GSFC-6101) via J3 wrote:
>>
>> No further calculations are ever done with relative_deviation
>> except a subsequent formatted output. Two compilers print
>> “Infinity” as expected even when using aggressive runtime
>> checking (e.g., with NAG I am using -C=all and -ieee=stop).
>> The 3rd compiler (gfortran 8.2.0) halts at the above assignment
>> to IEEE_POSITIVE_INF with the useful, albeit undesired run-time message:
>>
>> Program received signal SIGFPE: Floating-point exception -
>> erroneous arithmetic operation.
>>
>> The flag that toggles is -ffpe-trap=overflow. I can turn that
>> option off, but I would like the compile to helpfully identify
>> other bad denominators (and similar things) elsewhere in the
>> application.
>>
>> The question: Is not the intent of the standard to allow using
>> the IEEE functionality to return values such as Infinity without
>> halting the run while still enabling run-time checking of
>> calculations that incidentally compute erroneous operations?
>>
>
> What the standard allows and what the -ffpe-trap= option does
> are of course two distinct things. The option as the name
> suggests will trap on a floating-point exception. This option
> is applied globally including the runtime library. That being
> said, the standard provides facilities for a user to manage
> the halting properties of a program. You can use a combination
> of IEEE_GET_MODE, IEEE_SET_MODE, IEEE_GET_HALTING_MODE, and
> IEEE_SET_HALTING_MODE to micro-management/manipulate the halting
> property as you like. I don't know the quality of any Fortran
> processors' implmentation of these functions, so your mileage
> may vary.
>
>
> --
> Steve
More information about the J3
mailing list