【问题标题】:Is there a way to distinguish between subroutines of the same name in two different fortran90 modules? [duplicate]有没有办法区分两个不同的fortran90模块中的同名子程序? [复制]
【发布时间】:2017-06-22 13:59:44
【问题描述】:

如果我很不幸不得不使用两个具有共同子例程名称的不同 Fortran90 模块,有没有办法区分这两个子例程?

【问题讨论】:

  • 顺便说一句,这里有很大的重复潜力,但我还没有检查。使用privateonly 之类的东西应该很明显。
  • @VladimirF 我在发布之前检查了一个类似的问题。什么都没找到。
  • 在这种情况下,请参阅答案。

标签: module fortran fortran90 subroutine


【解决方案1】:

你可以使用only:

module m1
contains
  subroutine sub
  end subroutine

  subroutine other_m1
  end subroutine
end module

module m2
contains
  subroutine sub
  end subroutine

  subroutine other_m2
  end subroutine
end module

  use m1, only: sub, other_m1
  use m2, only: other2

  call sub
end

您也可以在use 语句中重命名其中一个:

  use m1
  use m2, some_other_name => sub

  call sub
end

【讨论】:

  • 第二个解决方案正是我所需要的。以前从未见过。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-11-22
  • 1970-01-01
  • 2020-09-18
  • 1970-01-01
  • 2020-08-01
  • 2012-10-11
  • 2023-03-18
相关资源
最近更新 更多