Function Fortran未解析模块过程规范名称
我有一个示例代码来测试我对Fortran 90中重载子程序的理解。以下是我的例子:Function Fortran未解析模块过程规范名称,function,fortran,overloading,fortran90,subroutine,Function,Fortran,Overloading,Fortran90,Subroutine,我有一个示例代码来测试我对Fortran 90中重载子程序的理解。以下是我的例子: module testint_mod use constants implicit none private :: testvReal private :: testvdpn interface testv module procedure testvReal module procedure testvdpn end interface
module testint_mod
use constants
implicit none
private :: testvReal
private :: testvdpn
interface testv
module procedure testvReal
module procedure testvdpn
end interface
contains
subroutine testvReal(vR)
implicit none
real,intent(in) :: vR
write(*,*) vR
end subroutine
subroutine testvdpn(vdpn)
implicit none
real(kind=dpn),intent(in) :: vdpn
write(*,*) vdpn
end subroutine
end module testint_mod
program testintmain
use constants
use testint_mod
implicit none
real :: r
real(kind=dpn) :: d
integer :: i
interface testv
module procedure testvdpn
end interface
r = 2.0
d = dble(4.0)
call testv(r)
call testv(d)
end program testintmain
其中常数包括:整数,参数dpn=所选的\u实数\u种类(14)
我得到一个错误:
testint_main.F(10) : Error: Unresolved MODULE PROCEDURE specification name. [T
ESTVDPN]
module procedure testvdpn
-------------------------^
我做错了什么?是否不允许使用选定的\u real\u kind()重载函数??谢谢你的帮助 接口testv主程序中的规范存在问题:编译器抱怨主程序中无法解析
testvdpn
,并且确实没有任何可通过该名称公开访问的内容。此外,testv
已经可以通过使用定义它的模块testint\u mod
的关联来访问。这三条线应该去掉
回答后面的问题
是否不允许使用选定的_real_kind()重载函数
如果泛型集中的两个过程仅通过实数参数的种类类型参数来区分,那么一个(或多个)来自所选的\u real\u kind
结果并不重要。但是,应注意种类参数确实是不同的。例如,示例的selected\u real\u kind(14)
返回的种类可能与默认real的种类相同。这种情况以及类似情况是不允许的。尽管编译器肯定会抱怨
另外请注意,为了完整性,对于函数(而不是问题的子例程),消歧必须仅通过函数的参数,而不是结果。啊,当然,我忘记了通过use语句进行访问。现在好像很好用,谢谢!不,函数结果的类型在泛型解析中不起作用!只有论点是重要的。@VladimirF上下文应该是没有考虑结果,但我希望在现在的回答中澄清这一点。