      SUBROUTINE stover(i,j,a)
      parameter(maxsym=8,maxorb=500,maxorbcas=16)
      parameter(ngru3=2048)
      IMPLICIT REAL*8(A-H,O-X,Z),logical*1(y)
c
c    |-*-*-*-*-*-*-*-|-*-*-*-*-*-*-*-|-*-*-*-*-*-*-*-|-*-*-*-*-*-*-*-|
c    |               |               |               | |
c
      common/dim/ iadri
      common/ver3/ itab(ngru3),jtab(ngru3),d(ngru3)
      real*4 d
      COMMON/VER2/nelem
      common /det/ndet,mdet(50)
      common/test/itest(50)
      common/pr/nprint,mprint(10)
      yw=.false.
      yw1=.false.
c      yw1=i.eq.8389.or.j.eq.8389
      if(itest(5).eq.1) then
         if(itest(6).eq.0) return
      endif
c      if(imat.eq.0) return
      nelem=nelem+1
      if(nelem.gt.ngru3) then
         nelem=1
         write(1)itab,jtab,d
      endif
      if(yw)write(6,*)'stover nelem,i,j'
     *,nelem,i,j
      if(yw1.or.mprint(3).eq.1)
     *write(6,'('' adresses numeros signes'',4i5,f10.6,i10)')
     *i,j,i,j,a,nelem
c      if(i.eq.827.and.j.eq.1271)stop
      itab(nelem)=i
      jtab(nelem)=j
      d(nelem)=a
      if(i.le.0.or.j.le.0.or.i.gt.ndet.or.j.gt.ndet) then
         write(6,*)'stover erreur i,j,ndet',i,j,ndet
         stop
      endif
      return
      end
       subroutine finver2(iadrv,ysgn)
      parameter(maxsym=8,maxorb=500,maxorbcas=16)
      parameter(ngru3=2048)
      IMPLICIT REAL*8(A-H,O-X,Z),logical*1(y)
c
c    |-*-*-*-*-*-*-*-|-*-*-*-*-*-*-*-|-*-*-*-*-*-*-*-|-*-*-*-*-*-*-*-|
c    | iadrv | |
c             ysgn
      common/dim/iadri
      common/ver3/ itab(ngru3),jtab(ngru3),d(ngru3)
      dimension iadrv(iadri),ysgn(iadri)
      real*4 d
c     COMMON/VER/IADRV(IADRI)
      COMMON/VER2/nelem
      common /det/ndet,mdet(50)
      yw=.false.
      yw1=.false.
c      write(6,*)'debut finver'
      nelem=nelem+1
      write(6,*)'finver nelem',nelem
      if(nelem.gt.ngru3) then
         nelem=1
         write(1)itab,jtab,d
      endif
      itab(ngru3)=-1
      jtab(ngru3)=nelem-1
      write(1)itab,jtab,d
      rewind 1
      rewind 87
      rewind 85
      call liry(ysgn,ndet,85)
      call lirbl(iadrv,ndet,87)
c       do k=1,ndet
c       print*,'finver2',k,iadrv(k)
c       enddo
 1    read(1) itab,jtab,d
      nm=ngru3
      if(itab(ngru3).eq.-1) nm=jtab(ngru3)
      do k=1,nm
         if(ysgn(itab(k)).and..not.ysgn(jtab(k)).or.
     *   ysgn(jtab(k)).and..not.ysgn(itab(k))) d(k)=-d(k)
         itab(k)=iadrv(itab(k))
         jtab(k)=iadrv(jtab(k))
      enddo
      write(83)itab,jtab,d
c       do k=1,2048
c       print*,k,itab(k),jtab(k),d(k)
c       enddo
      if(itab(ngru3).eq.-1) then
         close(1,status='DELETE')
         return
      endif
      goto 1
      end
