我讀過這裏,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