我读过这里,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在gfortran(4.6.3)中没有工作,但它在ifort?
其他重要信息:。这一块的代码是一个子程序,模块内部,有一次我先前不知道由move_alloc分配的向量的大小,所有这些向量都与子程序中的intent(out)属性有关,xray_all,yray_all和elem_all是双精度,另一个是整数。在不同的文件中。 以下是代码段我使用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