subroutine write_det_len(nunit, nI, nlen, lterm)
! Worker function for the above. Can be accessed to print an unusual
! lengthed determinant.
integer, intent(in) :: nunit, nlen, nI(nlen)
logical, intent(in) :: lTerm
integer :: i, elec
! Start with a bracket, and loop over all the electrons
write(nunit, '("(")', advance='no')
do i = 1, nlen
elec = nI(i)
! Write out the orbital number
write(nunit, '(i5)', advance='no') elec
if (i /= nlen) write(nunit, '(",")', advance='no')
end do
! Close the written determinant off
write(nunit, '(")")', advance='no')
if (lTerm) write(nunit, *)
end subroutine write_det_len