anchor.diff:        Complex (8), Allocatable :: evecfv_ (:, :, :)
   #endif
         Complex (8), Allocatable :: evecfvt (:, :)
  -      Complex (8), Allocatable :: zflm1 (:, :), zflm2 (:, :)
         Character (256) :: filetag
         Character (256), External :: outfilenamestring
     ! find the equivalent k-point number and crystal symmetry element
         Call findkpt (vpl, isym, ik)
  -  ! index to spatial rotation in lattice point group
  -      lspl = lsplsymc (isym)
     ! find the record length
   #ifdef XS
         Inquire (IoLength=Recl) vkl_, nmatmax_, nstfv_, nspnfv_
  
positive.code: !   \end{tabular}\newline\newline
  !
  ! !REVISION HISTORY:
  !   Documentation added, Dec 2009 (S. Sagmeister)
  !EOP
  !BOC
        Implicit None
    ! arguments
        Real (8), Intent (In) :: vpl (3)
        Real (8), Intent (In) :: vgpl (3, ngkmax)
        Complex (8), Intent (Out) :: evecfv (nmatmax, nstfv, nspnfv)
    ! local variables
        Logical :: exist
        Integer :: isym, lspl, ilo, l, m, lm, koffset
        Integer :: ik, igp, igk, ig, i, ilspl
        Integer :: is, ia, ja, ias, jas
        Integer :: recl, nmatmax_, nstfv_, nspnfv_
        Real (8) :: vkl_ (3), v (3), t1
        Real (8) :: si (3, 3), sc (3, 3)
        Complex (8) zt1
    ! allocatable arrays
  #ifdef XS
  
negative.code:       t1 = Abs (vpl(1)-vkl(1, ik)) + Abs (vpl(2)-vkl(2, ik)) + Abs &
       & (vpl(3)-vkl(3, ik))
        If (t1 .Lt. input%structure%epslat) Return
        allocate(evecfvt(nmatmax,nstfv))
        ! index to spatial rotation in lattice point group
        lspl=lsplsymc(isym)
  ! the inverse of the spatial symmetry rotates k into p
        ilspl = isymlat (lspl)
        si(:,:)=dble(symlat(:,:,ilspl))
  !-----------------------------------------------!
  !     translate and rotate APW coefficients     !
  !-----------------------------------------------!
        do ispn=1,nspnfv
          do igk=1,ngk(ispn,ik)
            ig=igkig(igk,ispn,ik)
            v(:)=dble(ivg(:,ig))
            t1=-twopi*dot_product(v(:),vtlsymc(:,isym))
            zt1=cmplx(cos(t1),sin(t1),8)
            evecfvt(igk,:)=zt1*evecfv(igk,:,ispn)
          end do
  ! inverse rotation used because transformation is passive
          do igk=1,ngk(ispn,ik)
            call r3mtv(si,vgkl(:,igk,ispn,ik),v)
            do igp=1,ngk(ispn,ik)
              t1=abs(v(1)-vgpl(1,igp,ispn)) &
                +abs(v(2)-vgpl(2,igp,ispn)) &
                +abs(v(3)-vgpl(3,igp,ispn))
              if (t1.lt.input%structure%epslat) then
                evecfv(igp,:,ispn)=evecfvt(igk,:)
                goto 10
              end if
            end do
        10 continue
          end do
        end do
  !---------------------------------------------------------!
  !     translate and rotate local-orbital coefficients     !
  !---------------------------------------------------------!
        if (nlotot.gt.0) then
  ! rotate k-point by inverse symmetry matrix
          call r3mtv(si,vkl(:,ik),v)
  ! loop over the first-variational spins
          do ispn=1,nspnfv
  ! make a copy of the local-orbital coefficients
            do i=ngk(ispn,ik)+1,nmat(ispn,ik)
              evecfvt(i,:)=evecfv(i,:,ispn)
            end do
            do is=1,nspecies
              do ia=1,natoms(is)
                ias=idxas(ia,is)
  ! equivalent atom for this symmetry
                ja=ieqatom(ia,is,isym)
                jas=idxas(ja,is)
  ! phase factor from translation
                t1=-twopi*dot_product(vkl(:,ik),input%structure%speciesarray(is)%species%atomarray(ja)%atom%coord(:))
                zt1=cmplx(cos(t1),sin(t1),8)
                t1=twopi*dot_product(v(:),input%structure%speciesarray(is)%species%atomarray(ia)%atom%coord(:))
                zt1=zt1*cmplx(cos(t1),sin(t1),8)
  ! rotate local orbitals (active transformation)
                do ilo=1,nlorb(is)
                  l=lorbl(ilo,is)
                  lm=idxlm(l,-l)
                  i=ngk(ispn,ik)+idxlo(lm,ilo,ias)
                  j=ngk(ispn,ik)+idxlo(lm,ilo,jas)
                  call rotzflm(symlatc(:,:,lspl),l,l,nstfv,nmatmax,evecfvt(j,1), &
                   evecfv(i,1,ispn))
                  evecfv(i:i+2*l,:,ispn)=zt1*evecfv(i:i+2*l,:,ispn)
                end do
              end do
            end do
          end do
        end if
        Deallocate (evecfvt)
        Return
  End Subroutine getevecfv
  