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

internal procedure allowed to pass as argument?

abhimodak
New Contributor I
860 Views

I stumbled upon compiler allowing internal procedure passed as argument. I believe the standard prohibits doing so. The snippet below would thus compile without error and actual steps into subroutine Model from program Test.

Abhi

===

Program Test

Implicit None

Integer, Parameter :: N = 5
External :: Library

Call Library(N, Model)

Contains

Subroutine Model(n)
Implicit None
Integer, Intent(IN) :: n
Print *, n
End Subroutine Model

End Program Test

Subroutine Library(n, Model)

Implicit None

Integer, Intent(IN) :: n

Interface
Subroutine Model(n)
Integer, Intent(IN) :: n
End Subroutine Model
End Interface

Call Model(n)

End Subroutine Library
0 Kudos
2 Replies
Steven_L_Intel1
Employee
860 Views

This is an extension to F2003 that we support. It is standard-conforming in F2008. Note that the standard describes a standard-conforming program. If you compiled this with standards checking, you'd see:

t.f90(8): warning #7601: F2003 standard does not allow an internal procedure to be an actual argument procedure name. (R1214.4). [MODEL]
Call Library(N, Model)
----------------^

0 Kudos
IDZ_A_Intel
Employee
860 Views

Yes, quite right. Thanks!

Abhi

0 Kudos
Reply