Problem with zeros.
Tim Prince
tprince@myrealbox.com
Fri Jul 20 03:04:00 GMT 2007
Tobias Burnus wrote:
> Hi,
>
> Ãric Depagne wrote:
>
>> My code reads a file, and puts the content of this file into an array.
>> The array is defined like this:
>>
>> DIMENSION X(40,30)
>> The content of the file looks like this:
>> 9.999e-46 9.999e-46 9.999e-46 9.999e-46 9.999e-46 2.944E-19
>>
>>
> Which gives the run-time error:
>
> At line 2 of file xxx.f90 (unit = 5, file = 'stdin')
> Fortran runtime error: Range error during floating point read
>
>
>> I would like to know if there is a way to let gfortran know that when he
>> encounters values that are too small, he shall convert them to zero ?
>>
>>
> To my knowledge not.
>
> I played around with other compiles and:
>
> a) 9.999e-46
>
>
> 1. ifort, NAG f95, sunf95, pgf95: denormalized number: 1.4012985E-45
> 2. g95, openf95: 0.0
> 3. gfortran: Range error
>
> (gcc+glibc with scanf: (2).)
>
> b) 1e99
>
> 1. sunf95, g95, f95, openf95, pgf95: Inf
> 2. ifort, gfortran: Range error
>
> (gcc+glibc with scanf: (1).)
>
> For (a) I think (1) is the best result and (2) is also ok. I don't see
> any good reason to do (3).
> For (b) one can argue whether (1) or (2) is better; I like (1) more, one
> might argue that (2) has also its merits and one may argue for an
> option, but overflow FP traps would have the same result, I'd guess.
> (Assuming that the data is used later on.)
>
> What do the others think?
>
>
At the time when we persuaded the Intel compiler team to institute the
present behavior of ifort, the primary models for compatibility were g77
on linux, and CVF on Windows. Both of those compilers silently convert
subnormal inputs to the nearest available sub-normal (0. if
appropriate). Throwing an exception which terminates the program, in
the absence of iostat handling, breaks important applications. So it
was accepted that the historical behavior of g77 and CVF should be
continued.
More information about the Fortran
mailing list