fortran - 如果参数列表不同,Fortran 95 是否允许两个子例程具有相同的名称?

标签 fortran fortran90 fortran95

如果参数列表的长度不同,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/

相关文章:

algorithm - 3D 中的最小边界框算法

fortran - 在openmp中,fortran子程序中的局部变量默认是私有(private)的吗?

linux - 错误 : 'b' argument of 'sign' intrinsic at (1) must be the same type and kind as 'a'

fortran - 作为函数参数的内在函数

module - Fortran 模块版本 fatal error

loops - 不确定在 openmp 循环中应该共享或私有(private)什么

linux - 选择linux上两个版本的gcc作为非管理员

fortran - 用 Fortran 重载函数

arrays - 数组排序算法的问题

string - 在 Fortran 90 中将字符串转换为整数