- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been having difficulty getting an optional argument to work properly. I've got a Fortran written DLL with many passed arguments. The last two are optional...an integer and a real*8. If I do not pass along these two arguments to the DLL and examine what is received by the DLL, the integer is registered as ' Undefined pointer/array' and is correctly identified as .false. with a 'Present' command. The real, however, is registered as an 'Undefined address', and is incorrectly identified as .true. with a 'Present' command. I've tried much simpler test cases that do not use the DLL interface and they work fine. Is there something going wacky with the DLL? Everything is written in Fortran, so I'd think that the interface would be fairly simple...
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ummm....if they are optional and you do not pass them to the routine then in the routine they are undefined. which you are finding properly. Any additional tests on them would be if, and only if, they are defined. Since 'undefined' means who knows or cares what's in those placeholders?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The placeholders, as identified when I pause the program to debug are different. The integer is 'Undefined pointer/array' while the real is 'Unidentified'. Apparently this difference matters to the compiler because it still thinks something was passed into the 'Unidentified' variable (even though nothing was). Very frustrating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have OPTIONAL arguments, an explicit interface to the procedure must be visible to the caller. Did you do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve - I had not done that (hand smack upside the head). I'll give that a try and keep you posted. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve - Thanks, as always! I did not know that the otional arguments needed the interface, but it makes perfect sense. I've added the interface and everything works great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Normally, when the caller and callee are compiled in the same project, the default "Generated Interface Checking" feature would catch this, but if you had your DLL as a separate project and, obviously, didn't have a module defining the interface, you'd run into this problem.
I'll also recommend a read of Doctor Fortran Gets Explicit - Again!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page