自动数组

时间:2016-01-19 14:56:30

标签: memory-management fortran intel-fortran

我正在编写一个程序,它应该计算一个大的稀疏矩阵(n> 1000)的逆矩阵,并且在计算过程中需要一个完整的单位矩阵。我想将此单位矩阵创建为自动数据对象。

此时,我遇到的问题是程序在访问计算程序时遇到有时卡住了(在这种情况下是MKL' PARDISO)。

为了解决这个问题,我使用了valgrindifort的几个编译器版本。我写了一个小示例程序,在valgrind观看时显示相同的行为。不幸的是,它在自行运行时不会崩溃。

module testmod
  implicit none
contains

  subroutine testsub(nl)
    integer :: nl, i, j
    !complex(8), dimension(:,:), allocatable :: b
    complex(8), dimension(nl,nl) :: b

    write(*,*) "Entering testsub"

    !allocate(b(nl,nl))
    b = 0

    write(*,*) sum(b)
    !deallocate(b)
  end subroutine
end module

program testprog
  use testmod
  implicit none

  call testsub(2000)

end program

我可以在第一个ifort 14, 15 and 16语句中使用write检测到分段错误。至少对于ifort 16,它从n=1023开始。从n=354开始,valgrind检测到无效的读取和写入(子例程中的所有3行),并警告可能的堆栈切换。

用手动管理替换自动分配(使用上面的注释行),问题似乎已经解决了。

代码有什么问题?有尺寸限制吗?或者ifort已损坏(gfortran正常工作)?

0 个答案:

没有答案
相关问题