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

Compilation issue with abstract type and deferred binding

OP1
New Contributor II
295 Views

The code below does not compile: the error returned by the compiler is "error #8383: The dummy arguments of an overriding and overridden binding that correspond by position must have the same characteristics, except for the type of the passed object dummy arguments.   [PROC]".

However, the alternate lines (with simultaneous use of PASS, or nothing for both PROCEDURE statements) compile ok.

I am struggling a bit to understand this behavior.

MODULE M1
IMPLICIT NONE
TYPE,ABSTRACT :: T1
    INTEGER :: I
    CONTAINS
    PROCEDURE(PROC),DEFERRED,NOPASS :: PROC
    ! PROCEDURE(PROC),DEFERRED,PASS :: PROC 
    ! PROCEDURE(PROC),DEFERRED      :: PROC
END TYPE T1
PRIVATE :: PROC
ABSTRACT INTERFACE
    SUBROUTINE PROC(ARG)
    IMPORT :: T1
    IMPLICIT NONE
    INTEGER :: A
    CLASS(T1),INTENT(INOUT) :: ARG
    END SUBROUTINE PROC
END INTERFACE
END MODULE M1


MODULE M2
USE M1
IMPLICIT NONE
TYPE,EXTENDS(T1) :: T2
    REAL :: R
    CONTAINS
    PROCEDURE,NOPASS :: PROC
    ! PROCEDURE(PROC),PASS :: PROC
    ! PROCEDURE(PROC)      :: PROC
END TYPE T2
PRIVATE :: PROC
INTERFACE
    MODULE SUBROUTINE PROC(ARG)
        IMPLICIT NONE
        INTEGER :: A
        CLASS(T2),INTENT(INOUT) :: ARG
    END SUBROUTINE PROC
END INTERFACE
END MODULE M2

 

0 Kudos
2 Replies
IanH
Honored Contributor II
295 Views

As shown... the argument is not a passed argument (because NOPASS is specified).  When overriding a binding, all the characteristics of dummy arguments that are not passed arguments must match.  The characteristics of an argument include its type. 

The type of the argument for the interface for the deferred binding in `T1` is `T1`, while the type of the corresponding argument for the procedure for the overriding binding is different  - it is `T2`.

For a passed argument, the type of the passed argument may differ - the passed argument is required to have the same type as the type definition that has the binding.

0 Kudos
OP1
New Contributor II
295 Views

Thanks - I got it. I made the mistake to assume that ARG was still required among my procedure arguments when NOPASS is used; it's clearly not the case.

I got my program to work, thanks again for your help!
 

0 Kudos
Reply