      double precision,dimension(:,:),allocatable :: flo,work2
      double precision,dimension(:),allocatable :: focc
      character(18),dimension(:),allocatable :: flab
      integer :: gap=2 !: factor. The tables for the norb orbitals are
!                         allocated to norb*gap, because more than norb
!                         orbitals can be stored during the calculation
      allocate(flab(norb*gap)) 

!--------------------------------------------------------
! give each Active a different name
!--------------------------------------------------------
!
!N      if(.not.loc_actives) then
!N         print*,' give each Active a different name'
         kl=0
         do k=1,norb
            if(flab(k)(1:1)=='A') then
               kl=kl+1
               ll=len_trim(flab(k))
               write(flab(k)(ll+1:ll+2),'(I2.2)') kl
            endif
         enddo
!N      endif
!
!--------------------------------------------------------
!     Create file NONORLOC
!--------------------------------------------------------
!
      open(53,status='scratch',form='unformatted')
      open(54,status='scratch',form='unformatted')
      open(55,status='scratch',form='unformatted')
      do is=1,nsym
         ndims=isym(is)
         if(ndims==0) cycle
         nn=isymt(is-1)
         write(53) flo(nn+1:nn+ndims,nn+1:nn+ndims)
         write(54) focc(nn+1:nn+ndims)
         write(55) flab(nn+1:nn+ndims)!//'    '
      enddo
      call ecriorb('* Orbitales Locales NON orthogonales (Schmudorb)',
     *trim(workdir)//'NONORLOC',nsym,isym,53,56,ifiloc=54,ifillab=55)
!
!--------------------------------------------------------
!     Create file SCH_FERMI
!--------------------------------------------------------
!
      close(94,status='delete')
      open(94,status='unknown',file=trim(workdir)//'SCH_FERMI')
      write(94,'(a,8(i4,'',''))') ' &ferm fermi=',fermi0(1:nsym)
      write(94,'(a)') ' /'
!
!--------------------------------------------------------
!     Create file containing the various fl...
!--------------------------------------------------------
!
      call crea_LoOinfo(iord)
!
!--------------------------------------------------------
!     close and delete files
!--------------------------------------------------------
!
      close(94)
      close(92,status='delete')
      close(93,status='delete')
      close(95,status='delete')
      close(96,status='delete')
      close(9,status='delete')
