A pointer is a
variable that has the pointer attribute.A pointer is associated with a target by allocation
or pointer assignment
具有target属性的变量,可以用指针指向该变量
program main
implicit none
integer,pointer ::a=>null(),b=>null()
integer,target ::c
integer ::d
c=1
print*,associated(a)
a=>c
c=2
b=>c
d=a+b
print*,associated(a)
print*,a,b,c,d
end
输出 2 2 2 4
The associated intrinsic returns the association status of a pointer variable
associated返回T or F,如果指针已与变量关联返回T,否则返回F
integer , pointer :: a=>null(),b=>null()
allocate(a)
a = 1
如果我们没有allocate a那么对a进行赋值是非法的
program main
implicit none
integer,pointer ::a=>null(),b=>null()
integer,target ::c
integer ::d
allocate(a)
allocate(b)
a=100
b=200
print*,a,b
c=1
a=>c
c=2
b=>c
d=a+b
print*,a,b,c,d
end
输出100 200
2 2 2 4
ALLOCATE ( allocation-list [ , STAT = stat-variable ] )
If the STAT= specifier is present, successful execution of the ALLOCATE statement causes the stat-variable to
become defined with a value of zero. If an error condition occurs during the execution of the ALLOCATE
statement, the stat-variable becomes defined with a processor-dependent positive integer value.
References
Ian Chivers / Jane Sleightholme
f90 stanard:http://www.fortran.com/f90_std.pdf