[英]No specific function for generic when passing a polymorphic argument
I have created an interface for the following functions 我已经为以下功能创建了一个界面
Interface numd
Module Procedure :: numcl_int8, numcl_int16
Module Procedure :: numcl_int32, numcl_int64
Module Procedure :: numcl_real32, numcl_real64
Module Procedure :: numcl_real128
End Interface numd
The functions as defined as follows for output as Int8, Int16, Int32, Int64, Real32, Real64, Real128. 对于输出为Int8,Int16,Int32,Int64,Real32,Real64,Real128的函数,定义如下。
Function numcl_int8 (t, mold) Result (b)
Integer (Int8) :: b
Class (*), Intent (In) :: t
Integer (Int8), Intent (InOut) :: mold
End Function numcl_int8
I am getting error 我遇到错误
There is no specific function for the generic 'numd' at (1)
when calling numd in the following subroutine 在以下子例程中调用numd时
Subroutine opscanc (ct)
Class (*), Intent (Out) :: ct
ct = numd (5, mold=ct)
End Subroutine opscanc
How can I solve this problem? 我怎么解决这个问题?
The second actual argument ( mold=ct
) in the call to numd
in the opscanc
subroutine has a declared type that is unlimited polymorphic. 第二实际参数( mold=ct
在呼叫)到numd
在opscanc
子程序具有声明的类型是无限多态的。 Based on your example of the interface of the specific procedures, none of the specific procedures in the generic interface have the type of the second dummy argument as unlimited polymorphic. 根据特定过程接口的示例,通用接口中的特定过程都没有第二个伪参数的类型为无限多态。
An unlimited polymorphic actual argument is not type compatible with a dummy argument that has some declared type, so there is no matching specific procedure to call. 无限多态实际参数与具有某种已声明类型的虚拟参数在类型上不兼容,因此没有匹配的特定过程要调用。
(The direction of the comparison is important here - an actual argument that has some declared type is compatible with a dummy argument that is unlimited polymorphic - hence the default integer literal constant 5
can be associated with the first dummy argument that is unlimited polymorphic.) (这里的比较方向很重要-具有某种声明类型的实际参数与无限多态的虚拟参数兼容-因此,默认整数文字常量5
可以与无限多态的第一个虚拟参数相关联。)
You either need to provide such a matching specific procedure, or use a SELECT TYPE construct inside opscanc
to access the object nominated by ct
via a declared type that is its dynamic type (or a parent type of its dynamic type). 您要么需要提供这样一个匹配的特定过程,要么在opscanc
内使用SELECT TYPE构造,以通过声明的类型(其动态类型(或其动态类型的父类型))访问ct
提名的对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.