如果参数列表的长度不同,Fortran 95 标准是否允许两个子例程(或函数)具有相同的名称?例如,
subroutine a(i)
! code here
end subroutine a
subroutine a(j,k)
! code here
end subroutine a
最佳答案
不是按照问题中给出的字面意思,而是使用界面
:
module a_wrapper
interface a
module procedure a_1
module procedure a_2
end interface
contains
subroutine a_1(i)
! code here
end subroutine a
subroutine a_2(j,k)
! code here
end subroutine a
end module
program test
use a_wrapper, only: a
call a(.....)
end program
另请参阅我对这篇文章的回答:Passing different set of variables in a FORTRAN subroutine或 M.S.B. 在这篇文章中的回答:how to write wrapper for 'allocate'
关于fortran - 如果参数列表不同,Fortran 95 是否允许两个子例程具有相同的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24187913/