floating point exceptions

floating point exceptions

vader1000's picture

I am using CVF 6.6A compiling a project to a Fortran .DLL. To enable floating point exceptions that I want, i have done the following call at the beginning of my fortran code:

INTEGER(2) CONTROL

CALL GETCONTROLFPQQ(CONTROL)
CONTROL = IBCLR(CONTROL, 0)
CONTROL = IBCLR(CONTROL, 1)
CONTROL = IBCLR(CONTROL, 2)
CONTROL = IBCLR(CONTROL, 3)
CONTROL = IBCLR(CONTROL, 4)
CONTROL = IBSET(CONTROL, 5)
CALL SETCONTROLFPQQ(CONTROL)

The reason bit 5 is not cleared is becaus i was getting a "float inexact result" for no apparent reason. it was in a floating point calculation where the result was 15.457 or something like that. it did 10 other similar calculations before that and never gave the error. This is problem #1... what does inexact result mean? some calculations result in 100.39 are OK and others resulting in 15.457 aren't OK. All of our floats are REAL(4). All integers are INTEGER(4), but I don't think any integers were in these calculations.

I have a much more critical problem now. I have recently incorporated CHARACTER(20) variables in my structures in fortran (FYI - VB .NET is the calling app). Since adding these I get a "underflow or overflow" error when fortran attempts to return to VB. Many times it is in the system.drawing.dll file, whatever that is.

The strange thing is that if I debug from fortran, all of my calculations are fine and all the string assignments look OK, when i get to the END statement and click "F10" to step over, fortran detects the error and throws me into assembly. If I do an F11 and "step into" the end, it will do it on a CALL statement to some function. If I remove the floating point check code as listed above, I do NOT receive this error and the system appears to run as normal. If I debug from VB, it detects that there was an overflow/underflow in the fortran routine, but just tells me that it detected it and moves on... even though the error came in, the data all looks good (including the strings).

I want to have floating point exception handling, but I can't figure out what is causing this. It appears to be something I have no control over since it is during the .DLL return to VB, and VB certainly isn't doing any calculations! What do i do?!?!?!

FYI, I have checked all data coming into fortran within the structures from VB and the sizes match 100%, meaning there is no memory stepping happening.

Please shed some light on this if you can!

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.