program exercise3 implicit none ! Variables real, target :: a(5:10) real, pointer :: p1(:), p2(:) ! Body of test5 p1 => a p2 => a(:) print *, associated(p1, a), lbound(p1) print *, associated(p2, a), lbound(p2) print *, associated(p1, p2), lbound(p1), lbound(p2), lbound(a) stop end program exercise3
実行結果
F
T
こんな変形しても同一認定。
program exercise4 implicit none ! Variables real, target :: a(5:10) real, pointer :: p1(:), p2(:) ! Body of test5 p1 => a p2 => a(:) print *, associated(p1, a), lbound(p1) print *, associated(p2, a), lbound(p2) print *, associated(p1, p2), lbound(p1), lbound(p2), lbound(a) stop end program exercise4
実行結果
T 5
T 1
T 5 1 5
a と a(:) のlboundが違うのは、サブルーチンに引数で渡した時によく出会うが、associated では同一認定。