名前リストを使用して派生型にネストされた割り当て可能な配列を作成するのに問題があります。最小の例を以下に示します。どのようにして、派生型内の割り付け可能な配列をネストされていないかのように動作させるようにプログラムを変更できますか? fooで名前リストを使用して派生型に割り当て可能な配列を書き込む方法は?
program test
implicit none
type struct_foo
integer, allocatable :: nested_bar(:)
end type struct_foo
integer, allocatable :: bar(:)
type(struct_foo) :: foo
! namelist/list/foo, bar
namelist/list/bar
allocate(bar(5))
bar = [1:5]
allocate(foo%nested_bar(5))
foo%nested_bar=[1:5]
write(*,list)
end program test
名前リストからコメントアウト、それは出力を生成し、うまく動作します:
&LIST
BAR = 1, 2, 3, 4, 5
/
fooで含まれ、プログラムがコンパイルに失敗します。
>> ifort -traceback test_1.f90 -o test && ./test
test_1.f90(20): error #5498: Allocatable or pointer derived-type fields require a user-defined I/O procedure.
write(*,list)
--------^
compilation aborted for test_1.f90 (code 1)
どのコンパイラを使用しているか教えていただけますか? – chw21
ifort(IFORT)15.0.3 20150408 – lenzinho