これは重複している必要があるように感じますが、どこにも見つからないようで、非常に迅速なグーグル検索では何も得られませんでした。
モジュール内のものの名前を変更して、ローカル(またはグローバル)の名前と競合しないようにする方法はありますか?例を考えてみましょう。
module namespace
real x !some data
contains
subroutine foo()
write(0,*) "foo!"
end subroutine foo
end module
subroutine foo()
write(0,*) "foo is the new bar :)"
end subroutine
program main
use namespace
real x
call foo() !should print "foo is the new bar"
call namespacefoo() !somehow call module namespace's version of foo
end program main
上記のコードは、x
が定義されていないためコンパイルされません。もちろん、という名前のローカル変数が必要ない場合はx
可能use namespace, only: foo
ですが、ローカル変数名を壊さなければならないのは少し面倒なようです。(補足として、私はこれを以前に見たことがあると確信していますonly
が、ステートメントの一部にいくつかの魔法があります...)
Pythonも知っている人のために、Pythonに似たものを探しています。
import namespace as other_namespace
または、Fortranにはそのレベルの名前空間制御がないため、次のように推測します。
from namespace import somefunc as otherfunc
from namespace import somedata as otherdata