public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: EXC_ARITHMETIC when writing a floating point variable
@ 2010-10-31 16:38 Dominique Dhumieres
  0 siblings, 0 replies; 5+ messages in thread
From: Dominique Dhumieres @ 2010-10-31 16:38 UTC (permalink / raw)
  To: fortran; +Cc: rd.daal

Richard,

Usual comment: give a nonworking reduced test case!

You can also use -Wall and -Wuninitialized (with -O
for the later). Try to find the minimal set of options
tha trigger the problem: do you really need
-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8?
If yes, are not you passing REAL variables to procs
expecting a REAL(4) (old timing procs are good candidates)?

You can also use valgrind on Mac OS 10.6.4 (I build it
with fink, but it may exist on macports).

If none of the above works, you can mail me the code
and I can have a look.

Cheers,

Dominique

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: EXC_ARITHMETIC when writing a floating point variable
  2010-10-31 16:36 Richard Daal
  2010-10-31 17:48 ` Jerry DeLisle
  2010-10-31 21:50 ` Steve Kargl
@ 2010-11-05 14:12 ` Richard Daal
  2 siblings, 0 replies; 5+ messages in thread
From: Richard Daal @ 2010-11-05 14:12 UTC (permalink / raw)
  To: fortran

Dear all,

Thank you very much for your feedback, which finally led to the
solution of the problem. As Steve pointed out in his reply, I got what
I wanted. :-)

The problem I encountered last week is caused by: -ffpe-trap=precision

It does not need any complex code to produce the floating point
exception (EXC_ARITHMETIC). Just:

   double precision :: Test
   Test = 123.45
   write(*, *) Test


With kind regards

Richard


2010/10/31 Richard Daal <rd.daal@gmail.com>:
> 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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: EXC_ARITHMETIC when writing a floating point variable
  2010-10-31 16:36 Richard Daal
  2010-10-31 17:48 ` Jerry DeLisle
@ 2010-10-31 21:50 ` Steve Kargl
  2010-11-05 14:12 ` Richard Daal
  2 siblings, 0 replies; 5+ messages in thread
From: Steve Kargl @ 2010-10-31 21:50 UTC (permalink / raw)
  To: Richard Daal; +Cc: fortran

On Sun, Oct 31, 2010 at 04:55:50PM +0100, Richard Daal wrote:
> 
> 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 ()"

Well, what does EXC_ARITHMETIC mean?  This is OS specific! 

> -ffpe-trap=invalid,zero,overflow,underflow,precision,denormal

Looks like you got what you wanted.

-- 
Steve

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: EXC_ARITHMETIC when writing a floating point variable
  2010-10-31 16:36 Richard Daal
@ 2010-10-31 17:48 ` Jerry DeLisle
  2010-10-31 21:50 ` Steve Kargl
  2010-11-05 14:12 ` Richard Daal
  2 siblings, 0 replies; 5+ messages in thread
From: Jerry DeLisle @ 2010-10-31 17:48 UTC (permalink / raw)
  To: Richard Daal; +Cc: fortran

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* EXC_ARITHMETIC when writing a floating point variable
@ 2010-10-31 16:36 Richard Daal
  2010-10-31 17:48 ` Jerry DeLisle
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Richard Daal @ 2010-10-31 16:36 UTC (permalink / raw)
  To: fortran

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-05 14:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-31 16:38 EXC_ARITHMETIC when writing a floating point variable Dominique Dhumieres
  -- strict thread matches above, loose matches on Subject: below --
2010-10-31 16:36 Richard Daal
2010-10-31 17:48 ` Jerry DeLisle
2010-10-31 21:50 ` Steve Kargl
2010-11-05 14:12 ` Richard Daal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).