      subroutine predet(iadrr)
      implicit real*8(a-h,o-x,z),logical*1 (y)
      parameter(maxsym=8,maxda3=300)
      include 'maxorb.prm'
      parameter(maxorbcas=16,maxdetc=12870)
      parameter(nbcdim=14*(maxorbcas+1)*maxsym*5)
      parameter (manim=50000)
      common /dim/ iadri
c
c    |-*-*-*-*-*-*-*-|-*-*-*-*-*-*-*-|
c    |   iadrr                       |
c
      common/test/itest(100)
      dimension iesp(maxorbcas*maxdetc*2),
     *iadrr(iadri*4)
      common/opt/ihab,calcul
      character*3 calcul
      common /nin/i3333,ie3333,i1111,ie1111,i3131,ie3131
     *,i3311,ie3311,i3331,ie3331,i1113,ie1113,i0000,ie0000
     *,l3333,le3333,l1111,le1111,l3131,le3131
     *,l3311,le3311,l3331,le3331,l1113,le1113,l0000,le0000
     *,i2333,ie2333,l2333,le2333,i2000,ie2000,l2000,le2000
     *,i2233,ie2233,l2233,le2233,i1122,ie1122,l1122,le1122
     *,i2323,ie2323,l2323,le2323,i1212,ie1212,l1212,le1212
     *,i2133,ie2133,l2133,le2133,i2313,ie2313,l2313,le2313
     *,i2311,ie2311,l2311,le2311,i2131,ie2131,l2131,le2131
     *,i2111,ie2111,l2111,le2111,i2123,ie2123,l2123,le2123
     *,i2213,ie2213,l2213,le2213
     *,i211a,i211b,i211c,l211a,l211b,l211c
     *,i2221,i2223,ie2221,ie2223,l2221,l2223,le2221,le2223
     *,i2222,ie2222,l2222,le2222
      common /cs/ noac,nelac,numac(maxorbcas),itype(maxorb),is0,ms2
      common/sym/ itsym(maxorb*2),its(maxsym,maxsym),nsym
      dimension idebd(maxorb,maxorb),idebd3(maxorb,maxsym)
      common /orb/ enuc,eref,norb,noca,nocb
     *,iorb(2*maxorb),ninac,nvirt,noca0
      common/sy2/nts(maxsym),ncs(maxsym),nps(maxsym)
     *,norbs(maxsym)
      common /prep/ nca0,ncb0,ic0(maxorbcas),icamun(maxorb+maxorb)
     *,numt(maxorb),nump(maxorb),nv
     *,gener,yoc(maxorb+maxorb),yrefc(maxorbcas),yac(maxorb)
     *,ygmono,ygddci,ygddc2,ygcas,ygtous
      common/dispre/ivvvv1,ioooo2,ivovo3,ivvoo4,
     *iovvo5,ivooo6,ivoov7,ivvvc8
     *,iccvv9,icvcv10,ioocc11,iococ12
     *,icovv13,icvov14,icvoo15,icovo16
     *,icooo17,iccov18,icocv19,iccco20,icccv21,icccc22
      character*4 gener
      character*1 syspin,syspins
      common/sysp1/syspin
      character*4 hab
      common/infdav/ twcas,alam(maxda3),tau,twvec,twess,sint,sint4,sh
     *,hab,Nbtots,nvec,ngao,niter,iprec,lvec(maxda3),nfrag,ipresc,irest
     *,jrest
     *,iunit,ihprec,ihvec,ifiess,NESSAI,nf8,maxda2,bidia,ywvec,ytana
     *,yhmono,ydens,ywcas
      logical*1 bidia
      dimension nbc(nbcdim),nim2(manim)
      common /det/ndet,mdet(50),nbdet_cas
      common/gd/ melc(5),nmelc
      common/stp/stop
      common/tps/icpu(10)
      character*8 stop
      common/c66/ y66(3,3,3,3),ye66(3,3,3,3)
      yw=.false.
      yw1=.false.
      if(ygcas) return
      write(6,*)' '
      write(6,*)'============================================'
      write(6,*)'predet  generation des determinants par type'
      write(6,*)'============================================'
      kdet=0
c-----ouverture des fichers qui contiendront iadrr et idebd,ilond
      open(76,status='UNKNOWN',form='UNFORMATTED',file='CD_ADRR1')
      open(77,status='UNKNOWN',form='UNFORMATTED',file='CD_DEBL1')
      if(irest.eq.1.or.irest.eq.3) then
         read(64) mdet
         read(64) itest,y66,ye66
         if(yw1)write(6,*)'dimension des listes de determinants (irest)'
         if(yw1)write(6,'(a6,5(8i8,/,6x))')' mdet',(mdet(k),k=1,39)
         if(yw1)write(6,*)'============================================'
         return
      endif
c
c-----initialisation de iadrr puis calcul de iadrr dans gendet
c
      nmelc=5
      melc(1)=0
      melc(2)=-1
      melc(3)=1
      melc(4)=-2
      melc(5)=2
      if(ygmono) then
         nmelc=3
         melc(1)=0
         melc(2)=-1
         melc(3)=1
         goto 10
      endif
c-----determinants |....a b> |.... + ->   classes (a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,nvirt,nvirt,1,nump
     *   ,nump,1,-1,1,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |....a b> |.... + -> cpu',icpu1
         call flush(6)
      endif
c      stop
c-----determinants |....a b> |.... - ->   classes (a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,nvirt,nvirt,-1,nump
     *   ,nump,-1,-1,2,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |....a b> |.... - -> cpu',icpu1
         call flush(6)
      endif
c-----determinants |....a b> |.... + +>   classes (a,b)
      if(syspin.ne.'0') goto 2
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,nvirt,nvirt,-1,nump
     *   ,nump,1,1,3,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |....a b> |.... + +> cpu',icpu1
         call flush(6)
      endif
 2    continue
c-----determinants |i j....> | + -....>   classes (i,j)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,ninac,1,numt
     *   ,numt,1,-1,4,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j....> | + -....> cpu',icpu1
         call flush(6)
      endif
c-----determinants |i j....> | - -....>   classes (i,j)
      if(syspin.ne.'0') goto 5
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,ninac,-1,numt
     *   ,numt,-1,-1,5,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j....> | - -....> cpu',icpu1
         call flush(6)
      endif
 5    continue
c-----determinants |i j....> | + +....>   classes (i,j)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,ninac,-1,numt
     *   ,numt,1,1,6,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j....> | + +....> cpu',icpu1
         call flush(6)
      endif
 10   continue
c-----determinants |i ... b> | +.....->   classes (i,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,1,-1,7,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i ... b> | +.....-> cpu',icpu1
         call flush(6)
      endif
c-----determinants |..j a..> |...- +..>   classes (j,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      if(syspin.eq.'0')call prede2
     *(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,-1,1,8,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |..j a..> |...- +..> cpu',icpu1
         call flush(6)
      endif
      nmelc=1
      melc(1)=0
c-----determinants |i. C0 a.> | +.....+>   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      close (77)
      close (76)
      if(ye66(3,1,3,1)) goto 663
      open(77,status='UNKNOWN',form='UNFORMATTED',file='CD_DEBL9')
      open(76,status='UNKNOWN',form='UNFORMATTED',file='CD_ADRR9')
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,1,1,9,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i. C0 a.> | +.....+> cpu',icpu1
         call flush(6)
      endif
c-----determinants |i. C0 a.> | -.....->   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      if(syspin.eq.'0')call prede2
     *(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,-1,-1,10,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i. C0 a.> | -.....-> cpu',icpu1
         call flush(6)
      endif
      melc(1)=1
c-----determinants |i. C+1 a> | +.....+>   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,1,1,11,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i. C+1 a> | +.....+> cpu',icpu1
         call flush(6)
      endif
c-----determinants |i. C+1 a> | -.....->   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      if(syspin.eq.'0')call prede2
     *(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,-1,-1,12,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i. C+1 a> | -.....-> cpu',icpu1
         call flush(6)
      endif
      melc(1)=-1
c-----determinants |i C-1 a.> | +.....+>   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,1,1,13,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i C-1 a.> | +.....+> cpu',icpu1
         call flush(6)
      endif
c-----determinants |i C-1 a.> | -.....->   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      if(syspin.eq.'0')call prede2
     *(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,-1,-1,14,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i C-1 a.> | -.....-> cpu',icpu1
         call flush(6)
      endif
      close(77)
      close(76)
 663  continue
      open(77,status='UNKNOWN',form='UNFORMATTED',file='CD_DEBL15')
      open(76,status='UNKNOWN',form='UNFORMATTED',file='CD_ADRR15')
      nmelc=2
      melc(1)=0
      melc(2)=-1
      if(itest(66).eq.1) then
c        si les listes sont trop longues, on les elimine
         mmm=0
         do k=9,14
            mmm=max(mmm,mdet(k))
         enddo
         if(mmm.gt.iadri) then
            print*,'dimension liste 9/14 trop grande, on fait autrement'
            do l=9,14
c               backspace 77
c               backspace 77
c               do kk=1,mdet(l),2048
c                  backspace 76
c               enddo
               mdet(l)=0
            enddo
            itest(67)=1
         endif
      endif
      if(ygmono) goto 1
c-----determinants |i.... a b> | +...+ ->   classes (i,a,b)
      if(syspin.ne.'0') goto 30
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede3(iesp,idebd,idebd3,iadrr,
     *   nvirt,nvirt,ninac,1,nump,
     *   nump,numt,1,-1,1,15,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i.... a b> | +...+ -> cpu',icpu1
         call flush(6)
      endif
c-----determinants |c....> | ...->
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
         call prede1(iesp,idebd,iadrr,nvirt,
     *   nump,-1,16)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |c....> | ...-> cpu',icpu1
         call flush(6)
      endif
 30   continue
c-----determinants |i.... a b> | -...-.+>   classes (i,a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede3(iesp,idebd,idebd3,iadrr,
     *nvirt,nvirt,ninac,1,nump,
     *nump,numt,-1,1,-1,17,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i.... a b> | -...-.+> cpu',icpu1
         call flush(6)
      endif
c-----determinants |c....> | ...+>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede1(iesp,idebd,iadrr,nvirt,
     *nump,1,18)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |c....> | ...+> cpu',icpu1
         call flush(6)
      endif
 20   continue
c-----determinants |i.... a b> | +...+ +>   classes (i,a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede3(iesp,idebd,idebd3,iadrr,
     *nvirt,nvirt,ninac,-1,nump,
     *nump,numt,1,1,1,19,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i.... a b> | +...+ +> cpu',icpu1
         call flush(6)
      endif
c-----determinants |c....> | ...+>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede1(iesp,idebd,iadrr,nvirt,
     *nump,1,18)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |c....> | ...+> cpu',icpu1
         call flush(6)
      endif
      if(syspin.ne.'0') goto 3
c-----determinants |i.... a b> | -...- ->   classes (i,a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede3(iesp,idebd,idebd3,iadrr,
     *nvirt,nvirt,ninac,-1,nump,
     *nump,numt,-1,-1,-1,20,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'cdeterminants |i.... a b> | -...- -> pu',icpu1
         call flush(6)
      endif
c-----determinants |c....> | ...->
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede1(iesp,idebd,iadrr,nvirt,
     *nump,-1,16)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |c....> | ...->cpu',icpu1
         call flush(6)
      endif
 3    continue
      melc(2)=1
c-----determinants |i j.... b> | + -...+>
      if(syspin.ne.'0') goto 21
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede3(iesp,idebd,idebd3,iadrr,
     *ninac,ninac,nvirt,1,numt,
     *numt,nump,1,-1,1,21,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j.... b> | + -...+> cpu',icpu1
         call flush(6)
      endif
c-----determinants |k....> | -...>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede1(iesp,idebd,iadrr,ninac,
     *numt,-1,22)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |k....> | -...> cpu',icpu1
         call flush(6)
      endif
 21   continue
c-----determinants |i j.... b> | - +...->
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede3(iesp,idebd,idebd3,iadrr,
     *ninac,ninac,nvirt,1,numt,
     *numt,nump,-1,1,-1,23,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j.... b> | - +...-> cpu',icpu1
         call flush(6)
      endif
c-----determinants |k....> | +...>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede1(iesp,idebd,iadrr,ninac,
     *numt,1,24)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |k....> | +...> cpu',icpu1
         call flush(6)
      endif
c-----determinants |i j.... b> | + +...+>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede3(iesp,idebd,idebd3,iadrr,
     *ninac,ninac,nvirt,-1,numt,
     *numt,nump,1,1,1,25,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j.... b> | + +...+> cpu',icpu1
         call flush(6)
      endif
c-----determinants |k....> | +...>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede1(iesp,idebd,iadrr,ninac,
     *numt,1,24)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |k....> | +...> cpu',icpu1
         call flush(6)
      endif
c-----determinants |i j.... b> | - -...->
      if(syspin.ne.'0') goto 22
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede3(iesp,idebd,idebd3,iadrr,
     *ninac,ninac,nvirt,-1,numt,
     *numt,nump,-1,-1,-1,26,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j.... b> | - -...-> cpu',icpu1
         call flush(6)
      endif
c-----determinants |k....> | -...>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede1(iesp,idebd,iadrr,ninac,
     *numt,-1,22)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |k....> | -...> cpu',icpu1
         call flush(6)
      endif
 22   continue
      close(77)
      close(76)
      if(gener.eq.'DDCI'.or.gener.eq.'DDci'.or.gener.eq.'DDC2') goto 1
c-----determinants |i j a b> | + - + ->
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
c      print'(''avant prede4 y66(1,1,3,3)'',l2)',y66(1,1,3,3)
      if(y66(1,1,3,3)) goto 661
      open(77,status='UNKNOWN',form='UNFORMATTED',file='CD_DEBL27')
      open(76,status='UNKNOWN',form='UNFORMATTED',file='CD_ADRR27')
      call prede4(iesp,iadrr,27,
     *1,-1,l3311,i3311,'CDI_3311')
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j a b> | + - + -> cpu',icpu1
         call flush(6)
      endif
      close(77)
      close(76)
 661  continue
      open(77,status='UNKNOWN',form='UNFORMATTED',file='CD_DEBL30')
      open(76,status='UNKNOWN',form='UNFORMATTED',file='CD_ADRR30')
c-----determinants |i j a b> | + + + +>
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede4(iesp,iadrr,30,
     *1,1,le3311,ie3311,'CDE_3311')
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j a b> | + + + +> cpu',icpu1
         call flush(6)
      endif
c-----determinants |i j a b> | - - - ->
      if(syspin.ne.'0') goto 1
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede4(iesp,iadrr,31,
     *-1,-1,le3311,ie3311,'CDE_3311')
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i j a b> | - - - -> cpu',icpu1
         call flush(6)
      endif
      close(77)
      close(76)
 1    continue
      nmelc=3
      melc(1)=0
      melc(2)=-1
      melc(3)=1
      if(yw)write(6,*)'appel cas 28'
c-----determinants |i. C0 a.> | +.....+>   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      if(y66(1,1,3,3)) goto 662
      open(77,status='UNKNOWN',form='UNFORMATTED',file='CD_DEBL28')
      open(76,status='UNKNOWN',form='UNFORMATTED',file='CD_ADRR28')
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,1,1,28,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i. C0 a.> | +.....+> cpu',icpu1
         call flush(6)
      endif
      if(yw)write(6,*)'appel cas 29'
c-----determinants |i. C0 a.> | -.....->   classes (i,a)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,ninac,nvirt,1,numt
     *,nump,-1,-1,29,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |i. C0 a.> | -.....-> cpu',icpu1
         call flush(6)
      endif
      if(itest(66).eq.1) then
c        si les listes sont trop longues, on les elimine
         mmm=0
         do k=28,29
            mmm=max(mmm,mdet(k))
         enddo
         if(mmm.gt.iadri) then
            print*,
     *      'dimension liste 28,29 trop grande, on fait autrement'
            do l=28,29
               mdet(l)=0
            enddo
            close(77,status='delete')
            close(76,status='delete')
            itest(68)=1
         else
            close(77)
            close(76)
         endif
      endif
 662  continue
c      melc(1)=1
      nmelc=5
      melc(1)=0
      melc(2)=-1
      melc(3)=1
      melc(4)=-2
      melc(5)=2
      if(ygmono) goto 12
      if(ivvvc8.eq.0) goto 12
      open(77,status='UNKNOWN',form='UNFORMATTED',file='CD_DEBL32')
      open(76,status='UNKNOWN',form='UNFORMATTED',file='CD_ADRR32')
c-----determinants |....a b> |.... + ->   classes (a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,nvirt,nvirt,1,nump
     *,nump,1,-1,1,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |....a b> |.... + -> cpu',icpu1
         call flush(6)
      endif
c-----determinants |...I..a> |.... + ->
      if(yw)write(6,*)'appel prdec1'
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prdec1(iesp,idebd,iadrr,nvirt,nvirt,1,nump
     *,nump,1,-1,32,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |...I..a> |.... + -> cpu',icpu1
         call flush(6)
      endif
c-----determinants |....a b> |.... + ->   classes (a,b)
      if(syspin.ne.'0') goto 4
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,nvirt,nvirt,1,nump
     *,nump,1,-1,1,0)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |....a b> |.... + -> cpu',icpu1
         call flush(6)
      endif
c-----determinants |...I..a> |.... - +>
      if(yw)write(6,*)'appel prdec1'
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prdec1(iesp,idebd,iadrr,nvirt,nvirt,1,nump
     *,nump,1,-1,33,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |...I..a> |.... - +> cpu',icpu1
         call flush(6)
      endif
c
c-----determinants |....a b> |.... - ->   classes (a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,nvirt,nvirt,-1,nump
     *,nump,-1,-1,2,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |....a b> |.... - -> cpu',icpu1
         call flush(6)
      endif
c-----determinants |...I..a> |.... - ->
      if(yw)write(6,*)'appel prdec1'
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prdec1(iesp,idebd,iadrr,nvirt,nvirt,-1,nump
     *,nump,-1,-1,34,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |...I..a> |.... - -> cpu',icpu1
         call flush(6)
      endif
 4    continue
c-----determinants |....a b> |.... + +>   classes (a,b)
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prede2(iesp,idebd,iadrr,iadrr(iadri*2+1),iadrr(iadri*3+1)
     *   ,nvirt,nvirt,-1,nump
     *,nump,1,1,3,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |....a b> |.... + +> cpu',icpu1
         call flush(6)
      endif
c-----determinants |...I..a> |.... + +>
      if(yw)write(6,*)'appel prdec1'
      if(ytana) then
         icpu(2)=itemps(idum)
      endif
      call prdec1(iesp,idebd,iadrr,nvirt,nvirt,-1,nump
     *,nump,1,1,35,1)
      if(ytana) then
         icpu1=itemps(idum)-icpu(2)
         write(6,*)'determinants |...I..i> |.... + +> cpu',icpu1
         call flush(6)
      endif
      close(77)
      close(76)
 12   continue
      syspins=syspin
      syspin='0'
      if(yw1)write(6,*)'dimension des listes de determinants'
      if(yw1)write(6,'(a6,8(5i10,/,6x))')' mdet',(mdet(k),k=1,39)
      if(yw1)write(6,*)'============================================'
c      if(itest(66).eq.1) then
c         mmm=0
c         do k=9,14
c            mmm=max(mmm,mdet(k))
c         enddo
c         if(mmm.gt.iadri) then
c            print*,'dimension liste 9/14 trop grande, on fait autrement
c            do l=9,14
c               mdet(l)=0
c            enddo
c            itest(67)=1
c         endif
c         mmm=0
c         do k=28,29
c            mmm=max(mmm,mdet(k))
c         enddo
c         if(mmm.gt.iadri) then
c            print*,
c     *      'dimension liste 28/29 trop grande, on fait autrement'
c            do l=28,29
c               mdet(l)=0
c            enddo
c            itest(68)=1
c         endif
c      endif
      mmm=0
      do k=1,39
         mmm=max(mmm,mdet(k))
      enddo
      call verdim('dimension liste trop grande   : mdet iadri '
     *,mmm,iadri)
      write(64) mdet
      write(64) itest,y66,ye66
      close(64)
      call flush(6)
      syspin=syspins
      return
      end
