1
!{\src2tex{textfont=tt}}
2
!!****f* ABINIT/matcginv
7
!! Invert a general matrix of complex elements.
10
!! Copyright (C) 2001-2007 ABINIT group (GMR)
11
!! This file is distributed under the terms of the
12
!! GNU General Public License, see ~abinit/COPYING
13
!! or http://www.gnu.org/copyleft/gpl.txt .
16
!! lda=leading dimension of complex matrix a
17
!! n=size of complex matrix a
18
!! a=matrix of complex elements
20
!! a=inverse of a input matrix
22
!! a(lda,n)= array of complex elements, input, inverted at output
29
!! cbgmdi,cbgmlu,cgeicd,cgetrf,cgetri,leave_new,wrtout
33
#if defined HAVE_CONFIG_H
37
subroutine matcginv(a,lda,n)
41
!This section has been created automatically by the script Abilint (TD). Do not modify these by hand.
42
#ifdef HAVE_FORTRAN_INTERFACES
43
use interfaces_01manage_mpi
45
!End of the abilint section
49
!Arguments ------------------------------------
51
integer,intent(in) :: lda,n
53
complex,intent(inout) :: a(lda,n)
55
!Local variables-------------------------------
57
integer :: ierr,istat,nwork
58
character(len=500) :: message
61
complex,allocatable :: work(:)
63
#if defined HAVE_IBM_ESSL_OLD
71
! *************************************************************************
73
!DEC$ ATTRIBUTES ALIAS:'CGETRI' :: cgetri
74
!DEC$ ATTRIBUTES ALIAS:'CGETRF' :: cgetrf
77
#if defined HAVE_IBM_ESSL_OLD
85
#if defined HAVE_IBM_ESSL_OLD
87
call cgeicd(a,lda,n,0,rcond,det,work,nwork)
88
if(abs(rcond)==zero) then
89
write(message, '(10a)' ) ch10,&
90
& ' matcginv : BUG -',ch10,&
91
& ' The matrix that has been passed in argument of this subroutine',ch10,&
92
& ' is probably either singular or nearly singular.',ch10,&
93
& ' The ESSL routine cgeicd failed.',ch10,&
94
& ' Action : Contact ABINIT group '
95
call wrtout(6,message,'COLL')
96
call leave_new('COLL')
99
#elif defined HAVE_NEC_ASL
101
call cbgmlu(a,lda,n,ipvt,ierr)
103
write(message, '(10a)' ) ch10,&
104
& ' matcginv : BUG -',ch10,&
105
& ' The matrix that has been passed in argument of this subroutine',ch10,&
106
& ' is probably either singular or nearly singular.',ch10,&
107
& ' The ASL routine cbgmlu failed.',ch10,&
108
& ' Action : Contact ABINIT group '
109
call wrtout(6,message,'COLL')
110
call leave_new('COLL')
112
call cbgmdi(a,lda,n,ipvt,cdet,det,-1,work,ierr)
114
write(message, '(10a)' ) ch10,&
115
& ' matcginv : BUG -',ch10,&
116
& ' The matrix that has been passed in argument of this subroutine',ch10,&
117
& ' is probably either singular or nearly singular.',ch10,&
118
& ' The ASL routine dbgmdi failed.',ch10,&
119
& ' Action : Contact ABINIT group '
120
call wrtout(6,message,'COLL')
121
call leave_new('COLL')
126
call cgetrf(n,n,a,lda,ipvt,ierr)
128
write(message, '(10a)' ) ch10,&
129
& ' matcginv : BUG -',ch10,&
130
& ' The matrix that has been passed in argument of this subroutine',ch10,&
131
& ' is probably either singular or nearly singular.',ch10,&
132
& ' The LAPACK routine cgetrf failed.',ch10,&
133
& ' Action : Contact ABINIT group '
134
call wrtout(6,message,'COLL')
135
call leave_new('COLL')
137
call cgetri(n,a,n,ipvt,work,n,ierr)
139
write(message, '(10a)' ) ch10,&
140
& ' matcginv : BUG -',ch10,&
141
& ' The matrix that has been passed in argument of this subroutine',ch10,&
142
& ' is probably either singular or nearly singular.',ch10,&
143
& ' The LAPACK routine cgetri failed.',ch10,&
144
& ' Action : Contact ABINIT group '
145
call wrtout(6,message,'COLL')
146
call leave_new('COLL')
155
end subroutine matcginv