[Fortran] 纯文本查看 复制代码
program test_assignment
implicit none
integer :: a(10,10)=1,b(10,10)=2
integer :: v(10)=[2,1,4,6,2,10,7,9,8,1]
integer :: i,j,n=10
integer, allocatable :: c(:)
real(kind=8) :: x,y
x=3.141592653589793; y=3.141592653589793_8
print '(2(a,g0,x),/)',"x=",x,"y=",y
x=1/2+x/2; y=1.0_8/2+y/2;
print '(2(a,g0,x),/)',"x=",x,"y=",y
forall(i=2:n-1,j=2:n-1)
a(i,j)=a(i,j-1)+a(i,j+1)+a(i-1,j)+a(i+1,j)
b(i,j)=a(i,j)
end forall
print '(a/,10(i0,x))',"b=",(b(i,:),i=1,n)
forall(i=1:10)a(i,:)=i
print '(/a/,10(i0,x))',"a(:,1)=",a(:,1)
a(:, 1)=a(v(:),1)
print '(/a/,10(i0,x))',"a(:,1)=",a(:,1)
allocate(c(5))
c=3
c=v
print '(/a/,10(i0,x))',"c=",c
deallocate(c)
end program test_assignment