      subroutine generscf(orb,norb)
      !
      !sous programme non fini
      !
      use bas
      implicit real*8 (a-h,o-x,z),logical*1(y)
      parameter (maxsym=8,nfix=500)
      parameter (maxl=100)
      parameter (maxproj=10)
      dimension lll(nsym)
      character*10000 namel
      character*12 tipo(nfix)
      character*300 orb
      character*4 atom1,orb1
c      character*8 base(nfix)
c      character*8 orbi(nfix)
c      character*4 atom(100)
c      common/bas/ orbi,nbas(nfix),nbast(0:nfix),natom,atom,base
      common/sym/ nsym,isym(maxsym),isymt(0:maxsym)
      double precision,dimension(:,:),allocatable :: u
      double precision,dimension(:),allocatable :: occup
c
      yw=.true.
      tipo(1:norb)=' '
      lll=0
c
      rewind 93
      namel=' '
      call LECNAM('&GSCF ',namel,93,ierr,1)
      call nameli(namel,NUMAC,'NUMAC',4)
c
      allocate(u(norb,norb))
      allocate(occup(norb))
c
c-------------------------------------
c     lecture des orbitales de liaison
c-------------------------------------
c
      il=0
      do
         read(93,'(a)',end=3) orb
         orb=adjustl(orb)
         long=len_trim(orb)
         call suppdb(orb,long)
         orb=adjustl(orb)
         long=len_trim(orb)
         call ligne_suite(orb,orb1,long,long1)
         call maj(orb,long)
         call versionm(molcas,orb)
         long=len_trim(orb)
         if(yw)print*,'orb lue ',orb(1:long)
         if(orb(1:3).eq.'FIN') exit
         il=il+1
c        label
         ll=index(orb,' ')-1
         tipo(il)(1:ll)=orb(1:ll)
         print*,'tipo',tipo(il)
c        atome
         orb(1:long-ll-2)=orb(ll+2:long)
         long=len_trim(orb)
         do
 1          continue
            atom1=' '
            ll=index(orb,' ')-1
            atom1(1:ll)=orb(1:ll)
            print*,'atom1',atom1
c           orbitales et coefs
            orb(1:long-ll-2)=orb(ll+2:long)
            long=len_trim(orb)
            do
c              orbitale
               orb1=' '
               ll=index(orb,'(')-1
               orb1=' '
               orb1(1:ll)=orb(1:ll)
               orbi(il)=' '
               orbi(il)(1:4)=atom1
               orbi(il)(5:ll+4)=orb1(1:ll)
               print*,'il,orbi',il,orbi(il)
               orb(1:long-ll-1)=orb(ll+1:long)
               long=len_trim(orb)
               ll=index(orb,')')-1
c              numero parmi les multi-zeta
               read(orb(2:ll),*) nz
               if(yw)print*,'nz',nz
c              coefficient
               orb(1:ll+1)=' '
               orb=adjustl(orb)
               long=len_trim(orb)
               ll=index(orb,' ')-1
               read(orb(1:ll),*) coef
               print*,'coef',coef
c              remplissage de la matrice des orbitales
               nz0=0
               norb=sum(isym(1:nsym))
               do is=1,nsym
               print*,'base',base(isymt(is-1)+1:isymt(is-1)+isym(is))
                  ii=0
                  y=.true.
                  do l=1,isym(is)
                     ii=ii+1
               print*,'orbi,base',il,ii,orbi(il),base(isymt(is-1)+ii)
                     if(orbi(il).eq.base(isymt(is-1)+ii)) then
                        nz0=nz0+1
                        if(nz.ne.nz0) cycle
                        if(y) lll(is)=lll(is)+1
                  print*,'is,l,ii,lll(is)',is,l,ii,lll(is)
                 print'('' y'',l2)',y
                        y=.false.
                        print'(a12,f10.6,10i3)','stockage',coef,
     *                  is,l,isymt(is-1)+lll(is),
     *                  isymt(is-1)+ii,isymt(is-1)
     *                ,nz,nz0
                        u(isymt(is-1)+ii,lll(is)+isymt(is-1))=coef
                        nz0=0
                        exit
                     endif
                  enddo
               enddo
c              autres OA ?
               orb(1:ll+1)=' '
               orb=adjustl(orb)
               long=len_trim(orb)
               print*,'suite?',orb(1:1)
               if(orb(1:1).eq.'(') goto 2
               if(orb(1:1).eq.':') then
                  orb(1:1)=' '
                  orb=adjustl(orb)
                  long=len_trim(orb)
                  goto 1
               endif
               cycle
            enddo
            exit
         enddo
c        occupation
 2       continue
         ll=index(orb,')')-1
         read(orb(2:ll),*) occup(il)
         print*,'occup',occup(il)
 
      enddo
 3    continue
      print*,'matrice scfgener'
      call scripto(u,norb,norb,norb,norb,base)
      stop
      return
      end
 
