31 character(len=100):: name
32 logical lookforfilename, lookforinvdim
35 character(len=100) :: filename, output
39 integer*4 sizeam, sizean
41 character(len=20) sizeinv_string
42 character(len=8) out_status
45 integer*4,
allocatable :: ia(:), ja(:)
47 COMPLEX*16,
ALLOCATABLE :: a(:)
49 real*8,
ALLOCATABLE :: a(:)
53 COMPLEX*16,
allocatable :: inva(:,:)
55 real*8,
allocatable :: inva(:,:)
69 lookforfilename = .false.
70 lookforinvdim = .false.
71 lookforoutput = .false.
76 narg=command_argument_count()
81 call get_command_argument(cptarg,name)
82 select case(adjustl(name))
84 write(0,*)
"This is program calculates a " , &
85 "partial inverse of a sparse matirix. Usage: ./MatrixIO ", &
86 "--filename FILENAME --invDim INTEGER --Output FILENAME" 88 case(
"--filename",
"-F",
"--Filename")
89 lookforfilename = .true.
90 case(
"--output",
"-o",
"--Output")
91 lookforoutput = .true.
93 lookforinvdim = .true.
95 if (lookforfilename)
then 96 filename=adjustl(name)
97 lookforfilename = .false.
98 elseif (lookforoutput)
then 100 lookforoutput = .false.
101 elseif (lookforinvdim)
then 102 sizeinv_string = trim(adjustl(name))
103 READ( sizeinv_string, * ) sizeinv
104 lookforinvdim = .false.
106 write(0,*)
"Option ",adjustl(name),
"unknown" 112 if (output.eq.
'')
then 117 write(0,*)
'Input file name:', trim(filename)
118 write(0,*)
'Output file name:', trim(output)
122 inquire(file=trim(filename),exist=fileexist)
123 if(.not.fileexist)
then 124 write(0,*)
"file ",trim(filename),
" not found!" 129 OPEN(unit=6, file=trim(filename),status=
'OLD',form=
'UNFORMATTED')
131 READ(6,end=999,err=1000) sizean
132 READ(6,end=999,err=1000) nonzerosa
134 allocate(ia(sizean+1))
135 allocate(ja(nonzerosa))
136 allocate(a(nonzerosa))
138 READ(6,end=999,err=1000) ia(:)
139 READ(6,end=999,err=1000) ja(:)
140 READ(6,end=999,err=1000) a(:)
148 write(0,*)
'Size of the partial inverse:', sizeinv
149 write(0,*)
'The size of the input MATRIX:', sizean
150 write(0,*)
'Nonzeros in the input matrix:', nonzerosa
151 write(0,*)
'The input MATRIX:' 154 if (j >= ia(i+1))
then 158 if (j < ia(i+1))
then 169 ALLOCATE(inva(sizeinv, sizeinv))
180 write(0,*)
'row', i,
'col', j,
' element of A = ', inva(i,j)
188 if (
allocated(inva) )
then 195 999
write(*,
'(/"End-of-file when i = ",I5)') i
198 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.