anchor.diff:      else if (bc(coll_dim) == SPECULAR_BC) then
          v(coll_dim) = -v(coll_dim)
       else if (bc(coll_dim) == PERIODIC_BC) then
  -       if (x(coll_dim) <= 0) then
  -          x(coll_dim) = x(coll_dim) + L(coll_dim)
  -       else if (x(coll_dim) >= L(coll_dim)) then
  -          x(coll_dim) = x(coll_dim) - L(coll_dim)
  -       end if
  +       jump = floor(x/L)
  +       x(coll_dim) = x(coll_dim) - jump(coll_dim)*L(coll_dim)
       end if
   
       wall_loop: do while (.true.)
  
positive.code:     integer, intent(in) :: bc(3)
      double precision, intent(in), optional :: g
  
      double precision, dimension(3) :: gvec, t_tmp
      double precision, dimension(3) :: old_x, old_v
      double precision :: t_collision, t_remainder, tt
      integer :: i, jump
      integer :: coll_dim, other_dim, actual_bc
      logical :: mirror(3), collision(3)
  
      gvec = 0
      if (present(g)) gvec(1) = g
  
negative.code:        else if (bc(coll_dim) == SPECULAR_BC) then
            v(coll_dim) = -v(coll_dim)
         else if (bc(coll_dim) == PERIODIC_BC) then
            jump = floor(x/L)
            x(coll_dim) = x(coll_dim) - jump(coll_dim)*L(coll_dim)
         end if
      end do wall_loop
  
      t_collision = t_remainder
      x = x + v*t_collision + gvec*t_collision**2 / 2
      v = v + gvec*t_collision
  
    end subroutine yzwall_collision
  
  