subroutine nonlin_map_calc(lat,ix_start, ix_end, emitx,emity,emitz, ref_orbit, det, ft_matrix) use bmad use mode3_mod use da_interface, dummy => nonlin_map_calc implicit none type (lat_struct) lat type(coord_struct), allocatable:: co(:), orbit(:), ref_orbit(:) type(coord_struct) x_co real(rp), allocatable:: ft_matrix(:,:) real(rp) emitx,emity,emitz, det, tune(3) integer i, i_dim/6/, n integer ix_start, ix_end logical err_flag, full_turn logical first/.true./, err/.false./ call reallocate_coord(co,7) if(first )then call set_on_off(rfcavity$,lat,on$,ref_orbit) call twiss3_at_start(lat,err) if(err)then print *,' mode3 calc error in init_phase_space' stop endif call twiss3_propagate_all(lat) call set_on_off(rfcavity$,lat,off$,ref_orbit) first = .false. endif call init_phase_space(lat%ele(ix_start), emitx,emity,emitz, co, i_dim) call compute_ft_matrix(lat,ref_orbit,emitx,emity,emitz, ix_start, ix_end, co, i_dim,full_turn, ft_matrix, x_co) !call measure_ft(ft_matrix,det,tune) return end subroutine nonlin_map_calc