[Fortran] 纯文本查看 复制代码
program ex0819
implicit none
integer,parameter::dim1=2
integer,parameter::dim2=2
integer,parameter::dim3=2
integer::a(dim1,dim2,dim3)
a(:,:,1)=1
a(:,:,2)=2
call getarray1(a(:,:,1),dim1,dim2)
call getarray2(a(1,1,2),dim1)
stop
end program ex0819
subroutine getarray1(a,dim1,dim2)
implicit none
integer::dim1,dim2
integer::a(dim1,dim2)
write(*,*)a
return
end subroutine getarray1
subroutine getarray2(a,dim1)
implicit none
integer::dim1,dim2
integer::a(dim1,*)!最后一维可以不赋值数组大小
integer::i
write(*,*)(a(:,i),i=1,2)
return
end subroutine getarray2