|
|
|
@ -36,12 +36,13 @@ subroutine mm_zvet_read(b, info, iunit, filename)
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j,infile
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j, infile
|
|
|
|
real(psb_dpk_) :: bre, bim
|
|
|
|
|
|
|
|
character :: mmheader*15, fmt*15, object*10, type*10, sym*15,&
|
|
|
|
character :: mmheader*15, fmt*15, object*10, type*10, sym*15,&
|
|
|
|
& line*1024
|
|
|
|
& line*1024
|
|
|
|
|
|
|
|
logical :: opened
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
infile=5
|
|
|
|
infile=5
|
|
|
|
@ -52,6 +53,7 @@ subroutine mm_zvet_read(b, info, iunit, filename)
|
|
|
|
infile=99
|
|
|
|
infile=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -76,15 +78,15 @@ subroutine mm_zvet_read(b, info, iunit, filename)
|
|
|
|
|
|
|
|
|
|
|
|
read(line,fmt=*)nrow,ncol
|
|
|
|
read(line,fmt=*)nrow,ncol
|
|
|
|
|
|
|
|
|
|
|
|
if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
if ((psb_tolower(type) == 'real').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
allocate(b(nrow),stat = ircode)
|
|
|
|
allocate(b(nrow),stat = ircode)
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
do i=1, nrow
|
|
|
|
do i=1,nrow
|
|
|
|
read(infile,fmt=*,end=902) bre,bim
|
|
|
|
read(infile,fmt=*,end=902) b(i)
|
|
|
|
b(i) = cmplx(bre,bim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
|
|
end if ! read right hand sides
|
|
|
|
end if ! read right hand sides
|
|
|
|
if (infile /= 5) close(infile)
|
|
|
|
if (opened) close(infile)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
! open failed
|
|
|
|
! open failed
|
|
|
|
@ -109,12 +111,13 @@ subroutine mm_zvet2_read(b, info, iunit, filename)
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j,infile
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j, infile
|
|
|
|
real(psb_dpk_) :: bre, bim
|
|
|
|
|
|
|
|
character :: mmheader*15, fmt*15, object*10, type*10, sym*15,&
|
|
|
|
character :: mmheader*15, fmt*15, object*10, type*10, sym*15,&
|
|
|
|
& line*1024
|
|
|
|
& line*1024
|
|
|
|
|
|
|
|
logical :: opened
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
infile=5
|
|
|
|
infile=5
|
|
|
|
@ -125,6 +128,7 @@ subroutine mm_zvet2_read(b, info, iunit, filename)
|
|
|
|
infile=99
|
|
|
|
infile=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -149,18 +153,13 @@ subroutine mm_zvet2_read(b, info, iunit, filename)
|
|
|
|
|
|
|
|
|
|
|
|
read(line,fmt=*)nrow,ncol
|
|
|
|
read(line,fmt=*)nrow,ncol
|
|
|
|
|
|
|
|
|
|
|
|
if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
if ((psb_tolower(type) == 'real').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
allocate(b(nrow,ncol),stat = ircode)
|
|
|
|
allocate(b(nrow,ncol),stat = ircode)
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
do j=1, ncol
|
|
|
|
read(infile,fmt=*,end=902) ((b(i,j), i=1,nrow),j=1,ncol)
|
|
|
|
do i=1, nrow
|
|
|
|
|
|
|
|
read(infile,fmt=*,end=902) bre,bim
|
|
|
|
|
|
|
|
b(i,j) = cmplx(bre,bim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end if ! read right hand sides
|
|
|
|
end if ! read right hand sides
|
|
|
|
if (infile /= 5) close(infile)
|
|
|
|
if (opened) close(infile)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
! open failed
|
|
|
|
! open failed
|
|
|
|
@ -189,8 +188,10 @@ subroutine mm_zvet2_write(b, header, info, iunit, filename)
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j, outfile
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j, outfile
|
|
|
|
|
|
|
|
|
|
|
|
character(len=80) :: frmtv
|
|
|
|
character(len=80) :: frmtv
|
|
|
|
|
|
|
|
logical :: opened
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
outfile=6
|
|
|
|
outfile=6
|
|
|
|
@ -201,6 +202,7 @@ subroutine mm_zvet2_write(b, header, info, iunit, filename)
|
|
|
|
outfile=99
|
|
|
|
outfile=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(outfile,file=filename, err=901, action='WRITE')
|
|
|
|
open(outfile,file=filename, err=901, action='WRITE')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -210,16 +212,18 @@ subroutine mm_zvet2_write(b, header, info, iunit, filename)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
write(outfile,'(a)') '%%MatrixMarket matrix array complex general'
|
|
|
|
write(outfile,'(a)') '%%MatrixMarket matrix array real general'
|
|
|
|
write(outfile,'(a)') '% '//trim(header)
|
|
|
|
write(outfile,'(a)') '% '//trim(header)
|
|
|
|
write(outfile,'(a)') '% '
|
|
|
|
write(outfile,'(a)') '% '
|
|
|
|
nrow = size(b,1)
|
|
|
|
nrow = size(b,1)
|
|
|
|
ncol = size(b,2)
|
|
|
|
ncol = size(b,2)
|
|
|
|
write(outfile,*) nrow,ncol
|
|
|
|
write(outfile,*) nrow, ncol
|
|
|
|
|
|
|
|
|
|
|
|
write(outfile,fmt='(2(es26.18,1x))') ((b(i,j), i=1,nrow),j=1,ncol)
|
|
|
|
write(frmtv,'(a,i0,a)') '(',ncol,'(es26.18,1x))'
|
|
|
|
|
|
|
|
|
|
|
|
if (outfile /= 6) close(outfile)
|
|
|
|
write(outfile,fmt=frmtv) ((b(i,j), i=1,nrow),j=1,ncol)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opened) close(outfile)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
! open failed
|
|
|
|
! open failed
|
|
|
|
@ -241,8 +245,10 @@ subroutine mm_zvet1_write(b, header, info, iunit, filename)
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j, outfile
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, i,root, np, me, ircode, j, outfile
|
|
|
|
|
|
|
|
|
|
|
|
character(len=80) :: frmtv
|
|
|
|
character(len=80) :: frmtv
|
|
|
|
|
|
|
|
logical :: opened
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
outfile=6
|
|
|
|
outfile=6
|
|
|
|
@ -253,6 +259,7 @@ subroutine mm_zvet1_write(b, header, info, iunit, filename)
|
|
|
|
outfile=99
|
|
|
|
outfile=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(outfile,file=filename, err=901, action='WRITE')
|
|
|
|
open(outfile,file=filename, err=901, action='WRITE')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -269,13 +276,13 @@ subroutine mm_zvet1_write(b, header, info, iunit, filename)
|
|
|
|
ncol = 1
|
|
|
|
ncol = 1
|
|
|
|
write(outfile,*) nrow,ncol
|
|
|
|
write(outfile,*) nrow,ncol
|
|
|
|
|
|
|
|
|
|
|
|
write(frmtv,'(a,i0,a)') '(',2*ncol,'(es26.18,1x))'
|
|
|
|
write(frmtv,'(a,i0,a)') '(',ncol,'(es26.18,1x))'
|
|
|
|
|
|
|
|
|
|
|
|
do i=1,size(b,1)
|
|
|
|
do i=1,size(b,1)
|
|
|
|
write(outfile,frmtv) b(i)
|
|
|
|
write(outfile,frmtv) b(i)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
|
|
if (outfile /= 6) close(outfile)
|
|
|
|
if (opened) close(outfile)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
! open failed
|
|
|
|
! open failed
|
|
|
|
@ -331,9 +338,10 @@ subroutine zmm_mat_read(a, info, iunit, filename)
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, nnzero
|
|
|
|
integer(psb_ipk_) :: nrow, ncol, nnzero
|
|
|
|
integer(psb_ipk_) :: ircode, i,nzr,infile
|
|
|
|
integer(psb_ipk_) :: ircode, i,nzr,infile
|
|
|
|
type(psb_z_coo_sparse_mat), allocatable :: acoo
|
|
|
|
type(psb_z_coo_sparse_mat), allocatable :: acoo
|
|
|
|
real(psb_dpk_) :: are, aim
|
|
|
|
logical :: opened
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
infile=5
|
|
|
|
infile=5
|
|
|
|
@ -344,6 +352,7 @@ subroutine zmm_mat_read(a, info, iunit, filename)
|
|
|
|
infile=99
|
|
|
|
infile=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -369,24 +378,27 @@ subroutine zmm_mat_read(a, info, iunit, filename)
|
|
|
|
|
|
|
|
|
|
|
|
allocate(acoo, stat=ircode)
|
|
|
|
allocate(acoo, stat=ircode)
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
if ((psb_tolower(type) == 'real').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
call acoo%allocate(nrow,ncol,nnzero)
|
|
|
|
call acoo%allocate(nrow,ncol,nnzero)
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),acoo%val(i)
|
|
|
|
acoo%val(i) = cmplx(are,aim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
call acoo%set_nzeros(nnzero)
|
|
|
|
call acoo%set_nzeros(nnzero)
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
else if ((psb_tolower(type) == 'pattern').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
|
|
|
|
call acoo%allocate(nrow,ncol,nnzero)
|
|
|
|
|
|
|
|
do i=1,nnzero
|
|
|
|
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i)
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
acoo%val(:) = zone
|
|
|
|
|
|
|
|
call acoo%set_nzeros(nnzero)
|
|
|
|
|
|
|
|
|
|
|
|
else if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'symmetric')) then
|
|
|
|
else if ((psb_tolower(type) == 'real').and.(psb_tolower(sym) == 'symmetric')) then
|
|
|
|
! we are generally working with non-symmetric matrices, so
|
|
|
|
! we are generally working with non-symmetric matrices, so
|
|
|
|
! we de-symmetrize what we are about to read
|
|
|
|
! we de-symmetrize what we are about to read
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),acoo%val(i)
|
|
|
|
acoo%val(i) = cmplx(are,aim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
nzr = nnzero
|
|
|
|
nzr = nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
@ -398,37 +410,34 @@ subroutine zmm_mat_read(a, info, iunit, filename)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
else if ((psb_tolower(type) == 'pattern').and.(psb_tolower(sym) == 'symmetric')) then
|
|
|
|
|
|
|
|
|
|
|
|
else if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'hermitian')) then
|
|
|
|
|
|
|
|
! we are generally working with non-symmetric matrices, so
|
|
|
|
|
|
|
|
! we de-symmetrize what we are about to read
|
|
|
|
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),are,aim
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i)
|
|
|
|
acoo%val(i) = cmplx(are,aim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
acoo%val(:) = zone
|
|
|
|
nzr = nnzero
|
|
|
|
nzr = nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
if (acoo%ia(i) /= acoo%ja(i)) then
|
|
|
|
if (acoo%ia(i) /= acoo%ja(i)) then
|
|
|
|
nzr = nzr + 1
|
|
|
|
nzr = nzr + 1
|
|
|
|
acoo%val(nzr) = conjg(acoo%val(i))
|
|
|
|
|
|
|
|
acoo%ia(nzr) = acoo%ja(i)
|
|
|
|
acoo%ia(nzr) = acoo%ja(i)
|
|
|
|
acoo%ja(nzr) = acoo%ia(i)
|
|
|
|
acoo%ja(nzr) = acoo%ia(i)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
write(psb_err_unit,*) 'read_matrix: matrix type not yet supported'
|
|
|
|
write(psb_err_unit,*) 'read_matrix: matrix type not yet supported'
|
|
|
|
info=904
|
|
|
|
info=904
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
if (infile /= 5) close(infile)
|
|
|
|
|
|
|
|
|
|
|
|
if (info == 0) then
|
|
|
|
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opened) close(infile)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
! open failed
|
|
|
|
! open failed
|
|
|
|
@ -446,6 +455,7 @@ subroutine zmm_mat_read(a, info, iunit, filename)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end subroutine zmm_mat_read
|
|
|
|
end subroutine zmm_mat_read
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine zmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
subroutine zmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
use psb_base_mod
|
|
|
|
use psb_base_mod
|
|
|
|
implicit none
|
|
|
|
implicit none
|
|
|
|
@ -455,10 +465,11 @@ subroutine zmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
integer(psb_ipk_) :: iout
|
|
|
|
integer(psb_ipk_) :: iout
|
|
|
|
|
|
|
|
logical :: opened
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
iout=6
|
|
|
|
iout=6
|
|
|
|
@ -469,6 +480,7 @@ subroutine zmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
iout=99
|
|
|
|
iout=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(iout,file=filename, err=901, action='WRITE')
|
|
|
|
open(iout,file=filename, err=901, action='WRITE')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -480,7 +492,7 @@ subroutine zmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
|
|
|
|
|
|
|
|
call a%print(iout,head=mtitle)
|
|
|
|
call a%print(iout,head=mtitle)
|
|
|
|
|
|
|
|
|
|
|
|
if (iout /= 6) close(iout)
|
|
|
|
if (opened) close(iout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
@ -501,12 +513,13 @@ subroutine lzmm_mat_read(a, info, iunit, filename)
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
character :: mmheader*15, fmt*15, object*10, type*10, sym*15
|
|
|
|
character :: mmheader*15, fmt*15, object*10, type*10, sym*15
|
|
|
|
character(1024) :: line
|
|
|
|
character(1024) :: line
|
|
|
|
integer(psb_lpk_) :: nrow, ncol, nnzero, i,nzr
|
|
|
|
integer(psb_lpk_) :: nrow, ncol, nnzero, i, nzr
|
|
|
|
integer(psb_ipk_) :: ircode,infile
|
|
|
|
integer(psb_ipk_) :: ircode, infile
|
|
|
|
type(psb_lz_coo_sparse_mat), allocatable :: acoo
|
|
|
|
type(psb_lz_coo_sparse_mat), allocatable :: acoo
|
|
|
|
real(psb_dpk_) :: are, aim
|
|
|
|
logical :: opened
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
infile=5
|
|
|
|
infile=5
|
|
|
|
@ -517,6 +530,7 @@ subroutine lzmm_mat_read(a, info, iunit, filename)
|
|
|
|
infile=99
|
|
|
|
infile=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
open(infile,file=filename, status='OLD', err=901, action='READ')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -542,24 +556,27 @@ subroutine lzmm_mat_read(a, info, iunit, filename)
|
|
|
|
|
|
|
|
|
|
|
|
allocate(acoo, stat=ircode)
|
|
|
|
allocate(acoo, stat=ircode)
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
if (ircode /= 0) goto 993
|
|
|
|
if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
if ((psb_tolower(type) == 'real').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
call acoo%allocate(nrow,ncol,nnzero)
|
|
|
|
call acoo%allocate(nrow,ncol,nnzero)
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),acoo%val(i)
|
|
|
|
acoo%val(i) = cmplx(are,aim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
call acoo%set_nzeros(nnzero)
|
|
|
|
call acoo%set_nzeros(nnzero)
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
else if ((psb_tolower(type) == 'pattern').and.(psb_tolower(sym) == 'general')) then
|
|
|
|
|
|
|
|
call acoo%allocate(nrow,ncol,nnzero)
|
|
|
|
|
|
|
|
do i=1,nnzero
|
|
|
|
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i)
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
acoo%val(:) = zone
|
|
|
|
|
|
|
|
call acoo%set_nzeros(nnzero)
|
|
|
|
|
|
|
|
|
|
|
|
else if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'symmetric')) then
|
|
|
|
else if ((psb_tolower(type) == 'real').and.(psb_tolower(sym) == 'symmetric')) then
|
|
|
|
! we are generally working with non-symmetric matrices, so
|
|
|
|
! we are generally working with non-symmetric matrices, so
|
|
|
|
! we de-symmetrize what we are about to read
|
|
|
|
! we de-symmetrize what we are about to read
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),are,aim
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i),acoo%val(i)
|
|
|
|
acoo%val(i) = cmplx(are,aim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
nzr = nnzero
|
|
|
|
nzr = nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
@ -571,37 +588,34 @@ subroutine lzmm_mat_read(a, info, iunit, filename)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
else if ((psb_tolower(type) == 'pattern').and.(psb_tolower(sym) == 'symmetric')) then
|
|
|
|
|
|
|
|
|
|
|
|
else if ((psb_tolower(type) == 'complex').and.(psb_tolower(sym) == 'hermitian')) then
|
|
|
|
|
|
|
|
! we are generally working with non-symmetric matrices, so
|
|
|
|
|
|
|
|
! we de-symmetrize what we are about to read
|
|
|
|
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
call acoo%allocate(nrow,ncol,2*nnzero)
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
read(infile,fmt=*,end=902) acoo%ia(i),acoo%ja(i),are,aim
|
|
|
|
read(infile,fmt=*,end=902,err=905) acoo%ia(i),acoo%ja(i)
|
|
|
|
acoo%val(i) = cmplx(are,aim,kind=psb_dpk_)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
acoo%val(:) = zone
|
|
|
|
nzr = nnzero
|
|
|
|
nzr = nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
do i=1,nnzero
|
|
|
|
if (acoo%ia(i) /= acoo%ja(i)) then
|
|
|
|
if (acoo%ia(i) /= acoo%ja(i)) then
|
|
|
|
nzr = nzr + 1
|
|
|
|
nzr = nzr + 1
|
|
|
|
acoo%val(nzr) = conjg(acoo%val(i))
|
|
|
|
|
|
|
|
acoo%ia(nzr) = acoo%ja(i)
|
|
|
|
acoo%ia(nzr) = acoo%ja(i)
|
|
|
|
acoo%ja(nzr) = acoo%ia(i)
|
|
|
|
acoo%ja(nzr) = acoo%ia(i)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%set_nzeros(nzr)
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
write(psb_err_unit,*) 'read_matrix: matrix type not yet supported'
|
|
|
|
write(psb_err_unit,*) 'read_matrix: matrix type not yet supported'
|
|
|
|
info=904
|
|
|
|
info=904
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
if (infile /= 5) close(infile)
|
|
|
|
|
|
|
|
|
|
|
|
if (info == 0) then
|
|
|
|
|
|
|
|
call acoo%fix(info)
|
|
|
|
|
|
|
|
call a%mv_from(acoo)
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opened) close(infile)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
! open failed
|
|
|
|
! open failed
|
|
|
|
@ -619,6 +633,7 @@ subroutine lzmm_mat_read(a, info, iunit, filename)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end subroutine lzmm_mat_read
|
|
|
|
end subroutine lzmm_mat_read
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine lzmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
subroutine lzmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
use psb_base_mod
|
|
|
|
use psb_base_mod
|
|
|
|
implicit none
|
|
|
|
implicit none
|
|
|
|
@ -628,10 +643,10 @@ subroutine lzmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
integer(psb_ipk_), optional, intent(in) :: iunit
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
character(len=*), optional, intent(in) :: filename
|
|
|
|
integer(psb_ipk_) :: iout
|
|
|
|
integer(psb_ipk_) :: iout
|
|
|
|
|
|
|
|
logical :: opened
|
|
|
|
|
|
|
|
|
|
|
|
info = psb_success_
|
|
|
|
info = psb_success_
|
|
|
|
|
|
|
|
opened = .false.
|
|
|
|
if (present(filename)) then
|
|
|
|
if (present(filename)) then
|
|
|
|
if (filename == '-') then
|
|
|
|
if (filename == '-') then
|
|
|
|
iout=6
|
|
|
|
iout=6
|
|
|
|
@ -642,6 +657,7 @@ subroutine lzmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
iout=99
|
|
|
|
iout=99
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
open(iout,file=filename, err=901, action='WRITE')
|
|
|
|
open(iout,file=filename, err=901, action='WRITE')
|
|
|
|
|
|
|
|
opened = .true.
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (present(iunit)) then
|
|
|
|
if (present(iunit)) then
|
|
|
|
@ -653,7 +669,7 @@ subroutine lzmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
|
|
|
|
|
|
|
|
call a%print(iout,head=mtitle)
|
|
|
|
call a%print(iout,head=mtitle)
|
|
|
|
|
|
|
|
|
|
|
|
if (iout /= 6) close(iout)
|
|
|
|
if (opened) close(iout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
@ -663,4 +679,3 @@ subroutine lzmm_mat_write(a,mtitle,info,iunit,filename)
|
|
|
|
write(psb_err_unit,*) 'Error while opening ',filename
|
|
|
|
write(psb_err_unit,*) 'Error while opening ',filename
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end subroutine lzmm_mat_write
|
|
|
|
end subroutine lzmm_mat_write
|
|
|
|
|
|
|
|
|
|
|
|
|