- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a function available that will let me test for the name of the Fortran routine that has called my subroutine?
Thanks and God bless!
Jack
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, there isn't. About the best you can do is call TRACEBACKQQ which will generate a traceback - if the program was built with traceback enabled that will contain the names of routines up the call stack. By default this is written to the console (or a popup window), but can be redirected to a file. Probably more complication than you're looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks so much, Steve, for your as-usual prompt and expert response.
You're very discerning about the complication. On to additional ENTRY points!
Thanks again, and of course ...
God bless!
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please don't use ENTRY! Maybe pass a code as an additional argument to indicate the caller.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry to challenge your digestion or blood pressure by mentioning ENTRY, Steve! But this is an old dog who knows only old tricks trying to keep an old (45-years-old!) program running that just needs a couple of new options. A lot easier to just point the calling routine into the specific code it needs than to teach the other callers how to identify themselves. ;-)
Thanks again so much for all you do with and for the Forum. You make it so pleasant and understandable for us engineers who have to write code every now and then.
God bless!
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
40 years ago, there were several incompatible versions of ENTRY (none standard).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Warning Will Robinson hack approaching...
module mod_FindCaller character(256) :: LastFile integer :: LastLine contains function FindCaller(f,l,x) real :: FindCaller, x ! same type, use generic function character*(*) :: f integer :: l LastFile = f LastLine = l FindCaller = x end function FindCaller end module mod_FindCaller subroutine FOO(A, B) use mod_FindCaller real :: A,B real :: C real :: X X = A + B goto 100 ENTRY FEE(C) X = C 100 continue print *,X print *,LastFile,LastLine end subroutine FOO program Test use mod_FindCaller implicit none ! The #defines must not be in the module ! They may be in an FPP #include file ! But not in a Fortran INCLUDE file #define FOO(a,b) foo(FindCaller(__FILE__, __LINE__, a), b) #define FEE(a) fee(FindCaller(__FILE__, __LINE__, a)) CALL FOO(1.0,2.0) CALL FEE(5.0) end program Test
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page