anchor.diff:    integer                        :: N_miniList, ni, leng
     double precision, allocatable  :: hij_cache(:)
     
  +  integer(bit_kind), allocatable :: microlist(:,:,:), microlist_zero(:,:,:)
  +  integer, allocatable           :: idx_microlist(:), N_microlist(:), ptr_microlist(:), idx_microlist_zero(:)
  +  integer :: mobiles(2), smallerlist
  +  
  +  
     
     leng = max(N_det_generators, N_det_non_ref)
  -  allocate(miniList(Nint, 2, leng), idx_miniList(leng), hij_cache(N_det_non_ref))
  +  allocate(miniList(Nint, 2, leng), idx_minilist(leng), hij_cache(N_det_non_ref))
     
     !create_minilist_find_previous(key_mask, fullList, miniList, N_fullList, N_miniList, fullMatch, Nint)
     call create_minilist_find_previous(key_mask, psi_det_generators, miniList, i_generator-1, N_miniList, fullMatch, Nint)
  
positive.code: end
  
  
  
  
  
  
  
  
negative.code:     return
    end if
    
    allocate(ptr_microlist(0:mo_tot_num*2+1),  &
        N_microlist(0:mo_tot_num*2) )
    allocate(   microlist(Nint,2,N_minilist*4),               &
      idx_microlist(N_minilist*4))
    
    if(key_mask(1,1) /= 0) then
      call create_microlist(miniList, N_minilist, key_mask, microlist, idx_microlist, N_microlist, ptr_microlist, Nint)
      call find_triples_and_quadruples_micro(i_generator,n_selected,det_buffer,Nint,tq,N_tq,microlist,ptr_microlist,N_microlist,key_mask)
    else
      call find_triples_and_quadruples(i_generator,n_selected,det_buffer,Nint,tq,N_tq,miniList,N_minilist)
  !     microlist(:N_miniList) = minilist(:N_miniList)
  !     idx_microlist(:N_minilist) = idx_minilist(:)
  !     N_microlist(0) = N_miniList
  !     ptr_microlist(1) = 1
  !     ptr_microlist(2) = N_miniList + 1
    end if
    
    
    
    deallocate(microlist, idx_microlist)
    
    allocate (dIa_hla(Nstates,Ndet_non_ref))
    
  