Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Trapping Errors in my FORTRAN DLL

tonywh
初学者
1,164 次查看
Hey, is there something in FORTRAN (note I am not that experienced with FORTRAN) that is equivalent to the
ON ERROR statement in VB. I am trying to trap unknown or unexpected errors in my DLL so that my VB application does not fail. I would like to pass an ErrorFlag back to VB, but I cannot find anything in FORTRAN that traps just general errors. Anyone out there know how? Thanks
0 项奖励
9 回复数
Steven_L_Intel1
1,164 次查看
There's a chapter or two in the Visual Fortran Programmer's Guide on exception handling - I suggest you read this. Your options are limited when dealing with DLLs, which have no context to hang exception handling on.

Steve
0 项奖励
rahzan
新分销商 I
1,164 次查看
Steve,
The chapter on exception handling is one of most obscure pieces of fortran documnetation, which perhaps reflects the functionality itself. with the vague understandin it left me with, It was like there are only a few types of errors you can catch and even then you have to do all kinds of complicated things to catch the error instead of something like C--'s try/catch.

I tried the C-wrapper idea once on an inprocess com-dll and the compiler gave all kinds of errors.

I sent this question to vfsupport a very long time ago and noone even acknowledged it.

Is C-wrapper even an option?
If so can you/anyone provide a simple example of its usage aroubd a dll call?

Tim
0 项奖励
Steven_L_Intel1
1,164 次查看
I'll admit that exception handling is not the easiest thing to learn or use. You could use a C++ wrapper around your routines, I think.

If you got NO response to a vf-support request, then either we didn't receive it or the e-mail address you sent it from was invalid. Please try again.

Steve
0 项奖励
gfthomas8
新手
1,164 次查看
IMO, the treatment of exception handling in the CVF docs is excellent. There are several samples that illustrate how to put a C++ wrapper around Fortran to trap errors in conjunction with TRACEBACK. It's also possible to write a wrapper in C# and VB.NET and even in VB5/6. I've tried them all and they all work. So keep at it, it'll come.

Ciao,
Gerry T.
0 项奖励
tonywh
初学者
1,164 次查看
After reading the error Trapping information in the CVF documentation SEVERAL times, I think I understand about 80% of it. Reading the VB Example was a great help, but I could not try it for myself. I don't have access to a C++ Compiler to compile the wrapper. My project is running on limited budget, buying the C++ compiler is a stretch..To me and my limited experience, this method seemed like a long winded way of doing things. Can you build the Wrapper in VB alone? This would make things sure a lot easier?

Tony
0 项奖励
gfthomas8
新手
1,164 次查看
Try:

(1) http://archive.devx.com/premier/mgznarch/vbpj/1999/05may99/bb0599.pdf

When your DLL is ready to crash, do a RaiseException API call instead of a STOP and let VB trap the error.

(2)
http://www.wintellect.com/about/instructors/robbins/code.aspx and download CrashFinder 2.1.

BTW, you did debug your DLL in the VS IDE using your VB client, didn't you?

HTH,
Gerry T.
0 项奖励
tonywh
初学者
1,164 次查看
Thank you g.f.Thomas!! I used your link to the "No Exceptions" Article. I followed this example and I was able to catch unexpected errors from my FORTRAN DLL and not crash my VB parent application. Thanks very MUCH!!
0 项奖励
Intel_C_Intel
员工
1,164 次查看
I would also like to thank g.f.Thomas!!! This is the first really helpful and easy method of exception handling I have seen from VB 6 to a Fortran .dll. It works like a charm.

I have attached a zip file for the project mentioned in the article.
0 项奖励
billaustralia
初学者
1,164 次查看
Very interesting. But mostly over my head.

But does seem to explain a procedure I have been using successfully for a VB5 program calling either VF or Lahey fortran dll. Also a MS Visual C calling the same.

To quit in the fortran and return to the vb5 or c, I simple use an integer division by zero.
i=0
i=6/i
This is picked up by the vb or c error handler as an integer div by zero. This happens many calls deep in the fortran, but still jumps straight back to the vb. Of course I set an argument in the call to the dll to indicate an error right at the start, and only remove it on no error return

Further info is in the topic in this forum
STOP inside a DLL?
0 项奖励
回复