Fortran中type型指针使用
(2017-04-12 03:57:24)
标签:
fortran指针type |
分类: 编程 |
module type_pointer
implicit none
type AB
integer(kind=4) :: NI,NJ
end type AB
type(AB),pointer :: M
type(AB),pointer :: P(:)
type(AB) :: D
end module type_pointer
progrm main
implicit none
integer(kind=4) :: NI,NJ
type(AB),pointer :: K
type(AB) :: L
NI=1;NJ=2
allocate( P(3) )
P%NI=NI !- 正确
D%NI=NI !- 正确
M%NI=NI !- 出现“access violation”错误
K => P(1)
K%NI=NI !- 正确
L%NI=NI !- 正确
stop
end program main