【发布时间】:2013-05-08 02:37:02
【问题描述】:
我在这里读到 move_alloc 从 gfortran 4.2 开始工作。我在我的 ubuntu 12.04 中安装了 gfortran 4.6,但 move_alloc 不起作用! move_alloc 在一个运行 10 次的循环中使用了五次。 使用 gfrotran 编译(没有任何错误或警告)后,程序只运行循环的一步(一些打印以验证任何错误)并显示“分段错误(已记录内核图像)”。但是,当使用 ifort 时,程序运行并正常工作。 我也尝试在 CentOS 中使用 gfortran 4.4.6。 两台计算机都是 x86_64。
其他重要信息:这段代码在一个子程序中,在一个模块内,一旦我以前不知道 move_alloc 分配的向量的大小。所有这些向量都带有子程序中的属性意图(out)。 xray_all、yray_all 和 elem_all 是双精度,另一个是整数。 main 和 module 位于不同的文件中。 这是我使用 move_alloc 的一段代码:
program main
double precision,allocatable,dimension(:)::xrayall,yrayall
(...)other allocatable variables
call yyyy(....,ray_indent,xray_all,...)
end program main
module xxxx
subroutine yyyy
do j=1,10
<lots of calculation>
allocate( vec_aux( 1:(i+size(ray_indent) ) ) )
vec_aux(1:size(ray_indent))=ray_indent
vec_aux(size(ray_indent)+1:)=j
call MOVE_ALLOC(vec_aux,ray_indent)
allocate( vec_auxreal( 1:(i+size(xray_all) ) ) )
vec_auxreal(1:size(xray_all))=xray_all
vec_auxreal(size(xray_all)+1:)=xray
call MOVE_ALLOC(vec_auxreal,xray_all)
allocate( vec_auxreal( 1:(i+size(yray_all) ) ) )
vec_auxreal(1:size(yray_all))=yray_all
vec_auxreal(size(yray_all)+1:)=yray
call MOVE_ALLOC(vec_auxreal,yray_all)
elemsize=count(icol/=0);
allocate( vec_auxreal( 1:(elemsize+size(elem_all) ) ) )
vec_auxreal(1:size(elem_all))=elem_all
vec_auxreal(size(elem_all)+1:)=elem(1:elemsize)
call MOVE_ALLOC(vec_auxreal,elem_all)
allocate( vec_aux( 1:(elemsize+size(icol_all) ) ) )
vec_aux(1:size(icol_all))=icol_all
vec_aux(size(icol_all)+1:)=icol(1:elemsize)
call MOVE_ALLOC(vec_aux,icol_all)
allocate( vec_aux( 1:(elemsize+size(irow_all) ) ) )
vec_aux(1:size(irow_all))=irow_all
vec_aux(size(irow_all)+1:)=j+control !
call MOVE_ALLOC(vec_aux,irow_all)
end do
end module xxxx
end subroutine yyyy
【问题讨论】:
标签: fortran gfortran dynamic-allocation intel-fortran