実際のサブルーチンを型バインド プロシージャの背後に配置し、型定義を別のファイルに配置できるかどうか疑問に思っていました。例えば:
ファイル A:
Module TypeDef
Type :: Test
Integer :: a,b,c
contains
Procedure, Pass, Public :: add => SubAdd
End Type
Type(Test) :: Test
Interface
Subroutine SubAdd(this)
Import TypeDef
Class(TypeDef), Intent(InOut) :: this
End Subroutine
End Interface
End Module
ファイル B:
Module TypeRoutines
use TypeDef
Private :: SubAdd
contains
Subroutine SubAdd(this)
Class(TypeDef), Intent(InOut) :: this
this%c=this%a+this%b
End Subroutine
End Module
最初にファイル A をコンパイルしてからファイル B をコンパイルすると、次ifort
のエラー メッセージが表示されるため、これは機能しません。
The name of the module procedure conflicts with a name in the encompassing scoping unit
これの主な理由は、型によっては、多くの型バインド プロシージャを作成する必要があり、一部のファイルは数百行にわたって展開され、作業が非常に面倒になるためです。最終的な目標は、すべてのサブルーチンを別のファイルに配置することです。
何か案は?