This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Exception catching
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Hassan Aurag <aurag at cae dot com>
- Cc: GCC Help Mailing List <gcc-help at gcc dot gnu dot org>
- Date: Fri, 16 Nov 2001 21:16:37 +0100
- Subject: Re: Exception catching
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <1005928419.21445.9.camel@l0553lnx>
Hassan Aurag wrote:
> I would like an example on how to catch all division by zeros in
> Fortran.
>
> My idea is the following in pseudo-code:
>
> num, denom = catch_div_byzero()
>
> return bignumber (and not nan)
>
> Is this even possible?
I presume you mean "possible without changing my Fortran source code" ?
> In other words, I would like to alter division by zero so that it
> returns a huge number. can it be made even in C and then linked as
> library to my fortran code?
No, because the division is done "inline", i.e., no subroutine call is
generated.
However, you might be able to set the floating point control word in
your processor to catch this error instead of silently generating a NaN.
See http://gcc.gnu.org/onlinedocs/g77_19.html#SEC644
[Note that this is really a C library question - notably a glibc
enabled solution]
Hope this helps,
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)