陣列指標

具有 POINTER 屬性的陣列稱為陣列指標。 當它與目標相關聯時,會透過下列方式來決定它的範圍及形狀:
  • 指標指派
  • 引數關聯
  • 執行 ALLOCATE 陳述式

範例

下列範例宣告陣列指標,並決定其界限和儲存體關聯。

REAL, POINTER, DIMENSION(:, :) :: b
REAL, TARGET, DIMENSION(5, 10) :: c, d(10, 10)
b => c   ! Bounds of b are now defined (1:5, 1:10)
b => d   ! b now has different bounds and is associated with different storage

如果您使用下列 ALLOCATE 陳述式並使用 -qinitalloc 選項編譯您的程式,則陣列指標 b 的所有元素都會起始設定為零。

ALLOCATE(b(5, 5)) ! Change bounds and storage association again

相關資訊