This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with zeros.


On Thu, Jul 19, 2007 at 07:12:48PM +0200, Tobias Burnus wrote:
> ?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
> 
> 
> For (a) I think (1) is the best result and (2) is also ok. I don't see
> any good reason to do (3).

troutmask:kargl[203] cat a.f
       program a
       real x(2), y(2)
       open(unit=10,file='data')
       read(10,*) x
       y = x
       print *, x, y
       end
troutmask:kargl[204] cat data
9.999e-46 9.999e-46
troutmask:kargl[205] gfc -o z -O a.f
troutmask:kargl[206] ./z
  1.4012985E-45  1.4012985E-45  1.4012985E-45  1.4012985E-45
troutmask:kargl[207]  gfc -v
Using built-in specs.
Target: x86_64-portbld-freebsd7.0
Configured with: ./..//gcc-4.2.1-RC-20070712/configure --disable-nls --with-system-zlib --with-libiconv-prefix=/usr/local --with-gmp=/usr/local --program-suffix=42 --libdir=/usr/local/lib/gcc-4.2.1 --with-gxx-include-dir=/usr/local/lib/gcc-4.2.1/include/c++/ --infodir=/usr/local/info/gcc42 --disable-libgcj --prefix=/usr/local x86_64-portbld-freebsd7.0
Thread model: posix
gcc version 4.2.1 20070712 (prerelease)


-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]