subroutine init_double_occ_output(funit)
! i need a routine to initialize the additional output, which I
! think should go into a seperate file for now!
integer, intent(in) :: funit
character(*), parameter :: this_routine = "init_double_occ_output"
character(30) :: filename
character(43) :: filename2
character(12) :: num
logical :: exists
integer :: i, ierr
filename = "double_occupancy_stats"
if (tReadPops) then
open(funit, file=filename, status='unknown', position='append')
else
inquire (file=filename, exist=exists)
! rename the existing file an create a new one
if (exists) then
i = 1
do while (exists)
write(num, '(i12)') i
filename2 = trim(adjustl(filename))//"."// &
trim(adjustl(num))
inquire (file=filename2, exist=exists)
if (i > 10000) call stop_all(this_routine, &
"error finding free double_occupancy_stats")
i = i + 1
end do
! i am not sure where this routine is defined:
call rename(filename, filename2)
end if
open(funit, file=filename, status='unknown', iostat=ierr)
end if
end subroutine init_double_occ_output