subroutine constructBath() ! This subroutine identifies the bath-sites for a given UMAT/TMAT logical :: isImp(nBasis) integer :: i, j, k, l character(*), parameter :: t_r = "constructBath" nImp = 0 isImp = .false. do i = 1, nBasis ! for each orbital, check if it is in the bath, that is, check if there are ! UMAT entries for that orbital do j = i + 1, nBasis do k = 1, nBasis do l = k + 1, nBasis if (abs(get_umat_el(gtId(i), gtID(j), gtID(k), gtID(l))) > eps) then ! as we know the first orbitals have to be the ImpuritySites, ! the only information needed is their number ! auxiliary flag for checking the correct ordering isImp(i) = .true. exit end if ! No double counting if (isImp(i)) exit end do if (isImp(i)) exit end do if (isImp(i)) exit end do end do nImp = count(isImp) ! dummy array of impurity orbitals allocate(ImpuritySites(nImp)) do i = 1, nImp ImpuritySites(i) = i end do ! do a quick check if the orbital ordering is correct do i = nImp + 1, nBasis if (isImp(i)) call stop_all(t_r, & "Incorrect orbital ordering. The first orbitals have to be the ImpuritySites") end do end subroutine constructBath