anchor.diff:      type(grid_cell),intent(in) :: icell
       type(vector3d_dp), intent(out) :: pos
       type(grid_cell) :: icell_actual
  -      
  +
       type(kdtree2_result) :: results(1)
       real(dp) :: point(3)
  -        
  +
       do
   
           ! Sample in bounding box
           call random_uni(pos%x, geo%cells(icell%ic)%xmin, geo%cells(icell%ic)%xmax)
           call random_uni(pos%y, geo%cells(icell%ic)%ymin, geo%cells(icell%ic)%ymax)
           call random_uni(pos%z, geo%cells(icell%ic)%zmin, geo%cells(icell%ic)%zmax)
  -    
  +
           ! Check if in right cell
           point = [pos%x, pos%y, pos%z]
           call kdtree2_n_nearest(geo%tree, point, 1, results)
  -        
  +
           ! Break if correct
           if(results(1)%idx == icell%ic) exit
  -        
  +
       end do
  -        
  +
     end subroutine random_position_cell
   
     real(dp) function distance_to_closest_wall(p) result(d)
  
positive.code:     real(dp), allocatable :: x(:), y(:), z(:)
      integer, allocatable :: neighbors(:,:)
      integer :: n_neighbors
      real(dp),allocatable :: points(:,:), bmin(:,:), bmax(:,:)
      type(cell),pointer :: c
  
      ! Read geometry file
  
negative.code:           geo%mask_map(iv) = ic
         end if
      end do
  
      where(geo%volume < 0._dp) geo%volume = 0._dp
  
      geo%n_dim = 3
  