anchor.diff:    logical :: debug = .false.
   
     real(dp) :: tmin, emin
  -  type(wall_id) :: imin
  +  type(wall_id) :: imin, iext
   
     public :: escaped
     interface escaped
  
positive.code:     type(photon),intent(in) :: p
      type(grid_cell) :: icell_actual
      real(dp) :: frac
  
      icell_actual = find_cell(p)
  
  
negative.code: 
         if(p%on_wall_id%w1 == -1) then
            frac = (p%r%x - geo%w1(p%icell%i1)) / (geo%w1(p%icell%i1+1) - geo%w1(p%icell%i1))
            in_correct_cell = in_correct_cell .and. abs(frac) < threshold
         else if(p%on_wall_id%w1 == +1) then
            frac = (p%r%x - geo%w1(p%icell%i1+1)) / (geo%w1(p%icell%i1+1) - geo%w1(p%icell%i1))
            in_correct_cell = in_correct_cell .and. abs(frac) < threshold
         else
            in_correct_cell = in_correct_cell .and. icell_actual%i1 == p%icell%i1
         end if
  
         if(p%on_wall_id%w2 == -1) then
            frac = (p%r%y - geo%w2(p%icell%i2)) / (geo%w2(p%icell%i2+1) - geo%w2(p%icell%i2))
            in_correct_cell = in_correct_cell .and. abs(frac) < threshold
         else if(p%on_wall_id%w2 == +1) then
            frac = (p%r%y - geo%w2(p%icell%i2+1)) / (geo%w2(p%icell%i2+1) - geo%w2(p%icell%i2))
            in_correct_cell = in_correct_cell .and. abs(frac) < threshold
         else
            in_correct_cell = in_correct_cell .and. icell_actual%i2 == p%icell%i2
         end if
  
         if(p%on_wall_id%w3 == -1) then
            frac = (p%r%z - geo%w3(p%icell%i3)) / (geo%w3(p%icell%i3+1) - geo%w3(p%icell%i3))
            in_correct_cell = in_correct_cell .and. abs(frac) < threshold
         else if(p%on_wall_id%w3 == +1) then
            frac = (p%r%z - geo%w3(p%icell%i3+1)) / (geo%w3(p%icell%i3+1) - geo%w3(p%icell%i3))
            in_correct_cell = in_correct_cell .and. abs(frac) < threshold
         else
            in_correct_cell = in_correct_cell .and. icell_actual%i3 == p%icell%i3
         end if
  