!+ ! Subroutine bmad_init_coord (ix_lat, ix_ele, orbit) ! ! Routine to initialize a coord struct. ! ! Input: ! ix_lat -- Integer: Index of lattice to use. ! ix_ele -- Integer: Index of element at which orbit is initialized at. ! The initialization is appropriate for the exit end of the elemtn. ! orbit -- CPP_coord: Structure to initialize. ! ! Output: ! orbit -- CPP_coord: Initialized structure. !- subroutine bmad_init_coord (ix_lat, ix_ele, orbit) use bmad_common_mod implicit none type (c_ptr), value :: orbit type (twiss_struct), target :: zero_twiss type (ele_struct), pointer :: ele_at_s type (lat_struct), pointer :: lat type (coord_struct), target :: f_orbit integer ix_lat, ix_ele character(*), parameter :: r_name = 'bmad_init_coord' ! if (lat_status(ix_lat) /= init_done$) then call out_io (s_error$, r_name, 'LATTICE NOT YET INITIALIZED!') return endif lat => bd_com(ix_lat)%lat ! call coord_to_f (orbit, c_loc(f_orbit)) call init_coord (f_orbit, f_orbit%vec, lat%ele(ix_ele), downstream_end$, electron$, +1) call coord_to_c (c_loc(f_orbit), orbit) end subroutine