Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Optional argument and Explicit interfaces

abhimodak
New Contributor I
1,592 Views

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:

32 bit

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

0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,592 Views
The difference between 32-bit and 64-bit is most likely that you converted a project from CVF, which applied the STDCALL conventions. On IA-32, this appends a @n suffix where n is based on the number of arguments. However, that is an IA-32 only method - on Intel 64, there is only the "C" convention, which has no suffix. Intel Fortran defaults to the "C" convention on IA-32.

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)
---------------------^
0 Kudos
abhimodak
New Contributor I
1,592 Views

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

0 Kudos
Steven_L_Intel1
Employee
1,592 Views
We have made significant progress, but you won't see every bit of F2003 from us this year. I'm not sure you'll see that from ANY vendor, though IBM is closest and might do so by the end of the year. Which specific features are you looking for?
0 Kudos
Reply