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: EXC_ARITHMETIC when writing a floating point variable


On 10/31/2010 08:55 AM, Richard Daal wrote:
Dear all,

I am struggling with a problem for some time now, where I do not know
how to proceed. I would greatly appreciate, if I could get some
advise.

I try to write a double precision variable "Test = 3.456" with
"write(*, *) Test" to the terminal.
That produces a floating point exception. With gdb, I get the
following error message:
"Program received signal EXC_ARITHMETIC, Arithmetic exception.
0x000000001001c8132 in __dtoa ()"

However, at some place in the code double precision variables of an
allocatable array that belongs to a derived type are written to the
terminal and this works fine. When removing the write statement that
produces the error, the program works fine.
I do not understand, what could go wrong with this "write" statement?
How could I check what the problem is? Its a relatively complex code.

I use the following flags with gfortran 4.5.1 (on Mac OS 10.6.4) for
compilation:
-ffree-form -fimplicit-none -frange-check -std=f2003
-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 -fmax-errors=0
-pedantic -Wall -fconvert=native -fbounds-check
-fmax-stack-var-size=32768 -g -ffpe-trap=invalid,zero,
overflow,underflow,precision,denormal
... and for linking:
-arch_errors_fatal -arch x86_64 -g

I thank you very much in advance for your help..

With kind regards,

Richard


My first suggestion is don't use these:


-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8

It is better to use explicit kind specifications and set a parameter in the program for the kind type to use.

I suppose your code is legacy and does not have any easy way to do this. The only way that I can see that the write statement would fail like that is if the variable has been stomped on because something is out of bounds. Of course there coud be a real exception in __dtoa () which would be a bug.

Try eliminating chunks of code until the problem goes away. This might give a hint.

Jerry


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