anchor.diff:          end do
   
       end function det_momentum
  -
  -    pure function det_invert_spin(f) result(f_inv)
  -
  -        ! Applies the spin inversion operator to a determinant.
  -        ! In:
  -        !    f(basis_length): bit string representation of the Slater
  -        !        determinant.
  -        ! Returns:
  -        !    f_inv(basis_length): bit string representation of the Slater
  -        !        determinant after the application of the spin inversion
  -        !        operator.
  -
  -        integer(i0) :: f_inv(basis_length)
  -        integer(i0), intent(in) :: f(basis_length)
  -
  -        integer(i0) :: a,b
  -        integer :: i
  -
  -        do i = 1, basis_length
  -            ! Find bit string of all alpha orbitals.
  -            a = iand(f(i), alpha_mask)
  -            ! Find bit string of all beta orbitals.
  -            b = iand(f(i), beta_mask)
  -            f_inv(i) = ishft(a,1) + ishft(b,-1)
  -        end do
  -
  -    end function det_invert_spin
  -
  -    subroutine write_det(f, iunit, new_line)
  -
  -        ! Write out a determinant as a list of occupied orbitals in the
  -        ! Slater determinant.
  -        ! In:
  -        !    f(basis_length): bit string representation of the Slater
  -        !        determinant.
  -        !    iunit (optional): io unit to which the output is written.
  -        !        Default: 6 (stdout).
  -        !    new_line (optional): if true, then a new line is written at
  -        !        the end of the list of occupied orbitals.  Default: no
  -        !        new line.
  -
  -        use utils, only: int_fmt
  -
  -        integer(i0), intent(in) :: f(basis_length)
  -        integer, intent(in), optional :: iunit
  -        logical, intent(in), optional :: new_line
  -        integer :: occ_list(nel), io, i
  -        character(4) :: fmt1
  -
  -        if (present(iunit)) then
  -            io = iunit
  -        else
  -            io = 6
  -        end if
  -
  -        call decode_det(f, occ_list)
  -        fmt1 = int_fmt(nbasis,1)
  -
  -        write (io,'("|")', advance='no')
  -        do i = 1, nel
  -            write (io,'('//fmt1//')', advance='no') occ_list(i)
  -        end do
  -        write (io,'(1X,">")', advance='no')
  -        if (present(new_line)) then
  -            if (new_line) write (io,'()')
  -        end if
  -
  -    end subroutine write_det
   
       pure function det_spin(f) result(Ms)
   
  
positive.code:         end do
  
      end function det_spin
  
      pure function det_gt(f1, f2) result(gt)
  
  
negative.code:         end select
  
      end subroutine set_spin_polarisation
  
  !--- Complete enumeration of determinant Hilbert space ---
  
      subroutine find_sym_space_size()
  
  