次の例は、dbx で割り当て済み配列を処理する方法を示しています。
demo% f90 -g Alloc.f90
demo% dbx a.out
a.out の読み込み中
ld.so.1 の読み込み中
...... (注 1)
(dbx) list 1,$
1 PROGRAM TestAlocate
2 INTEGER n, status
3 INTEGER, ALLOCATABLE :: buffer(:)
4 PRINT *, `Size?'
5 READ *, n
6 ALLOCATE (buffer(n), STAT=status)
7 IF (status /= 0) STOP `cannot allocate buffer'
8 buffer(n)=n
9 PRINT *,buffer(n)
10 DEALLOCATE (buffer, STAT = status)
11 END
(dbx) stop at 6
(2) stop at "Alloc.f90":6
(dbx) stop at 9
(3) stop at "Alloc.f90":9
(dbx) run
実行中: a.out
(プロセス id 23512)
Size?
1000
MAIN で停止しました 行番号 6 ファイル "Alloc.f90" (注 2)
6 ALLOCATE (buffer(n), STAT=status)
(dbx) whatis buffer
INTEGER*4 , allocatable::buffer(:)
(dbx) next
MAIN で停止しました 行番号 7 ファイル "Alloc.f90"
7 IF (status /= 0) STOP `cannot allocate buffer'
(dbx) whatis buffer
INTEGER*4 buffer(1:1000)
(dbx) cont
MAIN で停止しました 行番号 9 ファイル "Alloc.f90" (注 3)
9 PRINT *,buffer(n)
(dbx) print n
n = 1000
(dbx) print buffer(n)
buffer(n) = 1000 (注 4)
注 1: Alloc.f90
注 2: 行番号 6 ではサイズは未知
注 3: 行番号 9 ではサイズは未知
注 4: buffer (1000)