我为下列函数创建了一个接口
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为输出定义如下的函数: 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我搞错了
There is no specific function for the generic 'numd' at (1) 在以下子例程中调用numd时
Subroutine opscanc (ct)
  Class (*), Intent (Out) :: ct
  ct = numd (5, mold=ct)
End Subroutine opscanc我该如何解决这个问题?
发布于 2016-05-20 03:18:59
在调用mold=ct子例程中对numd的调用中的第二个实际参数( opscanc )有一个声明的类型,它是无限多态的。根据特定过程的接口示例,泛型接口中的任何特定过程都没有第二个虚拟参数的类型是无限多态的。
无限多态实际参数与具有某些声明类型的虚拟参数不兼容,因此没有匹配的特定过程可调用。
(这里比较的方向很重要-具有某种声明类型的实际参数与无限多态的虚拟参数兼容,因此默认的整数字面常量5可以与第一个具有无限多态的虚拟参数相关联。)
您需要提供这样一个匹配的特定过程,或者在opscanc中使用SELECT类型构造来通过声明的类型(即其动态类型(或其动态类型的父类型)访问ct指定的对象。
https://stackoverflow.com/questions/37336772
复制相似问题