30 character(len=100):: name
31 logical LookForFilename, LookForinvDim
34 character(len=100) :: filename, output
38 integer*4 sizeAm, sizeAn
40 character(len=20) sizeInv_string
41 character(len=8) out_status
44 integer*4,
allocatable :: ia(:), ja(:)
46 COMPLEX*16,
ALLOCATABLE :: a(:)
48 REAL*8,
ALLOCATABLE :: a(:)
52 COMPLEX*16,
allocatable :: invA(:,:)
54 real*8,
allocatable :: invA(:,:)
68 lookforfilename = .false.
69 lookforinvdim = .false.
70 lookforoutput = .false.
75 narg=command_argument_count()
80 call get_command_argument(cptarg,name)
81 select case(adjustl(name))
83 write(0,*)
"This is program calculates a " , &
84 "partial inverse of a real valued sparse matirix. Usage: ./MatrixIO " 85 "--filename FILENAME --invDim INTEGER --Output FILENAME" 87 case(
"--filename",
"-F",
"--Filename")
88 lookforfilename = .true.
89 case(
"--output",
"-o",
"--Output")
90 lookforoutput = .true.
92 lookforinvdim = .true.
94 if (lookforfilename)
then 95 filename=adjustl(name)
96 lookforfilename = .false.
97 elseif (lookforoutput)
then 99 lookforoutput = .false.
100 elseif (lookforinvdim)
then 101 sizeinv_string = trim(adjustl(name))
102 READ( sizeinv_string, * ) sizeinv
103 lookforinvdim = .false.
105 write(0,*)
"Option ",adjustl(name),
"unknown" 111 if (output.eq.
'')
then 116 write(0,*)
'Input file name:', trim(filename)
117 write(0,*)
'Output file name:', trim(output)
121 inquire(file=trim(filename),exist=fileexist)
122 if(.not.fileexist)
then 123 write(0,*)
"file ",trim(filename),
" not found!" 128 OPEN(unit=6, file=trim(filename),status=
'OLD',form=
'UNFORMATTED')
130 READ(6,end=999,err=1000) sizean
131 READ(6,end=999,err=1000) nonzerosa
133 allocate(ia(sizean+1))
134 allocate(ja(nonzerosa))
135 allocate(a(nonzerosa))
137 READ(6,end=999,err=1000) ia(:)
138 READ(6,end=999,err=1000) ja(:)
139 READ(6,end=999,err=1000) a(:)
147 write(0,*)
'Size of the partial inverse:', sizeinv
148 write(0,*)
'The size of the input MATRIX:', sizean
149 write(0,*)
'Nonzeros in the input matrix:', nonzerosa
150 write(0,*)
'The input MATRIX:' 153 if (j >= ia(i+1))
then 157 if (j < ia(i+1))
then 168 ALLOCATE(inva(sizeinv, sizeinv))
179 write(0,*)
'row', i,
'col', j,
' element of A = ', inva(i,j)
187 if (
allocated(inva) )
then 194 999
write(*,
'(/"End-of-file when i = ",I5)') i
197 1000
write(*,
'(/"ERROR reading when i = ",I5)') i
Module to calculate the partial inverse of a real/complex sparse matrix via the PARDISO libraries...
subroutine dgetpartialinv(sizeA, nonzerosA, a, ia, ja, sizeInv, invA, error)
Get the partial inverse of double valued real matrices.