There is no corresponding routine to call a routine with a common call of the associated type

I have a type with two related procedures (GetAsScalar and GetAsList) as part of a common procedure (GetValue):

type, extends(TObject) :: TKeyword character(len=:), allocatable :: fValue contains procedure, private :: GetAsScalar procedure, private :: GetAsList generic :: GetValue => & GetAsScalar, & GetAsList end type TKeyword 

Subroutine Signatures:

 subroutine GetAsScalar (this, value, status) !Arguments------------------------------------------------------------- class(TKeyword) :: this class(*), target :: value logical, optional :: status !... end subroutine GetAsScalar subroutine GetAsList (this, value, status) !Arguments------------------------------------------------------------- class(TKeyword) :: this class(*), pointer :: value(:) logical, optional :: status !... end subroutine GetAsList 

Internally, the TKeyword object stores the string.

If I try to use it as follows (below), I get a compilation error: "There is no corresponding subroutine for this type of associated common subroutine call"

 class(TKeyword), pointer :: key class(*), pointer :: p(:) allocate (integer::p(3)) !Code to read instantiate the TKeyword object call key%GetValue(p, status) select type (p) type is (integer) write (*,*) p end select 

If I remove GetASScalar from the general association and make it public, the following code works as expected:

 class(TKeyword), pointer :: key class(*), pointer :: p(:) allocate (integer::p(3)) !Code to read instantiate the TKeyword object call key%GetAsList(p, status) select type (p) type is (integer) write (*,*) p end select 

When passing a scalar (integer, real, character, etc.), the GetAsScalar procedure is called without problems.

I would like to know why this is happening. What am I missing in this β€œgeneral thing” that makes the compiler unable to recognize my routine as a general? Is there a way to make this work? Will there be something related to the usual signature?

I am using Intel Fortran 15.0.1.148

0
source share
1 answer

According to the answers on the intel fortran forum ( https://software.intel.com/en-us/forums/topic/537784#comment-1809520 ), this code should work, and the compiler error is probably a small error in the compiler .

The problem was exacerbated by Steve Lionel (Intel).

Thanks.

0
source

Source: https://habr.com/ru/post/1246987/


All Articles