!+ ! Subroutine bmad_calc_transfer_matrix (ix_lat, s1, s2, vec0, mat6_vec, c_err) ! ! Calculates transfer matrix between two points ! ! Input: ! ix_lat -- Integer: Index of lattice to use. ! s1, s2 -- Real(rp): End points. ! ! Output: ! vec0(6) -- Real(rp): Zeroth part of transfer map. ! mat6_vec(36) -- Real(rp): Vectorized transfer matrix. ! c_err -- C_logical: Set True if there is an error. False otherwise. !- subroutine bmad_calc_transfer_matrix (ix_lat, s1, s2, vec0, mat6_vec, c_err) use bmad_common_mod use transfer_map_mod implicit none type (lat_struct), pointer :: lat real(rp) s1, s2, mat6_vec(36), vec0(6), mat6(6,6) integer ix_lat logical(c_bool) c_err logical err1, err2 character(28), parameter :: r_name = 'bmad_calc_transfer_matrix' logical err_flag ! transfer matrix c_err = c_logic(.true.) if (lat_status(ix_lat) /= init_done$) then call out_io (s_error$, r_name, "Lattice \i0\ not yet initialized!", ix_lat) mat6_vec = 0 return endif lat => bd_com(ix_lat)%lat call check_if_s_in_bounds (lat%branch(0), s1, err1) call check_if_s_in_bounds (lat%branch(0), s2, err2) if (err1 .or. err2) then mat6_vec = 0 return endif call mat6_from_s_to_s (lat, mat6, vec0, s1, s2, err_flag = err_flag) if (err_flag) return mat6_vec = mat2vec(mat6, 36) c_err = c_logic(.false.) end subroutine