anchor.diff:  
       if(p%on_wall) then
   
  -       if(p%on_wall_id > 26 .or. p%on_wall_id < 1) then
  -          call warn("in_correct_cell","invalid on_wall_id")
  -          in_correct_cell = .false.
  -          return
  -       else
  -          in_correct_cell = .true.
  -       end if
  -
  -       select case(p%on_wall_id)
  -       case(1, 7, 9, 11, 13, 19, 21, 23, 25)
  +       in_correct_cell = .true.
  +
  +       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) < 1.e-3_dp
  -       case(2, 8, 10, 12, 14, 20, 22, 24, 26)
  +       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) < 1.e-3_dp
  -       case default
  +       else
             in_correct_cell = in_correct_cell .and. icell_actual%i1 == p%icell%i1
  -       end select
  -
  -       select case(p%on_wall_id)
  -       case(3, 7, 8, 15, 17, 19, 20, 23, 24)
  +       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) < 1.e-3_dp
  -       case(4, 9, 10, 16, 18, 21, 22, 25, 26)
  +       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) < 1.e-3_dp
  -       case default
  +       else
             in_correct_cell = in_correct_cell .and. icell_actual%i2 == p%icell%i2
  -       end select
  -
  -       select case(p%on_wall_id)
  -       case(5, 11, 12, 15, 16, 19, 20, 21, 22)
  +       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) < 1.e-3_dp
  -       case(6, 13, 14, 17, 18, 23, 24, 25, 26)
  +       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) < 1.e-3_dp
  -       case default
  +       else
             in_correct_cell = in_correct_cell .and. icell_actual%i3 == p%icell%i3
  -       end select
  +       end if
   
       else
   
  
positive.code:     ! Compute other useful quantities
      geo%n_dim = 3
  
    end subroutine setup_grid_geometry
  
    subroutine grid_geometry_debug(debug_flag)
  
negative.code:     escaped_cell = .false.
    end function escaped_cell
  
    type(grid_cell) function next_cell_int(cell, direction, intersection)
      implicit none
      type(grid_cell),intent(in) :: cell
      integer,intent(in) :: direction
  