分段错误,分配阵列 - 使用Intel v14

时间:2016-02-22 08:24:37

标签: segmentation-fault fortran intel

我正在尝试编译和运行本应成功编译并使用英特尔编译器版本11运行的代码。但是我有版本14,我无法设置运行它而不会出现分段错误。

subroutine iireg2(iidata,iicoeffs)
use myparams
implicit none
real(8):: iidata(:,:)
real(8)::z(size(iidata,1),size(iidata,2)-1)
real(8)::iicoeffs(size(iidata,2)-1)
integer:: ncoeffsa,flag1,i

ncoeffsa=size(iidata,2)-1

print*, 'this is ncoeffsa', ncoeffsa
print*, 'this is aaiadata1', iidata(1,:)
print*, 'this is size', size(iidata,2)-1
print*, 'this is aaiadata2', iidata(1,2:(ncoeffsa+1))
print*, 'this is aaiadata2', iidata(143345,2:(ncoeffsa+1))

print*, 'dimz 1', size(z,1)
print*, 'dimz 2', size(z,2)
print*, 'dimiidata 1', size(iidata,1)
print*, 'dimiidata 2', size(iidata,2)

! segmentation fault occurs if I uncomment below
! and pass N x 12 array. If I pass N x 1 array
! I do not get segmentation fault.
!z(:,:)=iidata(:,2:(ncoeffsa+1))
end subroutine iireg

我用以下

之类的东西来调用该子程序
print*, 'stempp', stempp
print*, 'siidata outside', siidata(1,:)
print*, 'siidata 1 dim', size(siidata,2)-1
print*, 'siidata 2 dim', size(siidata,1)
siidata = siidata*0
stempp = stempp*0

call iireg2(siidata,stempp)

在使用此子程序之前,我打印并确保所有尺寸都正确。我现在也用零替换矩阵的所有条目。所有尺寸和尺寸都匹配。变量类型也是正确的。如果我传递的维度为N x 1(N大约为10,000),则该函数可以成功运行。然而,当我传递恰好是N x 12的东西时,我得到了分段错误。

1 个答案:

答案 0 :(得分:2)

您是否尝试过-heap-arrays编译器选项?本文列出了分段错误的可能原因: https://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors