!+ ! Subroutine track1_custom (start_orb, ele, param, end_orb, err_flag, finished, track) ! ! ! 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. ! err_flag -- logical: Set true if there is an error. False otherwise. ! finished -- logical: When set True, track1 will halt processing and return to its calling routine. ! track -- track_struct, optional: Structure holding the track information if the ! tracking method does tracking step-by-step. !- subroutine track1_custom (start_orb, ele, param, end_orb, err_flag, finished, track) use bmad use ion_tracker_mod use ion_tracker_struct implicit none type (coord_struct) :: start_orb type (coord_struct) :: mid_orb type (coord_struct) :: end_orb type (ele_struct) :: ele type (lat_param_struct) :: param type (track_struct), optional :: track real(rp) :: kick(3) integer :: version logical err_flag, finished character(*), parameter :: r_name = 'track1_custom' ! Inputs for cbeta_ions real(rp) :: x_norm, y_norm, r, sigma_x, sigma_y, sig_ee err_flag = .false. ! Remember to also set end_orb%t end_orb = start_orb end_orb%s = ele%s !ele%ix_pointer should have been set by turn_track1_custom_on_for_all_elements ele%tracking_method = ele%ix_pointer version = param%ixx call track1 (start_orb, ele, param, mid_orb, track, err_flag) !If version == 0, then this routine should not have been used in the first place if (version > 0) then call apply_ion_kicks(mid_orb, ele, param, end_orb, kick, version) elseif (version == 0) then print *, 'No ion kicks' else !Version must be a positive integer call out_io(s_fatal$, 'apply_ion_kicks', 'VERSION NOT FOUND') endif !Reset tracking_method to custom$ so that this custom tracking can be applied to !all particles in the beam. ele%tracking_method = custom$ end subroutine