| 子程序中的动态数组,如果没有save属性(默认没有),退出子程序会自动释放。你可以用这个代码验证。 [Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode program test
  do k=1,10
    call sub 
  end do
  pause
end program test
  
subroutine sub
  implicit none
  integer,save::i=1
  integer(4),allocatable:: a(:,:,:)
  
  allocate(a(1024,1024,1024/4)) ! 1G内存
  a=i
  write(*,*) a(1,1,1)
  i=i+1
end subroutine
   |