anchor.diff:    call alloc(elens_iSet           , nelens_new,           elens_iSet_def, 'elens_iSet'           )
     call alloc(elens_optVal         , nelens_new,                     zero, 'elens_optVal'         )
     call alloc(elens_nUpdates       , nelens_new,                        0, 'elens_nUpdates'       )
  +  call alloc(elens_beam_mass      , nelens_new,      elens_beam_mass_def, 'elens_beam_mass'      )
  +  call alloc(elens_beam_chrg      , nelens_new,      elens_beam_chrg_def, 'elens_beam_chrg'      )
     call alloc(elens_iRadial        , nelens_new,                        0, 'elens_iRadial'        )
     call alloc(elens_radial_fr1     , nelens_new,                     zero, 'elens_radial_fr1'     )
     call alloc(elens_radial_fr2     , nelens_new,                     zero, 'elens_radial_fr2'     )
  
positive.code:   logical, allocatable, save          :: elens_lAllowUpdate_CR(:) ! (nelens)
  #endif
    ! R1/R2 expressed in normalised units (either betatron or dispersion)
    real(kind=fPrec), allocatable, save :: elens_emin(:)            ! normalised emittance [m rad]
    real(kind=fPrec), allocatable, save :: elens_sigdpp(:)          ! default rms of distribution in delta_p / p []
    integer, allocatable, save          :: elens_iSet(:)            ! which value of beta or disp should be taken:
                                                                    ! 0: none
                                                                    ! 1: min
                                                                    ! 2: max
                                                                    ! 3: average
                                                                    ! 4: quadratic average
                                                                    ! 5: geometric average
    real(kind=fPrec), allocatable, save :: elens_optVal(:)          ! value of optics function for normalised settings
    integer, allocatable, save          :: elens_nUpdates(:)        ! how many slices are being used
                                                                    
    ! radial profile
    integer, allocatable, save          :: elens_iRadial(:)         ! mapping to the radial profile (nelens)
    real(kind=fPrec), allocatable, save :: elens_radial_fr1(:)      ! value of f(R1) in case of radial profiles from file [0:1] (nelens)
  
negative.code:       ! 'radial kick'
        frr = (elens_theta_r2(ielens(ix))*((elens_r2(ielens(ix))/rr)*frr))*moidpsv(jj)
        if(elens_lThetaR2(ielens(ix))) then
          tmpBB=sign(elens_beta_lens_beam(ielens(ix))*beta0,elens_I(ielens(ix))/elens_beam_chrg(ielens(ix)))
          frr = frr*((rvv(jj)-tmpBB)/(one-tmpBB))
        endif
        yv1(jj)=yv1(jj)+frr*(xx/rr)
        yv2(jj)=yv2(jj)+frr*(yy/rr)
      endif
    end do
  end subroutine elens_kick
  