Procedures as arguments in subroutine calls

TCE Options

TCE Open Date: 

Thursday, February 13, 2020 - 20:30

Procedures as arguments in subroutine calls


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

 

AttachmentSize
Downloadapplication/octet-stream PASSING_PROCEDURES_PGM.F903.55 KB
4 posts / 0 new

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.


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,


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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today