anchor.diff:    integer, allocatable :: indirkp(:)
     integer, allocatable :: iwkp(:),linkq(:,:), sy(:,:,:)
     integer :: nqptt,nsymcryst,isym,lspl,nerr
  -
  -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  -  real(8):: v1(3),v2(3),s(3,3),t2
  -  real(8),external::r3taxi
   #endif
     ! external functions
     complex(8) gauntyry
  
positive.code:      allocate(ikmapnr(0:ngridk(1)-1,0:ngridk(2)-1,0:ngridk(3)-1))
       ! generate the non-reduced k-point set
       call genppts(.false.,ngridk,vkloff,nkptnr,ikmapnr,ivknr,vklnr,vkcnr,wkptnr)
  #ifdef TETRA
       if (tetra) then
          if ((task.eq.121).or.(task.eq.122).or.((task>=300).and.(task<=498))&
               .and.(task/=301)) then     
          ! ***
  !!$        call genkqtet(nsymcryst,sy,omega,bvec,(/0.0,0.0,0.0/),ngridk,nkptnr,&
  !!$             nkpt,vkloff,ivk,ivknr,ikmap,ikmapnr,wkpt,tvol,tnodes,link)
  !!$           call kqgen(bvec,ngridk,ikloff,dkloff,nkpt,ivk,ivq,dvk,dvq,kqid, &
  !!$                ntet,tnodes,wtet,linkq,tvol)
             deallocate(sy)
          end if
       end if
  
       if (task.eq.498) then!***************************
          write(*,*) 'writing out link...'
          open(1234,file='link.out',action='write',status='replace')
          write(1234,'(2i8)') (i1,link(i1,1),i1=1,6*nkpt)
          close(1234)
  
          write(*,*) 'writing out wtet_kqgen...'
          open(1234,file='wtet_kqgen.out',action='write',status='replace')
          write(1234,'(2i8)') (i1,wtet(i1),i1=1,6*nkpt)
          close(1234)
  
          write(*,*) 'writing out tnodes...'
          open(1234,file='tnodes.out',action='write',status='replace')
          write(1234,'(3i8,3i6)') ((i1,i2,tnodes(i1,i2),i2=1,6*nkpt),i1=1,4)
          close(1234)
          write(*,*) 'writing out tnodes2...'
          open(1234,file='tnodes2.out',action='write',status='replace')
          write(1234,'(3i8,3i6)') ((i1,i2,tnodes(i1,i2),i1=1,4),i2=1,6*nkpt)
  !!$        write(1234,'(3i8,3i6)') ((i1,i2,tnodes(i1,i2),&
  !!$             ivkt(1,tnodes(i1,i2)),ivkt(2,tnodes(i1,i2)),ivkt(3,tnodes(i1,i2)),&
  !!$             i1=1,4),i2=1,6*nkpt)
          close(1234)
       endif!********************************************
  
  !!$     write(*,*) 'writing out ivk...'
  !!$     open(1234,file='ivk.out',action='write',status='replace')
  !!$     write(1234,'(i8,3i6)') (i1,ivkt(1,i1),ivkt(2,i1),ivkt(3,i1),i1=1,nkpt)
  !!$     close(1234)
  
  !!$write(*,*) 'writing out k-points from genppts...'
  !!$open(1234,file='kpoints_genppts.out',action='write',status='replace')
  !!$write(1234,'(i8,4g18.10)') (ik,vklt(:,ik),wkptt(ik),ik=1,nkptt)
  !!$close(1234)
  !!$
  !!$write(*,*) 'writing out k-points from kgen...'
  !!$open(1234,file='kpoints_kgen.out',action='write',status='replace')
  !!$write(1234,'(i8,4g18.10)') (ik,vkl(:,ik),wkpt(ik),ik=1,nkpt)
  !!$close(1234)
  
  
  #endif
    end if ! if ((task.eq.20).or.(task.eq.21))
  
    !---------------------!
  
negative.code:         allocate(iwkp(ngridk(1)*ngridk(2)*ngridk(3)))
          allocate(wtet(1:ngridk(1)*ngridk(2)*ngridk(3)*6))
          allocate(tnodes(1:4,1:ngridk(1)*ngridk(2)*ngridk(3)*6))
          if (nsymcrys.gt.48) then
             write(*,*) 'Error(init1): number of crystal symmetries > 48'
             write(*,*) ' does not work with k-point generation for'
  