title: Using random numbers to delete random lines of a file. Fortran90
body: <p>I've been struggling with a problem, so if anyone could offer any advice or examples it would be really appreciated. Using Fortran90.</p>
  
  <p><strong>Purpose of program:</strong> </p>
  
  <p>To delete random lines from a file, at a quantity of my choosing. The best way I could think to do that was using random numbers to correspond to a line number.</p>
  
  <p><strong>What it does at the moment:</strong> </p>
  
  <p>Generates new random numbers each time and outputs them to a separate file.</p>
  
  <p><strong>Problems:</strong> </p>
  
  <p>(1) it doesn't generate integers that could correspond to a line number.
            (2) I don't know how to make the leap into using those numbers to delete lines from a file.</p>
  
  <pre><code>program random1
  implicit none
  integer :: i, seed, removed
  real :: r
  open (unit=10,file='random.dat')
  removed=5
  
  call init_random_seed() 
  do i=1,removed
  call random_number(r)
  write(10,*) r
  end Do
  
  end program random1
  
  subroutine init_random_seed()
          integer :: i,n,clock
          integer, dimension(:),allocatable :: seed
  
          call random_seed(size=n)
          allocate(seed(n))
  
          call system_clock(count=clock)
  
          seed=clock+37*(/(i-1,i=1,n)/)
          call random_seed(put=seed)
  
          deallocate(seed)
  end subroutine
  </code></pre>
  
  <p>Thank you!</p>