inivec Subroutine

public subroutine inivec(eiga, eigb, bvec_mo, xm, nocca, noccb, nvec)

Uses

  • proc~~inivec~~UsesGraph proc~inivec inivec module~precision precision proc~inivec->module~precision iso_fortran_env iso_fortran_env module~precision->iso_fortran_env

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in), dimension(:) :: eiga
real(kind=dp), intent(in), dimension(:) :: eigb
real(kind=dp), intent(out), dimension(:,:) :: bvec_mo
real(kind=dp), intent(out), dimension(:) :: xm
integer, intent(in) :: nocca
integer, intent(in) :: noccb
integer, intent(in) :: nvec

Called by

proc~~inivec~~CalledByGraph proc~inivec inivec proc~tdhf_energy tdhf_energy proc~tdhf_energy->proc~inivec proc~tdhf_mrsf_energy tdhf_mrsf_energy proc~tdhf_mrsf_energy->proc~inivec proc~tdhf_sf_energy tdhf_sf_energy proc~tdhf_sf_energy->proc~inivec proc~tdhf_energy_c tdhf_energy_C proc~tdhf_energy_c->proc~tdhf_energy proc~tdhf_mrsf_energy_c tdhf_mrsf_energy_C proc~tdhf_mrsf_energy_c->proc~tdhf_mrsf_energy proc~tdhf_sf_energy_c tdhf_sf_energy_C proc~tdhf_sf_energy_c->proc~tdhf_sf_energy

Source Code

  subroutine inivec(eiga,eigb,bvec_mo,xm, &
                    nocca,noccb,nvec)
    use precision, only: dp

    implicit none

    real(kind=dp), intent(in), dimension(:) :: eiga, eigb
    real(kind=dp), intent(out), dimension(:,:) :: bvec_mo
    real(kind=dp), intent(out), dimension(:) :: xm
    integer, intent(in) :: nocca, noccb
    integer, intent(in) :: nvec

    integer :: i, ij, j, k, nbf, mxvec

    integer :: itmp(nvec)
    real(kind=dp) :: xtmp(nvec)

    nbf = ubound(eiga, 1)
    mxvec = ubound(bvec_mo, 2)

  ! -- Set xm(xvec_dim)
    do j = noccb+1, nbf
      do i = 1, nocca
        ij = (j-noccb-1)*nocca+i
        xm(ij) = eigb(j)-eiga(i)
      end do
    end do

!   Find indices of the first `nvec` smallest values in the `xm` array
    itmp = 0 ! indices
    xtmp = huge(1.0d0) ! values

    do i = 1, ubound(xm,1)
      do j = 1, nvec
        if (xtmp(j) > xm(i)) exit
      end do
      if (j <= nvec) then
        ! new small value found, insert it into temporary arrays
        xtmp(j+1:nvec) = xtmp(j:nvec-1)
        itmp(j+1:nvec) = itmp(j:nvec-1)
        xtmp(j) = xm(i)
        itmp(j) = i
      end if
    end do

  ! -- Get initial vectors: bvec(xvec_dim,nvec)
    bvec_mo = 0.0_dp
    do k = 1, nvec
      bvec_mo(itmp(k),k) = 1.0_dp
    end do

  end subroutine inivec