LISTSERV mailing list manager LISTSERV 16.5

Help for PHOSIM-DEV Archives


PHOSIM-DEV Archives

PHOSIM-DEV Archives


PHOSIM-DEV@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

PHOSIM-DEV Home

PHOSIM-DEV Home

PHOSIM-DEV  February 2013

PHOSIM-DEV February 2013

Subject:

turning on floating point exception handling

From:

James Chiang <[log in to unmask]>

Reply-To:

lsst phosim group <[log in to unmask]>

Date:

Fri, 8 Feb 2013 14:22:35 -0800

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (55 lines)

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

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

October 2014
July 2014
June 2014
February 2014
January 2014
December 2013
February 2013
January 2013
December 2012

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use