- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
As I understand (and try my best to adhere to) the Fortran standard requires interface to be explicit if the subroutine has an optional argument. Recently, I made a mistake and "forgot" to do so. I was surprised that the 64bit compilation with version 10.0.025 did not show unresolved externals while the 32 bit did. I am using Win64 operating system and the compiler integration with VS2005. When I made the interface available, 32 bit compiler was happy as I expected.
I canno reproduce the code here so I decided to test it with a sample. I think I stumbled upon something else. Most likely, I think there is a hole in my understanding of the standard andIsincerely appreciate illumintating thoughts/suggestions.
In the attached file, the main program calls a subroutine that has optional argument which in turn calls another subroutine which also has optional argument. Here is what I find:
(a) Debug build: Runs to end but after printing 10 and 20 (please see the code), says "access violation"
(b) Release build: Runs to end (no access violation message)
64 bit
Both debug and release builds run "successfully" i.e. no access viloation although knowing the danger I don't want to call it that.
Commenting out the interface block only for the second subroutine OneMoreTest from subroutine myTest results in "success" for (a).
My question is why didn't compiler catch any unresolved externals? In the commercial software we develop, I do see it for the 32bit built WITHOTUT /gen-interfaces and /warn:interfaces etc. However, I don't see that for this test problem. Obviously I am missing something.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you build with /gen_interface and /warn:interface and compile the called routines first, the compiler should catch such problems. I do note that you are using an old compiler - we have improved this generated interface checking feature over the years.
Here's what I get for your code when I move the main program to the end of the source.
test.f90(82) : Warning: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source.
Call myTest(m, n)
---------------------^
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve.
(1) Calling convention: I think it makes sense as we use a mixed langauge program.
(2) 10.0.025 (both 32 bit and 64 bit) when used in 'correct' order as you mentioned does display the warning.
I will remember the 'compiling sequence part' of this lesson. I did observe this behavior when I had put the subroutines in different files but only now it dawns upon me why it was happening so.
We will be updating the compilers soon. I have been pushing the management to do so and in that respect have been vehemently telling them that Intel is going to release a "full" 2003 standard conforming compiler soon....I hope I don't get stranded...
Abhi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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