我不能在 Linux 环境下使用 pgf90 fortran 编译器两次调用同一个子程序。第一次调用子程序是可以的,但第二次调用它,它给出了分段错误。有人可以提出一些建议,我的代码有什么问题,举个简单的例子
PS 与 gfortran 没关系,即使我在 intel visual fortran 上尝试过,也没关系
program main
use module_Append_1DI
implicit none
integer, allocatable:: Arr(:)
integer::Brr(2)
Brr=[3, 4]
call Append_1DI(Arr,Brr)
write(*,*)Arr
call Append_1DI(Arr,Brr)
write(*,*)Arr
end program main
module module_Append_1DI
contains
subroutine Append_1DI(A,B)
implicit none
!================================================
integer, allocatable, intent(inout)::A(:)
integer, intent(in)::B(:)
integer, allocatable::temp(:)
integer::sizeA,sizeB,sizeN
!================================================
sizeA=size(A); sizeB=size(B); sizeN=sizeA+sizeB
allocate(temp(sizeN)); temp(1:sizeA)=A
call move_alloc(from=temp,to=A)
A(sizeA+1:sizeN)=B
end subroutine Append_1DI
end module module_Append_1DI