- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I modified the __except to force a program continuation ...
__try {
fortran_driver();
__except ( 1 )
{
* stuff that's supposed to happen, but doesn't *
}
... but the except clause never seems to execute (program just aborts). For the C wrapper project, I have "Enable C++ Exceptions" set to "yes", and "Basic Runtime Checks" set to "Both", without any effect.
I noticed that on the same project in CVF where the exception is being handled correctly, there's a project setting for C/C++ | C++ Language | Enable exception handling ... and that item is enabled ... but I can't find the equivalent in IVF.
Anyone have a clue? Thx.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd: set 'No Frame Pointers' to No, 'Incremental Linking' to No, and C/C++ Run Time Checks' to /RTCs.
Also, the LPEXCEPTION_POINTERS should be passed to C by reference.
Additionally, at program initialization do something like:
....
control = FPCW$NEAR +&
FPCW$53 +&
FPCW$INVALID +&
FPCW$ZERODIVIDE +&
FPCW$OVERFLOW +&
FPCW$UNDERFLOW +&
FPCW$DENORMAL +&
FPCW$INEXACT
call
SETCONTROLFPQQ(control)FPE_MASK = FPE_M_TRAP_OVF +&
FPE_M_TRAP_DIV0 +&
FPE_M_TRAP_INV
FPE_STS = FOR_SET_FPE(FPE_MASK)
...
and you have to interface your FortranWrap as in
interface
subroutine FortranWrap[Alias:'_FortranWrap']() end subroutine FortranWrap end interface...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the meantime, I took the GETEPTRS sample solution in IVF and converted it to a VS 6 workspace. I also changed the nature of the test so that the exception is essentially an array out of bounds (array subscript is zero) which occurs in function BONG, just before the original divide by zero condition.
The try/except in the main driver is coded with __except (1) to unconditionally capture an exception condition, and the ensuing __except clause (printing a msg and exit with cc=99) executes on CVF, but not on IVF, where the rebuilt solution instead gets an "unhandled exception" when the zero index array is referenced.
I also changed the IF* libs to DF* libs to make it work under CVF ... and changed them back for the IVF test. The zip of the combined solution/workspace is attached for anyone interested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would appreciate it if someone could look over that sample (which is build-ready for both CVF 6.6 and IVF 9.0), and tell me what I'm doing wrong in IVF, because the CVF build against the same code works as expected (an array subscript exception is detected and handled using the code block following the __except), but the IVF build aborts with an unhandled exception message.
Thx. Longden
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The SEHs that I use for IVF 9.1 and CVF 6.6C sucessfully handles any manner of error in complex applications, so long as it's a Windows exception (with apologies to Henry F. and Bill G). This includes memory-, debugger-, fp-, integer-, exception-relatedexceptions, the whole catastrophy.
Have you considered submitting your sample to Premier Support?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a sample solution somewhere that demonstrates SEH (using __try/__except), or is the SIGNALQQ-based GETEPTRS the only exception-handling sample?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, CVF 6 as 6 samples on SEH, GETEPTRS among them. These are in C:Program FilesMicrosoft Visual StudioDF98SAMPLESEXCEPTIONHANDLING.
Remember you can do EH from C/C++ (its a Microsoft extention to the C/C++ standard(s), afterall, and Fortran 95 has no error handling other than GOTO 999 STOP). The definitive tutorial on this entire topic is J. Richter's 'Programming Applications for Microsoft Windows", 4th ed or later (Microsoft Press).
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Longden
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
However, it's not playing nice with me on converting to IVF. After converting the workspace to a solution and extracting the Fortran projects, I had to replace includes for IOSDEF.FOR with FOR_IOSDEF.FOR, but there's still a string of compiler errors relating to FOR$IOS_SUCCESS, FOR$IOS_FILNOTFOU, and FOR$IOS_MIXFILACC). My guess is that there's more and I just reached a display limit on the compile errors. I haven't converted the "USE DF*" lines with the resepective "USE IF*" lines ... should I? There's not always a one-to-one on those, and I understand some of them are still valid.
Has anyone else converted the VBVF1 workspace to IVF, and if so I'd like to know what changes had to be done (source and project settings).
Steve, there seems to be a lot of good stuff in the CVF 6.6 SAMPLESEXCEPTIONHANDLING ... I'm surprised more of that wasn't ported over and included in the IVF 9.0 distribution. Is that in the works?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the meantime ... my kingdom for a simple (and working) SEH sample solution!
What's frustrating is that the SEH samples seem to work with little fuss on CVF, but it's been like pulling teeth on IVF. I have to believe it's just a project setting someplace, which is why I'd really like to see a working IVF solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
====> main.c:
#include
#include
extern float ARRAYTEST ( int *) ;
int main()
{
float a;
int b = 0;
// Cause an array out of bounds error
__try {
a = ARRAYTEST ( &b ) ;
}
__except ( 1 )
{
printf("exception caught");
exit(99);
}
exit(0);
}
====> ARRAYTEST.f90:
REAL(4) FUNCTION ARRAYTEST(R1)
INTEGER R1
REAL(4) anum(2)
! Cause an array bounds exception
ARRAYTEST = anum(r1)
END FUNCTION
On CVF, the debugger steps thru the "exception caught" message, and exits with cc=99 as expected. But on IVF, the debugger registers an unhandled exception as soon as the ARRAYTEST=anum(r1) line is executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmm. I tried a similar example and that doesn't match my observation. My findings, though, are not useful either: I took a casual look at disassembly output of statement (located in a dll):
i1(index) = 0
and it turns out that it evaluates to:
if (index_is_out_of bounds)
call _for_emit_diagnostic !ugly message box
else
assign zero where appropriate
end if
IOW, no "Array out of bounds" exception (0xC000008C) is raised. I find it kind of odd; maybe it can be regulated by environment variables. I do, hovever, have FOR_IGNORE_EXCEPTIONS set to TRUE and traceback turned off in the project settings. Setting FOR_DISABLE_DIAGNOSTIC_DISPLAY to TRUE doesn't help either -- the process simply dies after the debugger signals "Unhandled exception: User breakpoint".
Steve?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have no problem using SEH in IVF 9.1 in and out of the debugger.
Two cases:
1.two nonfatal and one fatal exception
Debug Output:
First-chance exception at 0x7c59bc81 in FcallsfDLL.exe: 0xC000008F: Floating-point inexact result.
'FcallsfDLL.exe': Loaded 'C:WINNTsystem32dbghelp.dll', Cannot find or open a required DBG file.
First-chance exception at 0x7c59bc81 in FcallsfDLL.exe: 0xC0000091: Floating-point overflow.
First-chance exception at 0x7c59bc81 in FcallsfDLL.exe: 0xC000008C: Array bounds exceeded.
The thread 'Win32 Thread' (0x7fc) has exited with code 18 (0x12).
The program '[2284] FcallsfDLL.exe: Native' has exited with code 18 (0x12).
Traceback Log:
Exception: Floating point inexact operation.
Image PC Routine Line Source
KERNEL32.dll 7C59BC81 Unknown Unknown Unknown
SimpleDLL.dll 00E04D08 _GenerateErrors 14 GenErrors.F90
SimpleDLL.dll 00E04EDE Unknown Unknown Unknown
SimpleDLL.dll 00E04BF2 _fMain 68 fMain.f90
FcallsfDLL.exe 004013D1 _FCALLSFDLLAPPLY@ 157 FcallsfDLL.f90
FcallsfDLL.exe 0040E955 Unknown Unknown Unknown
FcallsfDLL.exe 00404DFA Unknown Unknown Unknown
Exception: Floating point overflow.&nb
sp;
Image PC Routine Line Source
KERNEL32.dll 7C59BC81 Unknown Unknown Unknown
SimpleDLL.dll 00E04D6E _GenerateErrors 16 GenErrors.F90
SimpleDLL.dll 00E04EDE Unknown Unknown Unknown
SimpleDLL.dll 00E04BF2 _fMain 68 fMain.f90
FcallsfDLL.exe 004013D1 _FCALLSFDLLAPPLY@ 157 FcallsfDLL.f90
FcallsfDLL.exe 0040E955 Unknown Unknown Unknown
FcallsfDLL.exe 00404DFA Unknown Unknown Unknown
Exception: Array bounds exceeded.
Image PC Routine Line Source
KERNEL32.dll 7C59BC81 Unknown Unknown Unknown
SimpleDLL.dll 00E04DD4 _GenerateErrors 18 GenErrors.F90
SimpleDLL.dll 00E04EDE Unknown Unknown Unknown
SimpleDLL.dll 00E04BF2 _fMain 68 fMain.f90
FcallsfDLL.exe 004013D1 _FCALLSFDLLAPPLY@ 157 FcallsfDLL.f90
FcallsfDLL.exe 0040E955 Unknown Unknown Unknown
FcallsfDLL.exe 00404DFA Unknown Unknown Unknown
Information Application: The last exception was fatal and the application is closing
Information Application: Closed FortranSEH on 6/ 9/2006 at 8:51:42 AM
2. three nonfatal exceptions
Debug Output:
First-chance exception at 0x7c59bc81 in FcallsfDLL.exe: 0xC000008F: Floating-point inexact result.
'FcallsfDLL.exe': Loaded 'C:WINNTsystem32dbghelp.dll', Cannot find or open a required DBG file.
First-chance exception at 0x7c59bc81 in FcallsfDLL.exe: 0xC0000091: Floating-point overflow.
First-chance exception at 0x7c59bc81 in FcallsfDLL.exe: 0xC000008C: Array bounds exceeded.
The thread 'Win32 Thread' (0x8dc) has exited with code 0 (0x0).
The program '[2240] FcallsfDLL.exe: Native' has exited with code 0 (0x0).
Traceback Log:
Exception: Floating point inexact operation.
Image PC Routine Line Source
KERNEL32.dll 7C59BC81 Unknown Unknown Unknown
SimpleDLL.dll 00E04D08 _GenerateErrors 14 GenErrors.F90
SimpleDLL.dll 00E04EDE Unknown Unknown Unknown
SimpleDLL.dll 00E04BF2 _fMain 68 fMain.f90
FcallsfDLL.exe 004013D1 _FCALLSFDLLAPPLY@ 157 FcallsfDLL.f90
FcallsfDLL.exe 0040E955 Unknown Unknown Unknown
FcallsfDLL.exe 00404DFA Unknown Unknown Unknown
Exception: Floating point overflow.&
nbsp;
Image PC Routine Line Source
KERNEL32.dll 7C59BC81 Unknown Unknown Unknown
SimpleDLL.dll 00E04D6E _GenerateErrors 16 GenErrors.F90
SimpleDLL.dll 00E04EDE Unknown Unknown Unknown
SimpleDLL.dll 00E04BF2 _fMain 68 fMain.f90
FcallsfDLL.exe 004013D1 _FCALLSFDLLAPPLY@ 157 FcallsfDLL.f90
FcallsfDLL.exe 0040E955 Unknown Unknown Unknown
FcallsfDLL.exe 00404DFA Unknown Unknown Unknown
Exception: Array bounds exceeded.
Image PC Routine Line Source
KERNEL32.dll 7C59BC81 Unknown Unknown Unknown
SimpleDLL.dll 00E04DD4 _GenerateErrors 18 GenErrors.F90
SimpleDLL.dll 00E04EDE Unknown&nbs
p; Unknown Unknown
SimpleDLL.dll 00E04BF2 _fMain 68 fMain.f90
FcallsfDLL.exe 004013D1 _FCALLSFDLLAPPLY@ 157 FcallsfDLL.f90
FcallsfDLL.exe 0040E955 Unknown Unknown Unknown
FcallsfDLL.exe 00404DFA Unknown Unknown Unknown
Information Application: FortranSEH module closed on 6/ 9/2006 at 9: 2:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm attaching the ARRAYTEST example above as a zip file which contains both the IVF 9.0 solution (.sln) and the CVF 6.6 workspace (.dsw) for anyone who want to test this for themselves. On CVF, the program correctly exits with a cc=99, but on IVF it generates an unhandled exception.
For CVF, open sehtest.dsw, "driver" is the active project ... just clean, build "driver.exe" and run the debugger.
For IVF, open sehtest.sln. Clean solution, build solution, and run Debug on the "driver" project.
- Longden
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav, I can't follow the dialog on this between you and Steve but then again I know or could less about the inners of compilers preferring to pay the big bucks to those who do. FWIW,in Debugger/Exceptions/Win32Exceptionsall selectedexceptions break into the debuger when thown,irrespective of whether or notit is handled. When thrown, a messagebox appears withbreak/continue/ignore options. Since SEH is in place, one sees the offending line of code and chooses to continue. If it's a fatal exceptionI call into the C-Fortran wrapper to quit (no STOP here) so I can fix the code. Isn't this how it's supposed to work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was discussing this with some of the developers at lunch today and I have been asked to write up a "feature request" for some mechanism to allow applications to get some sort of hook into the ifort RTL's error reporting process. What I envision is the ability to specify a callback routine which is called just before the error would be displayed - the called routine could choose to do something else (display a different message to the user, log it, etc.) and then return to the RTL with a status of what to do next (go ahead and display message, don't display, etc.) Clearly the called routine would need some reasonable way of figuring out what kind of error had occurred, so it could choose whether or not to act. One might also envision a way to allow multiple such handlers in a chain. We're not going to reinvent SEH here (the Fortran standards committee has been unable to come to agreement on that issue.)
The issue of "continue" is thorny. In many cases, an error is non-continuable. We need to look at all the possible cases and think about what mechanisms make sense. We have the benefit of knowing about mechanisms used successfully on VMS, where the OS was designed for such things, so we know what we're aiming for.
No promises and no timeframes. But we are interested.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page