Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Generics 传递多态参数时,没有泛型的特定函数_Generics_Fortran - Fatal编程技术网

Generics 传递多态参数时,没有泛型的特定函数

Generics 传递多态参数时,没有泛型的特定函数,generics,fortran,Generics,Fortran,我已经为以下函数创建了一个接口 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

我已经为以下函数创建了一个接口

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

如何解决此问题?

在调用
opscanc
子例程中的
numd
时,第二个实际参数(
mold=ct
)具有一个声明的类型,该类型是无限多态的。根据您的特定过程接口示例,泛型接口中的任何特定过程都没有第二个伪参数类型为无限多态

无限制多态实际参数与具有某些声明类型的伪参数的类型不兼容,因此没有匹配的特定过程可调用

(这里比较的方向很重要-具有某种声明类型的实际参数与无限多态性的伪参数兼容-因此默认整数文字常量
5
可以与第一个无限多态性的伪参数相关联。)


您需要提供这样一个匹配的特定过程,或者在
opscanc
中使用SELECT TYPE构造,通过声明的动态类型(或其动态类型的父类型)访问
ct
指定的对象。

第二个实际参数(
mold=ct
)在调用
opscanc
中的
numd
时,子例程具有一个声明的类型,该类型是无限多态的。根据您的特定过程接口示例,泛型接口中的任何特定过程都没有第二个伪参数类型为无限多态

无限制多态实际参数与具有某些声明类型的伪参数的类型不兼容,因此没有匹配的特定过程可调用

(这里比较的方向很重要-具有某种声明类型的实际参数与无限多态性的伪参数兼容-因此默认整数文字常量
5
可以与第一个无限多态性的伪参数相关联。)

您需要提供这样一个匹配的特定过程,或者在
opscanc
中使用SELECT TYPE构造,通过声明的动态类型(或其动态类型的父类型)访问
ct
指定的对象