4

複素行列の逆行列を計算したい。lapack には代数計算に関連する多くのルーチンが含まれているので、サブルーチン ZGETRI を見つけました。予期せず、次のコードを「ifort -o out -heap-arrays test.f90 -mkl」でコンパイルし、ファイル「out」を実行した後、エラーが発生しました

" glibc が検出されました./out:free(): 無効なポインター: 0x00007fee68f76010***"

その後にメモリマップが続き、最後に「中止(コアダンプ)」されます。これは私にとって非常に奇妙で、どこが間違っているのかわかりません。ところで、コンパイル時ではなく実行時にエラーが発生した場合、どこからエラーが発生したかを検出する方法はありますか?

program test
Implicit none
integer,parameter::M=300   
complex*16,allocatable,dimension(:,:)::A
complex*16,allocatable,dimension(:)::WORK
integer,allocatable,dimension(:)::IPIV
integer i,j,info,error

allocate(A(M,M),WORK(M),IPIV(M),stat=error)
if (error.ne.0)then
  print *,"error:not enough memory"
  stop
end if

!definition of the test matrix A
 do i=1,M
   do j=1,M
      if(j.eq.i)then
         A(i,j)=(1,0)
      else 
         A(i,j)=0
      end if
   end do
 end do  

call ZGETRI(M,A,M,IPIV,WORK,M,info)
if(info .eq. 0) then
  write(*,*)"succeded"
else
 write(*,*)"failed"
end if
deallocate(A,IPIV,WORK,stat=error)
if (error.ne.0)then
  print *,"error:fail to release"
  stop
end if      
end 
4

1 に答える 1