1

OOP を使用して Fortran コードの可読性を改善したいと考えています。a%b%c%d%eモジュールで定義された、非常に複雑な派生型になりますmymod

今、私が行うサブルーチンで

subroutine test
    use mymod, only: a
    ! lots of unrelevant stuff, especially with a%b%c%d%e.
end subroutine

私の問題は次のとおりです。この特定のサブルーチンで、名前をa%b%c%d%e単純なnewname.

たとえば、次のようにテストしましuse mymod, only: a%b%c%d%e => newnameたが、次のようなコンパイル エラーが表示されます。

エラー: USE ステートメントの構文エラー

4

2 に答える 2

4

associateコンストラクトを使用してこれを行うことができます。

subroutine test
    use :: mymod, only: a
    associate(newname => a%b%c%d%e)
        ! lots of unrelevant stuff, now using newname.
    end associate
end subroutine
于 2013-04-12T15:26:39.920 に答える