
     Format_KSS

     The format of the _KSS file, produced by a non-zero nbandkss value.
     (XG 20040210 : Is this file up-to-date ???)

     Copyright (C) 2000-2007 ABINIT group (MT,XG).
     
     A non-zero nbandkss value calls the routine outkss.f, at the
     and a the self-consistent cycles.
     In this routine, the Hamiltonian is first constructed 
     in the basis of G-vectors, then completely diagonalized. 
     The eigenvectors and different informations are then dumped
     in a file abo_STO .
     They can be used as input for a GW computation, using the code
     of M. Torrent .
     Here is the format of this abo_STO file.

     ========================================


 write(unitgw) title1(1:80)     ! character*80
 write(unitgw) title2(1:80)     ! character*80
 write(unitgw) (flag(i),i=1,16) ! 16*integer
                                ! Flag(1): 1=unformatted, 0=formatted
                                !          (here, unformatted)
                                ! Flag(2): DFT-code identifier
                                !          (here, Abinit=2)
                                ! Flag(3..16): unused
 write(unitgw) rprimd
 write(unitgw) nsym2            ! integer</tt></b>
 write(unitgw) (((symrel2(i,j,k),i=1,3),j=1,3),k=1,nsym2)
                                ! nsym2: Nb of syms without inversion
                                ! symrel2: symetries without inversion
 write(unitgw) npwsto,ishm      ! 2*integer
 write(unitgw) ((gbig(i,ig),i=1,3),ig=1,npwsto),(shlim(in),in=1,ishm)
                                ! npwkss: Nb of components of wf to be stored
                                ! (ie : nb of g-vectors to be stored)
                                ! a 'big' set of g-vectors containing all
                                ! g's for all k-points (in other words, the
                                ! union of all set of g-vectors used in Abinit
                                ! The vectors are stored by shells (in
                                ! order of increasing magnitude).
                                ! ishm: Nb of shells of g-vectors
                                ! shlim: indice of the last g-vector of a shell
 write(unitgw) nkpt
 write(unitgw) ((kpt(i,ikpt),i=1,3),ikpt=1,nkpt)
 write(unitgw) nbandkss
 write(unitgw) fermie
 do isppol=1,nsppol
  do ikpt=1,nkpt
   write(unitgw) (eigval(ib),ib=1,nbandkss)
   write(unitgw) (occ_k(ib),ib=1,nbandkss)
   do ib=1,nbandkss
    write(unitgw)(eigvec(1,ig,ib),eigvec(2,ig,ib),ig=1,npwkss)
   enddo
  enddo
 enddo

