gdbでFortran型で定義された割り当て可能な配列をどのように出力しますか?GDBのFortran配列構造コンポーネントを調べるには?
は、私は次のFortran 90のコードがあるとします。
program test
implicit none
type :: t_buzzer
real(8), allocatable :: alloc_array(:,:)
end type
integer, parameter :: nx=2, ny=3
integer :: ii, jj
real(8) :: fixed_array(nx,ny)
real(8), allocatable :: alloc_array(:,:)
type(t_buzzer) :: buzz
allocate(alloc_array(nx,ny))
allocate(buzz%alloc_array(nx,ny))
do jj=1,ny
do ii=1,nx
fixed_array(ii,jj) = 10.0 * real(ii) + real(jj)
end do
end do
alloc_array = fixed_array
buzz%alloc_array = alloc_array
write(*,*) fixed_array
write(*,*) alloc_array
write(*,*) buzz%alloc_array
deallocate(alloc_array)
deallocate(buzz%alloc_array)
end program test
は、GDBでそれを実行し、私は表示するにはalloc_array
(gdb) print fixed_array
$1 = ((11, 21) (12, 22) (13, 23))
(gdb) print alloc_array
$2 = ((0))
fixed_array
のコンテンツを視聴するprint
機能を使用することはできませんが、内容はalloc_array
です。使用する必要があります
(gdb) print *((real_8 *)alloc_array)@6
$3 = (11, 21, 12, 22, 13, 23)
今度はbuzz%alloc_array
の内容を見たいと思います。上記のコマンドのいずれもがここで働いていない:
(gdb) print buzz%alloc_array
$4 = ((0))
(gdb) print *((real_8 *)buzz%alloc_array)@6
Attempt to extract a component of a value that is not a structure.
GDBのドキュメントから、私はexplore
機能を使用する必要がありますように、それはそうです。私はそれをしようとするが、何も印刷されません取得します:
(gdb) explore buzz
The value of 'buzz' is a struct/class of type 'Type t_buzzer
real(kind=8) :: alloc_array(*,*)
End Type t_buzzer' with the following fields:
alloc_array = <Enter 0 to explore this field of type 'real(kind=8) (*,*)'>
Enter the field number of choice: 0
'buzz.alloc_array' is an array of 'real(kind=8) (*)'.
Enter the index of the element you want to explore in 'buzz.alloc_array': 1,1
Returning to parent value...
The value of 'buzz' is a struct/class of type 'Type t_buzzer
real(kind=8) :: alloc_array(*,*)
End Type t_buzzer' with the following fields:
alloc_array = <Enter 0 to explore this field of type 'real(kind=8) (*,*)'>
Enter the field number of choice:
(gdb)
私はbuzz%alloc_array
のコンテンツを視聴するにはどうすればよいですか?
http://stackoverflow.com/questions/16447741/can-gdb-be-used-to-print-values-of-allocatable-arrays-of-a-derived-type-in-を見ますfortr?noredirect = 1&lq = 1 –