fortran模块的子程序名称冲突 [英] fortran modules' subroutine name conflict
本文介绍了fortran模块的子程序名称冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个不同的模块,每个模块都有相同的子程序。主程序会根据一定的条件调用其中的一个。如果你有两个模块包含相同方法 foo()
的和 B
然后首先创建一个本地别名为
program SOModNames
use A,fooA => foo
使用B,fooB => foo
隐式无
!变量
real X(10),Y(10)
调用fooA(X,10)
调用fooB(Y,10)
结束程序SOModNames
Unofrtunatelty不能用调用A :: foo模块(X,10)
为例。
I have two different modules each one has the same subroutine. main program will call one of them based on a certain condition. I want to avoid renaming each of these subroutine to a different name.
解决方案
If you have two modules A
and B
containing the same method foo()
then first you can create a local alias with
program SOModNames
use A, fooA => foo
use B, fooB => foo
implicit none
! Variables
real X(10), Y(10)
call fooA(X,10)
call fooB(Y,10)
end program SOModNames
Unofrtunatelty you cannot scope to a module with call A::foo(X,10)
for example.
这篇关于fortran模块的子程序名称冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文