213 & ( comm, ido, bmat, n, which, nev, np, tol, resid, mode, iupd,
214 & ishift, mxiter, v, ldv, h, ldh, ritz, bounds,
215 & q, ldq, workl, ipntr, workd, info, verbose, usrchk, unconv )
237 character bmat*1, which*2
238 integer ido, info, ishift, iupd, ldh, ldq, ldv, mxiter,
240 integer verbose, usrchk, unconv
250 & bounds(nev+np), h(ldh,2), q(ldq,nev+np), resid(n),
251 & ritz(nev+np), v(ldv,nev+np), workd(3*n),
260 parameter(one = 1.0, zero = 0.0)
267 logical cnorm, getv0, initv, update, ushift
269 integer ierr, iter, j, kplusp, msglvl, nconv, nevbef, nev0,
270 & np0, nptemp, nevd2, nevm2, kp(3)
273 save cnorm, getv0, initv, update, ushift,
274 & iter, kplusp, msglvl, nconv, nev0, np0,
275 & rnorm, eps23, cnvchk
285 external dcopy, pdgetv0, pdsaitr, dscal, dsconv,
286 & pdseigt, pdsgets, pdsapps,
287 & dsortr, pdvout, pivout, second
294 & ddot, pdnorm2, pdlamch
295 external ddot, pdnorm2, pdlamch
301 intrinsic min, abs, sqrt
321 eps23 = pdlamch(comm,
'Epsilon-Machine')
322 eps23 = eps23**(2.0/3.0)
356 if (info .ne. 0)
then
377 call pdgetv0( comm, ido, bmat, 1, initv, n, 1, v, ldv,
378 & resid, rnorm, ipntr, workd, workl, info)
380 if (ido .ne. 99) go to 9000
382 if (rnorm .eq. zero)
then
418 if (cnvchk) go to 110
424 call pdsaitr(comm, ido, bmat, n, 0, nev0, mode,
425 & resid, rnorm, v, ldv, h, ldh, ipntr,
426 & workd, workl, info)
433 if (ido .ne. 99) go to 9000
435 if (info .gt. 0)
then
461 if (verbose .gt. 0)
then
462 write(*,*)
' Iteration ',iter,
463 &
' - Number of converged eigenvalues ',nconv
466 if (msglvl .gt. 0)
then
467 call pivout(comm, logfil, 1, iter, ndigit,
468 &
'_saup2: **** Start of major iteration number ****')
470 if (msglvl .gt. 1)
then
471 call pivout(comm, logfil, 1, nev, ndigit,
472 &
'_saup2: The length of the current Lanczos factorization')
473 call pivout(comm, logfil, 1, np, ndigit,
474 &
'_saup2: Extend the Lanczos factorization by')
485 call pdsaitr(comm, ido, bmat, n, nev, np, mode,
486 & resid, rnorm, v, ldv, h, ldh, ipntr,
487 & workd, workl, info)
494 if (ido .ne. 99) go to 9000
496 if (info .gt. 0)
then
511 if (msglvl .gt. 1)
then
512 call pdvout(comm, logfil, 1, rnorm, ndigit,
513 &
'_saup2: Current B-norm of residual for factorization')
521 call pdseigt( comm, rnorm, kplusp, h, ldh, ritz, bounds,
524 if (ierr .ne. 0)
then
534 call dcopy(kplusp, ritz, 1, workl(kplusp+1), 1)
535 call dcopy(kplusp, bounds, 1, workl(2*kplusp+1), 1)
549 call pdsgets( comm, ishift, which, nev, np, ritz,
556 call dcopy(nev, bounds(np+1), 1, workl(np+1), 1)
557 if (usrchk .eq. zero)
then
558 call dsconv(nev, ritz(np+1), workl(np+1), tol, nconv)
577 if (usrchk .ne. zero)
then
582 if (msglvl .gt. 2)
then
586 call pivout(comm, logfil, 3, kp, ndigit,
587 &
'_saup2: NEV, NP, NCONV are')
588 call pdvout(comm, logfil, kplusp, ritz, ndigit,
589 &
'_saup2: The eigenvalues of H')
590 call pdvout(comm, logfil, kplusp, bounds, ndigit,
591 &
'_saup2: Ritz estimates of the current NCV Ritz values')
606 if (bounds(j) .eq. zero)
then
612 if ( (nconv .ge. nev0) .or.
613 & (iter .gt. mxiter) .or.
624 if (which .eq.
'BE')
then
636 call dsortr(wprime, .true., kplusp, ritz, bounds)
639 if ( nev .gt. 1 )
then
640 call dswap( min(nevd2,np), ritz(nevm2+1), 1,
641 & ritz( max(kplusp-nevd2+1,kplusp-np+1) ), 1)
642 call dswap( min(nevd2,np), bounds(nevm2+1), 1,
643 & bounds( max(kplusp-nevd2+1,kplusp-np+1)), 1)
657 if (which .eq.
'LM') wprime =
'SM'
658 if (which .eq.
'SM') wprime =
'LM'
659 if (which .eq.
'LA') wprime =
'SA'
660 if (which .eq.
'SA') wprime =
'LA'
662 call dsortr(wprime, .true., kplusp, ritz, bounds)
672 temp = max( eps23, abs(ritz(j)) )
673 bounds(j) = bounds(j)/temp
684 call dsortr(wprime, .true., nev0, bounds, ritz)
692 temp = max( eps23, abs(ritz(j)) )
693 bounds(j) = bounds(j)*temp
703 if (which .eq.
'BE')
then
712 call dsortr(wprime, .true., nconv, ritz, bounds)
723 call dsortr(which, .true., nconv, ritz, bounds)
734 if (msglvl .gt. 1)
then
735 call pdvout(comm, logfil, kplusp, ritz, ndigit,
736 &
'_saup2: Sorted Ritz values.')
737 call pdvout(comm, logfil, kplusp, bounds, ndigit,
738 &
'_saup2: Sorted ritz estimates.')
745 if (iter .gt. mxiter .and. nconv .lt. nev) info = 1
751 if (np .eq. 0 .and. nconv .lt. nev0) info = 2
756 else if (nconv .lt. nev .and. ishift .eq. 1)
then
765 nev = nev + min(nconv, np/2)
766 if (nev .eq. 1 .and. kplusp .ge. 6)
then
768 else if (nev .eq. 1 .and. kplusp .gt. 2)
then
779 & call pdsgets( comm, ishift, which, nev, np,
780 & ritz, bounds, workl)
784 if (msglvl .gt. 0)
then
785 call pivout(comm, logfil, 1, nconv, ndigit,
786 &
'_saup2: no. of "converged" Ritz values at this iter.')
787 if (msglvl .gt. 1)
then
790 call pivout(comm, logfil, 2, kp, ndigit,
791 &
'_saup2: NEV and NP .')
792 call pdvout(comm, logfil, nev, ritz(np+1), ndigit,
793 &
'_saup2: "wanted" Ritz values.')
794 call pdvout(comm, logfil, nev, bounds(np+1), ndigit,
795 &
'_saup2: Ritz estimates of the "wanted" values ')
799 if (ishift .eq. 0)
then
829 if (ishift .eq. 0) call dcopy(np, workl, 1, ritz, 1)
831 if (msglvl .gt. 2)
then
832 call pivout(comm, logfil, 1, np, ndigit,
833 &
'_saup2: The number of shifts to apply ')
834 call pdvout(comm, logfil, np, workl, ndigit,
835 &
'_saup2: shifts selected')
836 if (ishift .eq. 1)
then
837 call pdvout(comm, logfil, np, bounds, ndigit,
838 &
'_saup2: corresponding Ritz estimates')
850 call pdsapps( comm, n, nev, np, ritz, v, ldv, h, ldh, resid,
861 if (bmat .eq.
'G')
then
863 call dcopy(n, resid, 1, workd(n+1), 1)
873 else if (bmat .eq.
'I')
then
874 call dcopy(n, resid, 1, workd, 1)
884 if (bmat .eq.
'G')
then
886 tmvbx = tmvbx + (t3 - t2)
889 if (bmat .eq.
'G')
then
890 rnorm_buf = ddot(n, resid, 1, workd, 1)
891 call mpi_allreduce( rnorm_buf, rnorm, 1,
892 & mpi_double_precision, mpi_sum, comm, ierr )
893 rnorm = sqrt(abs(rnorm))
894 else if (bmat .eq.
'I')
then
895 rnorm = pdnorm2( comm, n, resid, 1 )
900 if (msglvl .gt. 2)
then
901 call pdvout(comm, logfil, 1, rnorm, ndigit,
902 &
'_saup2: B-norm of residual for NEV factorization')
903 call pdvout(comm, logfil, nev, h(1,2), ndigit,
904 &
'_saup2: main diagonal of compressed H matrix')
905 call pdvout(comm, logfil, nev-1, h(2,1), ndigit,
906 &
'_saup2: subdiagonal of compressed H matrix')