Here's the page with the info on fpe handling:
http://gcc.gnu.org/onlinedocs/gcc-3.3.5/g77/Floating_002dpoint-Exception-Handling.html
The phosim package doesn't use libraries of its own, so rather than
using the suggested trick, it works just to put the code block at the
top of some executable such as raytrace/main.cpp:
diff --git a/source/raytrace/main.cpp b/source/raytrace/main.cpp
index b818404..925a8fc 100644
--- a/source/raytrace/main.cpp
+++ b/source/raytrace/main.cpp
@@ -16,6 +16,15 @@
#include "image.h"
+#define _GNU_SOURCE 1
+#include <fenv.h>
+static void __attribute__ ((constructor))
+trapfpe () {
+ /* Enable some exceptions. At startup all exceptions are masked. */
+
+ feenableexcept (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
+}
+
int main() {
Image im;
In the ./phosim examples/star -c examples/nobackground run, one first
encounters a bug in dust.cpp that is easy to fix. The next FPE is in
a line I would be loathe to debug:
Program received signal SIGFPE, Arithmetic exception.
asphere (surface=0x3477dd0, surface_r=0x34a6bf0, surface_normal=0x348f4e0,
numelements=1000, radiusofcurv=<value optimized out>,
spacing=3892.3446079999994, semidiameter=551, holesemi=0, conic=0, third=0,
fourth=0, fifth=0, sixth=0, seventh=0, eighth=0, ninth=0, tenth=0)
at raytrace.cpp:381
381
*(surface+i)=spacing-(pow(surface_r[i],2.0)/radiusofcurv/(1.0+sqrt(1.0-(conic+1.0)*pow(surface_r[i]/radiusofcurv,2.0)))+third*pow(surface_r[i],3.0)+fourth*pow(surface_r[i],4.0)+fifth*pow(surface_r[i],5.0)+sixth*pow(surface_r[i],6.0)+seventh*pow(surface_r[i],7.0)+eighth*pow(surface_r[i],8.0)+ninth*pow(surface_r[i],9.0)+tenth*pow(surface_r[i],10.0));
(gdb)
--
James Chiang SLAC, MS 29 home: (650) 605-3346
Fermi ISOC 2575 Sand Hill Rd office: (650) 926-2930
Menlo Park CA 94025 FAX: (650) 926-5566
########################################################################
Use REPLY-ALL to reply to list
To unsubscribe from the PHOSIM-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=PHOSIM-DEV&A=1
|