BLASとLAPACKがFortranでどのように動作しているかを理解しようとしているので、行列を生成して反転するコードを作った。LAPACKとBLASサブルーチンへの未定義の参照
は、ここで私が呼んでいるファイル内の行列Aがあるコード
program test
Implicit none
external ZGETRF
external ZGETRI
integer ::M
complex*16,allocatable,dimension(:,:)::A
complex*16,allocatable,dimension(:)::WORK
integer,allocatable,dimension(:)::IPIV
integer i,j,info,error
Print*, 'Enter size of the matrix'
Read*, M
Print*, 'Enter file of the matrix'
READ(*,*), A
OPEN(UNIT=10,FILE = '(/A/)' ,STATUS='OLD',ACTION='READ')
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 ZGETRF(M,M,A,M,IPIV,info)
if(info .eq. 0) then
write(*,*)"succeded"
else
write(*,*)"failed"
end if
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
close (10)
end program test
だ、とも私は行列(M)の大きさを言います。私はのgfortranでそれらをcopileときに私は私が正しい方法ライブラリで呼んでいる場合ので、私は知りませんがインストールBLASとLAPACKをインストールしているこれらのメッセージ
/tmp/ccVkb1zY.o: In function
MAIN__': test.f03:(.text+0x751): undefined reference to
zgetrf_' test.f03:(.text+0x85d): undefined reference to `zgetri_' collect2: error: ld returned 1 exit status
を取得します。
提案がありますか?
次のコンパイル・コマンドを与えることができますか? – ztik
いいえ、できませんでした。コンパイルしようとするとエラーが発生します – Daniel
[gfortran LAPACKの "未定義参照"エラー(https://stackoverflow.com/questions/20669410/gfortran-lapack-undefined-reference-error)の可能な複製 –