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

Procedures as arguments in subroutine calls

Svein-Atle_Engeseth
505 Views

Hi,
I have a program where many of the subroutines have procedures in the argument list.
Many of the subroutines have the same procedures passed.
Each subroutine has an INTERFACE for explicit declaration of the procedures.

I thought I could put these interfaces in a module and then USE the module in the subroutines.
This failed.
I had to also include the line: PROCEDURE(procname) :: MY_FUNC.

Is this according to the standard?

I have included a sample program that shows the same behaviour.
My compiler is: Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.0.166 Build 20191121
Windows 10.

Regards,
Svein-Atle Engeseth

 

0 Kudos
3 Replies
mecej4
Honored Contributor III
505 Views

On line 20, replace INTERFACE by ABSTRACT INTERFACE, and on line 88 write the correct syntax for IMPORT, and then your program will be OK.

0 Kudos
Svein-Atle_Engeseth
505 Views
Hi, Thanks for the answer. My point was: Why is it necessary to have the line: PROCEDURE(name) :: FUNC. If I change to an abstract interface, this line is still necessary. Why shouldn't the USE statement be equivalent to having the interfaces in the subroutine? The IMPORT is written correctly. Regards,
0 Kudos
mecej4
Honored Contributor III
505 Views

If you do not specify "ABSTRACT", you are declaring an interface to one specific subprogram such as FUNC. With ABSTRACT, you are declaring an interface to a class of procedures FUNC1, FUNC2,..., all of which have the same interface.

An analogy: we can define a data type. Such a definition does not create any variables of that type, so declarations of variables must also be given. An abstract interface defines the characteristics of a type of procedure, i.e, a procedure code type, rather than data. The procedure(proc) declaration declares one procedure of that type.

I think that the ONLY clause in the IMPORT statement was added for F2018.

0 Kudos
Reply