      subroutine genel(nt01,np01,it01,ip01,
     *nt02,np02,it02,ip02,ntaj,npaj,nl)
      use module
      dimension it01(nt01)
      dimension ip01(np01)
      dimension it02(nt02)
      dimension ip02(np02)
      dimension itaj(2)
      dimension ipaj(2)
      logical y,yw
!
!  < it01 itaj --> ip01 ipaj  |  it02 itaj --> ip02 ipaj >
!
      nl=0
      yw=.true.
      if(yw) then
         print*,'genel it01',it01(1:nt01)
         print*,'genel ip01',ip01(1:np01)
         print*,'genel it02',it02(1:nt02)
         print*,'genel ip02',ip02(1:np02)
         print*,'ntaj,npaj)',ntaj,npaj
      endif
      if(ntaj==0) then
         if(npaj==0) then
            call genel2(nt01,np01,it01,ip01,
     *      nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
         else if(npaj==1) then
            do k=1,nvirt
               ipaj(1)=numvir(k)
               call genel2(nt01,np01,it01,ip01,
     *         nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
            enddo
         else if(npaj==2) then
            do k=1,nvirt
               ipaj(1)=numvir(k)
               do l=k,nvirt
                  ipaj(2)=numvir(l)
                  call genel2(nt01,np01,it01,ip01,
     *            nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
               enddo
            enddo
         endif
      else if(ntaj==1) then
         if(npaj==0) then
            do k=1,ninac
               itaj(1)=numin(k)
               call genel2(nt01,np01,it01,ip01,
     *         nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
            enddo
         else if(npaj==1) then
            do k=1,ninac
               itaj(1)=numin(k)
               do l=1,nvirt
                  ipaj(1)=numvir(l)
                  call genel2(nt01,np01,it01,ip01,
     *            nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
               enddo
            enddo
         else if(npaj==2) then
            do k=1,ninac
               itaj(1)=numin(k)
               do l=1,nvirt
                  ipaj(1)=numvir(l)
                  do m=1,nvirt
                     ipaj(2)=numvir(m)
                     call genel2(nt01,np01,it01,ip01,
     *               nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
                  enddo
               enddo
            enddo
         endif
      else if(ntaj==2) then
         if(npaj==0) then
            do k=1,ninac
               itaj(1)=numin(k)
               do l=k,ninac
                  itaj(2)=numin(l)
                  call genel2(nt01,np01,it01,ip01,
     *            nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
               enddo
            enddo
         else if(npaj==1) then
            do k=1,ninac
               itaj(1)=numin(k)
               do l=1,ninac
                  itaj(2)=numin(l)
                  do m=1,nvirt
                     ipaj(1)=numvir(m)
                     call genel2(nt01,np01,it01,ip01,
     *               nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
                  enddo
               enddo
            enddo
         else if(npaj==2) then
            stop 'genel'
         endif
      endif
      return
      end
      
       subroutine genel2(nt01,np01,it01,ip01,
     *nt02,np02,it02,ip02,ntaj,npaj,itaj,ipaj,nl)
      dimension it01(nt01)
      dimension ip01(np01)
      dimension it02(nt02)
      dimension ip02(np02)
      dimension itaj(2)
      dimension ipaj(2)
      dimension it1(2),ip1(2),it2(2),ip2(2)
      logical y,yw
      yw=.true.
      nt1=0
      do k=1,nt01
         nt1=nt1+1
         it1(nt1)=it01(k)
      enddo
      do k=1,ntaj
         nt1=nt1+1
         it1(nt1)=itaj(k)
      enddo
!
      np1=0
      do k=1,np01
         np1=np1+1
         ip1(np1)=ip01(k)
      enddo
      do k=1,npaj
         np1=np1+1
         ip1(np1)=ipaj(k)
      enddo
!
      nt2=0
      do k=1,nt02
         nt2=nt2+1
         it2(nt2)=it02(k)
      enddo
      do k=1,ntaj
         nt2=nt2+1
         it2(nt2)=itaj(k)
      enddo
!
      np2=0
      do k=1,np02
         np2=np2+1
         ip2(np2)=ip02(k)
      enddo
      do k=1,npaj
         np2=np2+1
         ip2(np2)=ipaj(k)
      enddo
      if(yw)print*,'it1,ip1',it1(1:nt1),' --> ',ip1(1:np1)
      if(yw)print*,'it2,ip2',it2(1:nt2),' --> ',ip2(1:np2)
!
!  < it1 --> ip1   |  it2  --> ip2  >
!
      call verifl(nt1,it1,np1,ip1,iadr1)
      if(iadr1==0) return
      call verifl(nt2,it2,np2,ip2,iadr2)
      if(iadr2==0) return
      nl=nl+1
      return
      end
       subroutine verifl(nt1,it1,np1,ip1,iadr1)
      use module
      dimension it1(nt1),ip1(np1)
      iadr1=0
      if(nt1==0) then
         if(np1==0) then
            iadr1=1
         else if(np1==1) then
            iadr1=ilc1(ip1(1))
         else if(np1==2) then
            ii=ilc1(ip1(1))
            if(ii==0) return
            jj=ilc1(ip1(2))
            if(jj==0) return
            if(jj<ii) stop'(jj<ii'
            iadr1=num1(jj)+ii
         endif
      else if(nt1==1) then
         if(np1==0) then
            iadr1=ilc1(it1(1))
         else if(np1==1) then
            iadr1=il(it1(1),ip1(1))
         else if(np1==2) then
            if(ilc1(ip1(1))/=0) then
               if(ilp(it1(1),ip1(2))/=0) then
                  iadr1=abs(ipc(ilp(it1(1),ip1(2)),ilc1(ip1(1))))
               endif
            endif
            if(iadr1==0) then
               if(ilc1(ip1(2))/=0) then
                  if(ilp(it1(1),ip1(1))/=0) then
                     iadr1=abs(ipc(ilp(it1(1),ip1(1)),ilc1(ip1(2))))
                  endif
               endif
            endif
         endif
      else if(nt1==2) then
         if(np1==0) then
            ii=ilc1(it1(1))
            if(ii==0) return
            jj=ilc1(it1(2))
            if(jj==0) return
            if(jj<ii) stop'(jj<ii'
            iadr1=num1(jj)+ii
         else if(np1==1) then
            if(ilc1(it1(1))/=0) then
               if(ilp(it1(2),ip1(1))/=0) then
                  iadr1=abs(ipc(ilp(it1(2),ip1(1)),ilc1(it1(1))))
               endif
            endif
            if(iadr1==0) then
               if(ilc1(it1(2))/=0) then
                  if(ilp(it1(1),ip1(1))/=0) then
                     iadr1=abs(ipc(ilp(it1(1),ip1(1)),ilc1(it1(2))))
                  endif
               endif
            endif
         else if(np1==2) then
            if(ilp(it1(1),ip1(1))/=0) then
               if(ilp(it1(2),ip1(2))/=0) then
                  iimax=max(ilp(it1(1),ip1(1)),ilp(it1(2),ip1(2)))
                  iimin=min(ilp(it1(1),ip1(1)),ilp(it1(2),ip1(2)))
                  ii1=iimax*(iimax-1)/2+iimin
                  iadr1=abs(ipp(ii1))
               endif
            endif
            if(iadr1==0) then
               if(ilp(it1(1),ip1(2))/=0) then
                  if(ilp(it1(2),ip1(1))/=0) then
                     iimax=max(ilp(it1(1),ip1(2)),ilp(it1(2),ip1(1)))
                     iimin=min(ilp(it1(1),ip1(2)),ilp(it1(2),ip1(1)))
                     ii1=iimax*(iimax-1)/2+iimin
                     iadr1=abs(ipp(ii1))
                  endif
               endif
            endif
         endif
      endif
      print*,'verifl iadr1',iadr1
      return
      end
      
      
