Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29278 Discussions

EXTERNAL subroutines, INTERFACE and modules

OP1
New Contributor III
363 Views

When you pass a subroutine SUB as a dummyargumentto other subroutines, you can define it as EXTERNAL, or, even better, define a INTERFACE block in these calling subroutines.

Is it possible to havethis INTERFACE block defined in a module, so that the INTERFACE block doesn't have to be explicitly written for each of the calling subroutines? When I try to do this I get the following error message:

"Error: The same named entity from different modules and/or program units cannot be referenced. "

I don't want to have to type the INTERFACE block for SUB for each of my subroutines (SUB is an error handling subroutine and therefore is called by a very large number of subroutines in my libraries). On the other hand I want to make sure that the syntax of SUB (which is written by the user and linked with my libraries) is correct (so that the linker detects possible problems).

What's the best way to do this?

Thanks,

Olivier

0 Kudos
2 Replies
Steven_L_Intel1
Employee
363 Views
The way to do this is with an ABSTRACT INTERFACE, but this is not working well in the current compiler. Here's an example that does work:

[plain]module mymod
abstract interface
subroutine extsub_int (a,b)
integer a
real b
end subroutine extsub_int
end interface
end module mymod

subroutine callit (extsub, a, b)
use mymod
procedure(extsub_int) :: extsub
integer a
real b

call extsub (a,b)
end[/plain]
0 Kudos
OP1
New Contributor III
363 Views
Ah, that's very interesting. That's exactly what I need. I am still using IVF 10, but will upgrade to IVF 11 later on. I will be looking forward to using this neat convenience feature.

I guess right now I am stuck with explicitly including the interface blocks (maybe usingan INCLUDE statement - although I am not too found of this solution).

Thanks Steve!

Olivier

0 Kudos
Reply