!+
! Subroutine track1_custom (start_orb, ele, param, end_orb, err_flag, track)
!
! Add path length corresponding to change in RF frequency
! If called, this routine will generate an error message and quit.
! This routine needs to be replaced for a custom calculation.
!
! Note: This routine is not to be confused with track1_custom2.
! See the Bmad manual for more details.
!
! General rule: Your code may NOT modify any argument that is not listed as
! an output agument below."
!
! Modules Needed:
!   use bmad
!
! Input:
!   start_orb  -- Coord_struct: Starting position.
!   ele    -- Ele_struct: Element.
!   param  -- lat_param_struct: Lattice parameters.
!
! Output:
!   end_orb   -- Coord_struct: End position.
!   track     -- track_struct, optional: Structure holding the track information if the 
!                 tracking method does tracking step-by-step.
!   err_flag  -- Logical: Set true if there is an error. False otherwise.
!-

subroutine track1_custom (start_orb, ele, param, end_orb, err_flag, track)

use bmad_interface, except_dummy => track1_custom

implicit none

type (coord_struct) :: start_orb
type (coord_struct) :: end_orb
type (ele_struct) :: ele
type (lat_param_struct) :: param
type (track_struct), optional :: track
type (all_pointer_struct) a_ptr
logical err_flag

character(32) :: r_name = 'track1_custom'
real(rp) delta_s
!
err_flag = .false.
!print '(a,6es12.4)',' start_orb ',start_orb%vec
call pointer_to_attribute(ele, 'DELTA', .true., a_ptr, err_flag)
!delta_s = ele%value(custom_attribute1$)
 delta_s = a_ptr%r
 end_orb = start_orb
 end_orb%vec(5) = start_orb%vec(5) + delta_s
!print '(a,6es12.4)',' end_orb ',end_orb%vec
!print *,' delta_s = ', delta_s
 return
end subroutine
