18 integer,
parameter ::
dp = kind(1.0d0)
47 logical :: integration
59 character(20) :: bml_type
69 integer,
parameter :: nkey_char = 1, nkey_int = 5, nkey_re = 2, nkey_log = 2
70 character(len=*) :: filename
73 character(len=50),
parameter :: keyvector_char(nkey_char) = [character(len=100) :: &
75 character(len=100) :: valvector_char(nkey_char) = [character(len=100) :: &
78 character(len=50),
parameter :: keyvector_int(nkey_int) = [character(len=50) :: &
79 'Verbose=',
'NFirst=',
'NRefI=',
'NRefF=',
'MDim=']
80 integer :: valvector_int(nkey_int) = (/ &
83 character(len=50),
parameter :: keyvector_re(nkey_re) = [character(len=50) :: &
84 'NumthreshI=',
'NumthreshF=' ]
85 real(
dp) :: valvector_re(nkey_re) = (/&
88 character(len=50),
parameter :: keyvector_log(nkey_log) = [character(len=100) :: &
90 logical :: valvector_log(nkey_log) = (/&
94 character(len=50),
parameter :: startstop(2) = [character(len=50) :: &
98 ,keyvector_int,valvector_int,keyvector_re,valvector_re,&
99 keyvector_log,valvector_log,trim(filename),startstop)
102 if(valvector_char(1) ==
"Dense")
then
103 input%bml_type = bml_matrix_dense
104 elseif(valvector_char(1) ==
"Ellpack")
then
105 input%bml_type = bml_matrix_ellpack
106 elseif(valvector_char(1) ==
"Ellblock")
then
107 input%bml_type = bml_matrix_ellblock
111 input%verbose = valvector_int(1)
112 input%nfirst = valvector_int(2)
113 input%nrefi = valvector_int(3)
114 input%nreff = valvector_int(4)
115 input%mdim = valvector_int(5)
118 input%zsp = valvector_log(1)
119 input%integration = valvector_log(2)
122 input%numthresi = valvector_re(1)
123 input%numthresf = valvector_re(2)
134 ,zk4_bml,zk5_bml,zk6_bml,norb,bml_type,bml_element_type)
135 integer :: norb, igenz
136 character(20) :: bml_type, my_bml_element_type
137 character(20),
optional :: bml_element_type
138 type(bml_matrix_t) :: zk1_bml
139 type(bml_matrix_t) :: zk2_bml
140 type(bml_matrix_t) :: zk3_bml
141 type(bml_matrix_t) :: zk4_bml
142 type(bml_matrix_t) :: zk5_bml
143 type(bml_matrix_t) :: zk6_bml
145 if(
present(bml_element_type))
then
146 my_bml_element_type = bml_element_type
148 my_bml_element_type = bml_element_real
153 if(bml_get_n(zk1_bml).le.0)
then
154 call bml_zero_matrix(bml_type,my_bml_element_type,
dp,norb,norb,zk1_bml)
155 call bml_zero_matrix(bml_type,my_bml_element_type,
dp,norb,norb,zk2_bml)
156 call bml_zero_matrix(bml_type,my_bml_element_type,
dp,norb,norb,zk3_bml)
157 call bml_zero_matrix(bml_type,my_bml_element_type,
dp,norb,norb,zk4_bml)
158 call bml_zero_matrix(bml_type,my_bml_element_type,
dp,norb,norb,zk5_bml)
159 call bml_zero_matrix(bml_type,my_bml_element_type,
dp,norb,norb,zk6_bml)
176 real(
dp) :: err_check
177 character(len=*),
intent(in) :: bml_type
178 character(20) :: bml_element_type
179 integer :: i, j, mdim, norb
180 integer,
intent(in) :: mdimin
181 integer,
optional,
intent(in) :: verbose
183 real(
dp) :: invsqrt, threshold
184 real(
dp),
allocatable :: nono_evals(:), nonotmp(:,:), smat(:,:), umat(:,:)
185 real(
dp),
allocatable :: zmat(:,:)
186 type(bml_matrix_t) :: nonotmp_bml, saux_bml, umat_bml, umat_t_bml
187 type(bml_matrix_t) :: zmat_bml
188 type(bml_matrix_t),
intent(inout) :: smat_bml
190 if(
present(verbose))
then
192 write(*,*)
"";
write(*,*)
"In buildzdiag ..."
196 if(bml_get_precision(smat_bml) == 1 .or.&
197 &bml_get_precision(smat_bml) == 2)
then
198 bml_element_type =
"real"
199 elseif(bml_get_precision(smat_bml) == 3 .or.&
200 &bml_get_precision(smat_bml) == 4)
then
201 bml_element_type =
"complex"
204 norb = bml_get_n(smat_bml)
205 mdim = bml_get_m(smat_bml)
208 allocate(nono_evals(norb))
209 allocate(umat(norb,norb))
210 allocate(nonotmp(norb,norb))
212 if(.not. bml_allocated(zmat_bml))
then
213 call bml_zero_matrix(bml_matrix_dense,bml_element_type,
dp,norb,norb,zmat_bml)
217 call bml_zero_matrix(bml_type,bml_element_type,
dp,norb,norb,umat_bml)
218 call bml_zero_matrix(bml_type,bml_element_type,
dp,norb,norb,nonotmp_bml)
222 call bml_diagonalize(smat_bml,nono_evals,umat_bml)
224 if(
present(verbose))
then
226 write(*,*)
"Time for S diag = "//
to_string(
mls() - mls_i)//
" ms"
229 call bml_export_to_dense(umat_bml, umat)
239 if(nono_evals(i).lt.0.0_dp) stop
'matrix s has a 0 eigenvalue'
240 invsqrt = 1.0_dp/sqrt(nono_evals(i))
242 nonotmp(i,j) = umat(j,i) * invsqrt
247 call bml_import_from_dense(bml_type, nonotmp, nonotmp_bml, threshold, mdim)
250 call bml_multiply(umat_bml,nonotmp_bml,zmat_bml,1.0_dp,0.0_dp,threshold)
253 deallocate(nono_evals)
255 call bml_deallocate(umat_bml)
256 call bml_deallocate(nonotmp_bml)
273 bml_type,zk1_bml,zk2_bml,zk3_bml&
274 ,zk4_bml,zk5_bml,zk6_bml,nfirst,nrefi,nreff&
275 ,thresholdi,thresholdf,integration,verbose)
279 character(20) :: bml_type
280 integer :: kk, i, igenz, mdim
281 integer :: nfirst, norb, nref, nreff
282 integer :: nrefi, verbose
283 logical :: integration
284 real(
dp) :: sec_i, sec_ii
285 real(
dp) :: threshold, thresholdf, thresholdi
286 type(bml_matrix_t) :: smat_bml, zk1_bml, zk2_bml, zk3_bml
287 type(bml_matrix_t) :: zk4_bml, zk5_bml, zk6_bml, zmat_bml
289 norb = bml_get_n(smat_bml)
290 if(mdim<0) mdim = norb
294 if(verbose.eq.1)sec_ii=
mls()
297 if(igenz.lt.nfirst)
then
298 nref=nrefi; threshold = thresholdi
300 nref=nreff; threshold = thresholdf
303 if(verbose.eq.1)sec_i=
mls()
305 if(verbose.eq.1)
write(*,*)
"Time for prg_initial estimate "//
to_string(
mls()-sec_i)//
" ms"
307 if(verbose.eq.1)sec_i=
mls()
310 &,zk4_bml,zk5_bml,zk6_bml,igenz,norb,bml_type,threshold)
312 if(verbose.eq.1)
write(*,*)
"Time for xl scheme "//
to_string(
mls()-sec_i)//
" ms"
314 if(verbose.eq.1)sec_i=
mls()
316 if(verbose.eq.1)
write(*,*)
"Time for prg_genz_sp_ref "//
to_string(
mls()-sec_i)//
" ms"
323 if(verbose.eq.1)
write(*,*)
"Time for prg_buildZsparse "//
to_string(igenz)//
" "//
to_string(
mls()-sec_ii)//
" ms"
339 character(20) :: bml_type, bml_type_f, bml_element_type
340 integer :: i, ii, j, jj
341 integer :: k, l, mdim, norb
342 integer,
allocatable :: kk(:)
343 real(
dp) :: err_check, invsqrt, threshold, thresholdz0
344 real(
dp),
allocatable :: sitmp(:,:), smat(:,:), sthres(:,:), stmp(:,:)
345 real(
dp),
allocatable :: stmp_evals(:), utmp(:,:), zmat(:,:), ztmp(:,:)
346 type(bml_matrix_t) :: sitmp_bml, sthres_bml, stmp_bml, utmp_bml
347 type(bml_matrix_t) :: xtmp_bml, zmat_bml
348 type(bml_matrix_t),
intent(in) :: smat_bml
354 bml_type= bml_matrix_dense
356 if(bml_get_precision(smat_bml) == 1 .or.&
357 &bml_get_precision(smat_bml) == 2)
then
358 bml_element_type =
"real"
359 elseif(bml_get_precision(smat_bml) == 3 .or.&
360 &bml_get_precision(smat_bml) == 4)
then
361 bml_element_type =
"complex"
365 allocate(zmat(norb,norb))
368 allocate(sthres(norb,norb))
370 allocate(smat(norb,norb))
371 call bml_export_to_dense(smat_bml,smat)
373 call bml_zero_matrix(bml_type,bml_element_type,
dp,norb,norb,sthres_bml)
375 call bml_import_from_dense(bml_type,smat,sthres_bml,thresholdz0,mdim)
377 call bml_export_to_dense(sthres_bml,sthres)
389 if(abs(sthres(i,j)).gt.thresholdz0)
then
397 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,stmp_bml)
398 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,sitmp_bml)
399 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,utmp_bml)
400 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,xtmp_bml)
402 allocate(stmp(k,k),sitmp(k,k))
403 allocate(utmp(k,k),stmp_evals(k),ztmp(k,k))
413 stmp(l,j) = smat(kk(l),kk(j))
417 call bml_import_from_dense(bml_type, stmp, stmp_bml)
418 call bml_diagonalize(stmp_bml,stmp_evals,utmp_bml)
419 call bml_export_to_dense(utmp_bml,utmp)
422 invsqrt = 1.0_dp/sqrt(stmp_evals(j))
424 sitmp(l,j) = utmp(l,j) * invsqrt
430 call bml_import_from_dense(bml_type , utmp , utmp_bml)
431 call bml_import_from_dense(bml_type, sitmp, sitmp_bml)
432 call bml_multiply(sitmp_bml,utmp_bml,xtmp_bml,1.0_dp,0.0_dp)
433 call bml_export_to_dense(xtmp_bml,ztmp)
438 zmat(i,kk(l)) = ztmp(j,l)
443 deallocate(stmp,sitmp)
445 deallocate(stmp_evals)
447 call bml_deallocate(sitmp_bml)
448 call bml_deallocate(stmp_bml)
449 call bml_deallocate(utmp_bml)
453 call bml_zero_matrix(bml_type_f,bml_element_type,
dp,norb,norb,zmat_bml)
454 call bml_import_from_dense(bml_type_f,zmat, zmat_bml,threshold,mdim)
463 call bml_deallocate(sthres_bml)
481 character(20) :: bml_type, bml_type_f, bml_element_type
482 integer :: i, ii, j, jj
483 integer :: k, l, mdim, norb
484 integer,
allocatable :: kk(:)
485 real(
dp),
intent(in) :: threshold
486 real(
dp) :: err_check, invsqrt
487 real(
dp) :: thresholdz0
488 real(
dp),
allocatable :: sitmp(:,:), smat(:,:), sthres(:,:)
489 real(
dp),
allocatable :: stmp(:,:)
490 real(
dp),
allocatable :: stmp_evals(:), utmp(:,:)
491 real(
dp),
allocatable :: zmat(:,:), ztmp(:,:)
492 type(bml_matrix_t) :: sitmp_bml, sthres_bml, stmp_bml
493 type(bml_matrix_t) :: xtmp_bml, zmat_bml, utmp_bml
494 type(bml_matrix_t),
intent(in) :: smat_bml
501 bml_type= bml_matrix_dense
503 if(bml_get_precision(smat_bml) == 1 .or.&
504 &bml_get_precision(smat_bml) == 2)
then
505 bml_element_type =
"real"
506 elseif(bml_get_precision(smat_bml) == 3 .or.&
507 &bml_get_precision(smat_bml) == 4)
then
508 bml_element_type =
"complex"
512 allocate(zmat(norb,norb))
513 allocate(sthres(norb,norb))
515 allocate(smat(norb,norb))
516 call bml_export_to_dense(smat_bml,smat)
519 call bml_zero_matrix(bml_type,bml_element_type,
dp,norb,norb,sthres_bml)
522 call bml_import_from_dense(bml_type,smat,sthres_bml,threshold,mdim)
525 call bml_export_to_dense(sthres_bml,sthres)
542 if(abs(sthres(i,j)).gt.threshold)
then
550 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,stmp_bml)
551 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,sitmp_bml)
552 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,utmp_bml)
553 call bml_zero_matrix(bml_type,bml_element_type,
dp, k,k,xtmp_bml)
555 allocate(stmp(k,k),sitmp(k,k))
556 allocate(utmp(k,k),stmp_evals(k),ztmp(k,k))
566 stmp(l,j) = smat(kk(l),kk(j))
570 call bml_import_from_dense(bml_matrix_dense, stmp, stmp_bml)
571 call bml_diagonalize(stmp_bml,stmp_evals,utmp_bml)
572 call bml_export_to_dense(utmp_bml,utmp)
575 invsqrt = 1.0_dp/sqrt(stmp_evals(j))
577 sitmp(l,j) = utmp(l,j) * invsqrt
583 call bml_import_from_dense(bml_type, utmp, utmp_bml)
584 call bml_import_from_dense(bml_type, sitmp, sitmp_bml)
585 call bml_multiply(sitmp_bml,utmp_bml,xtmp_bml,1.0_dp,0.0_dp)
586 call bml_export_to_dense(xtmp_bml,ztmp)
592 zmat(i,kk(l)) = ztmp(j,l)
597 deallocate(stmp,sitmp)
599 deallocate(stmp_evals)
601 call bml_deallocate(sitmp_bml)
602 call bml_deallocate(stmp_bml)
603 call bml_deallocate(utmp_bml)
608 call bml_import_from_dense(bml_type_f,zmat,zmat_bml,threshold,mdim, &
609 bml_get_distribution_mode(smat_bml))
619 call bml_deallocate(sthres_bml)
634 &,zk4_bml,zk5_bml,zk6_bml,igenz,norb,bml_type&
636 integer :: igenz,norb,KK
637 character(20) :: bml_element_type
638 real(dp) :: alpha, kappa, c0, c1, c2, c3, c4, c5
639 real(dp) :: threshold
640 type(bml_matrix_t) :: zmat_bml
641 type(bml_matrix_t) :: zk1_bml,zk2_bml,zk3_bml,zk4_bml,zk5_bml,zk6_bml
642 character(20) :: bml_type
649 if(bml_get_precision(zmat_bml) == 1 .or.&
650 &bml_get_precision(zmat_bml) == 2)
then
651 bml_element_type =
"real"
652 elseif(bml_get_precision(zmat_bml) == 3 .or.&
653 &bml_get_precision(zmat_bml) == 4)
then
654 bml_element_type =
"complex"
669 call bml_zero_matrix(bml_type,bml_element_type,dp,norb ,norb,zk1_bml)
670 call bml_zero_matrix(bml_type,bml_element_type,dp,norb ,norb,zk2_bml)
671 call bml_zero_matrix(bml_type,bml_element_type,dp,norb ,norb,zk3_bml)
672 call bml_zero_matrix(bml_type,bml_element_type,dp,norb ,norb,zk4_bml)
673 call bml_zero_matrix(bml_type,bml_element_type,dp,norb ,norb,zk5_bml)
674 call bml_zero_matrix(bml_type,bml_element_type,dp,norb ,norb,zk6_bml)
676 call bml_copy(zmat_bml,zk1_bml);
call bml_copy(zmat_bml,zk2_bml);
call bml_copy(zmat_bml,zk3_bml)
677 call bml_copy(zmat_bml,zk4_bml);
call bml_copy(zmat_bml,zk5_bml);
call bml_copy(zmat_bml,zk6_bml)
683 call bml_add_deprecated(1.0_dp,zmat_bml,-1.0_dp,zk6_bml,threshold)
684 call bml_scale(kappa,zmat_bml)
685 call bml_add_deprecated(1.0_dp,zmat_bml,2.0_dp,zk6_bml,threshold)
686 call bml_add_deprecated(1.0_dp,zmat_bml,-1.0_dp,zk5_bml,threshold)
689 call bml_add_deprecated(1.0_dp,zmat_bml,c0,zk6_bml,threshold)
690 call bml_add_deprecated(1.0_dp,zmat_bml,c1,zk5_bml,threshold)
691 call bml_add_deprecated(1.0_dp,zmat_bml,c2,zk4_bml,threshold)
692 call bml_add_deprecated(1.0_dp,zmat_bml,c3,zk3_bml,threshold)
693 call bml_add_deprecated(1.0_dp,zmat_bml,c4,zk2_bml,threshold)
694 call bml_add_deprecated(1.0_dp,zmat_bml,c5,zk1_bml,threshold)
700 call bml_copy(zk2_bml,zk1_bml)
701 call bml_copy(zk3_bml,zk2_bml)
702 call bml_copy(zk4_bml,zk3_bml)
703 call bml_copy(zk5_bml,zk4_bml)
704 call bml_copy(zk6_bml,zk5_bml)
705 call bml_copy(zmat_bml,zk6_bml)
721 integer,
intent(inout) :: norb
722 integer,
intent(in) :: nref
723 real(
dp) :: err_check, sec_i
724 real(
dp),
allocatable :: smat(:,:), zmat(:,:)
725 real(
dp),
intent(in) :: threshold
726 type(bml_matrix_t) :: temp_bml
727 type(bml_matrix_t) :: temp1_bml
728 type(bml_matrix_t) :: temp2_bml
729 type(bml_matrix_t) :: idscaled_bml
730 type(bml_matrix_t) :: xmat_t_bml
731 type(bml_matrix_t),
intent(inout) :: zmat_bml
732 type(bml_matrix_t) :: aux_bml
733 type(bml_matrix_t),
intent(in) :: smat_bml
734 character(20),
intent(in) :: bml_type
735 character(20) :: bml_element_type
737 norb = bml_get_n(smat_bml)
740 if(bml_get_precision(smat_bml) == 1 .or.&
741 &bml_get_precision(smat_bml) == 2)
then
742 bml_element_type =
"real"
743 elseif(bml_get_precision(smat_bml) == 3 .or.&
744 &bml_get_precision(smat_bml) == 4)
then
745 bml_element_type =
"complex"
748 call bml_zero_matrix(bml_type,bml_element_type,
dp,norb,norb,idscaled_bml)
750 call bml_add_identity(idscaled_bml, 1.0_dp, threshold)
751 call bml_scale(1.8750_dp,idscaled_bml)
753 call bml_noinit_matrix(bml_type,bml_element_type,
dp,norb ,norb,temp_bml)
754 call bml_noinit_matrix(bml_type,bml_element_type,
dp,norb ,norb,temp2_bml)
760 call bml_transpose(zmat_bml, xmat_t_bml)
761 call bml_add_deprecated(0.50_dp,zmat_bml, 0.50_dp, xmat_t_bml,threshold)
763 call bml_multiply(smat_bml,zmat_bml,temp_bml, 1.0_dp, 0.0_dp,threshold)
765 call bml_multiply(zmat_bml,temp_bml, temp2_bml, 1.0_dp, 0.0_dp,threshold)
767 call bml_multiply(temp2_bml, temp2_bml, temp_bml, 1.0_dp, 0.0_dp,threshold)
769 call bml_scale(0.3750_dp, temp_bml)
770 call bml_scale(-1.250_dp, temp2_bml)
773 call bml_add_deprecated(1.0_dp,temp2_bml,1.0_dp, idscaled_bml,threshold)
774 call bml_add_deprecated(1.0_dp,temp_bml,1.0_dp, temp2_bml,threshold)
776 call bml_multiply(zmat_bml,temp_bml,temp2_bml, 1.0_dp, 0.0_dp,threshold)
778 call bml_copy(temp2_bml,zmat_bml)
781 call bml_deallocate(temp_bml)
782 call bml_deallocate(temp1_bml)
783 call bml_deallocate(temp2_bml)
785 write(*,*)
"Time for ref loop "//
to_string(
mls()-sec_i)//
" ms"
788 call bml_deallocate(idscaled_bml)
789 call bml_deallocate(xmat_t_bml)
To produce a matrix which is needed to orthogonalize .
subroutine, public prg_buildzsparse(smat_bml, zmat_bml, igenz, mdim, bml_type, zk1_bml, zk2_bml, zk3_bml, zk4_bml, zk5_bml, zk6_bml, nfirst, nrefi, nreff, thresholdi, thresholdf, integration, verbose)
Inverse factorization using Niklasson's algorithm.
subroutine, public prg_genz_sp_initial_zmat(smat_bml, zmat_bml, norb, mdim, bml_type_f, threshold)
Initial estimation of Z.
subroutine, public prg_buildzdiag(smat_bml, zmat_bml, threshold, mdimin, bml_type, verbose)
Usual subroutine involving diagonalization. , where = eigenvectors and = eigenvalues....
subroutine, public prg_genz_sp_ref(smat_bml, zmat_bml, nref, norb, bml_type, threshold)
Iterative refinement.
subroutine, public prg_parse_zsp(input, filename)
The parser for genz solver.
subroutine prg_genz_sp_int(zmat_bml, zk1_bml, zk2_bml, zk3_bml, zk4_bml, zk5_bml, zk6_bml, igenz, norb, bml_type, threshold)
Inverse factorization using Niklasson's algorithm.
subroutine, public prg_genz_sp_initialz0(smat_bml, zmat_bml, norb, mdim, bml_type_f, threshold)
Initial estimation of Z.
subroutine, public prg_init_zspmat(igenz, zk1_bml, zk2_bml, zk3_bml, zk4_bml, zk5_bml, zk6_bml, norb, bml_type, bml_element_type)
Initiates the matrices for the Xl integration of Z.
Some general parsing functions.
subroutine, public prg_parsing_kernel(keyvector_char, valvector_char, keyvector_int, valvector_int, keyvector_re, valvector_re, keyvector_log, valvector_log, filename, startstop)
The general parsing function. It is used to vectorize a set of "keywords" "value" pairs as included i...
Module to handle input output files for the PROGRESS lib.
Input for the genz driver. This type controlls all the variables that are needed by genz.