anchor.diff:                  do i = 1, nbeta_combinations
   
                       ! Get beta orbitals.
  -                    if (i == 1) then
  -                        f_beta = first_perm(nbeta)
  -                    else
  -                        f_beta = bit_permutation(f_beta)
  -                    end if
  -
  -                    call decode_bit_string(f_beta, occ)
  -                    ! Convert to beta orbitals.
  -                    occ = 2*(occ+1)
  +                    call next_string(i==1, .false., nbasis/2, nbeta, d0%occ_list_beta, &
  +                                     d0%unocc_list_beta, truncation_level, comb(:,1),  &
  +                                     occ(1:nbeta), excit_level_beta)
  +
                       ! Symmetry.
                       ! Have to treat the UEG as a special case as we don't consider
                       ! all possible symmetries for the UEG but rather only momenta
  
positive.code:         integer, intent(in), optional :: occ_list0(nel)
  
          integer :: i, j, iel, idet, ierr
          integer :: nalpha_combinations, nbeta_combinations
          integer :: sym_beta, sym
          character(4) :: fmt1
          integer(i0) :: f_alpha, f_beta, f0(basis_length), f(basis_length)
          integer, allocatable :: occ(:)
          integer :: k(ndim), k_beta(ndim)
  
          allocate(occ(nel), stat=ierr)
          call check_allocate('occ', nel, ierr)
  
negative.code:         !        being used.  *MUST* be specified if truncate_space is true.
  
          use checking, only: check_allocate, check_deallocate
          use errors, only: stop_all
          use utils, only: binom_i, int_fmt
  
          use basis, only: basis_length
  