Optional Argument Problem

Optional Argument Problem

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...

7 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

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?

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.

If you have OPTIONAL arguments, an explicit interface to the procedure must be visible to the caller. Did you do this?

See also Doctor Fortran and the Virtues of Omission.

Steve - Intel Developer Support

Steve - I had not done that (hand smack upside the head).  I'll give that a try and keep you posted.  Thanks!

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.

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!

Steve - Intel Developer Support

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen