!+ ! Function bmad_element_index (ix_lat, ele_name) result (ix_ele) ! ! Find the element index. ! ! Input: ! ix_lat -- Integer: Index of lattice to search. ! ele_name -- Character(40): Name of element to find ! ! Output: ! ix_ele -- Integer: Index of element. Set to -1 if not found !- function bmad_element_index (ix_lat, ele_name) result (ix_ele) use bmad_common_mod implicit none type (lat_struct), pointer :: lat real(rp) attrib_value real(rp), pointer :: a_ptr integer ix_lat, ix_ele, i character(1) ele_name(*) character(40) e_name character(20), parameter :: r_name = 'bmad_element_index' logical err_flag ! ix_ele = -1 call bmad_set_lat_pointer (err_flag, r_name, ix_lat, lat, can_be_in_init = .true.) if (err_flag) return call remove_null_in_string(ele_name, e_name) call upcase(e_name) do i = 0, lat%n_ele_max if (lat%ele(i)%name == e_name) then ix_ele = i return endif enddo end function