program svd_test ! Track n turns ! write matrix x(n,i) where n is turns and i is detector 1:100 ! Then do svd and check singular values use bmad use nr implicit none type (lat_struct) lat type (ele_struct) ele type (coord_struct), allocatable :: orbit(:) type (coord_struct) start, end integer unit, number, m, n_turns/100/, i, ix, nargs character*19 file_name character*3 num character*140 lat_file character*120 line, last_line character*7 det_name character*3 bpm_name real(rp) matrix(100,100) nargs = cesr_iargc() if(nargs == 1)then call cesr_getarg(1,lat_file) print *, 'Using ', trim(lat_file) else lat_file = 'bmad.' type '(a,$)',' Lattice file name ? (default= bmad.) ' read(5,'(a)') line call string_trim(line, line, ix) lat_file = line if(ix == 0) lat_file = 'bmad.' type *, ' lat_file = ', lat_file endif call bmad_parser (lat_file, lat) call reallocate_coord(orbit,lat%n_ele_max) call twiss_at_start(lat) call twiss_propagate_all(lat) lat%z%tune = 0.05*twopi call set_z_tune(lat) call calc_z_tune(lat) start%vec =0 start%vec(1) = 0.001 start%vec(3) = 0.001 start%vec(6) = 0.001 do i =1,n_turns do m = 1, lat%n_ele_track call track1(start, lat%ele(m), lat%param, end) if(index(lat%ele(m)%name,'DET_')/= 0)then num = lat%ele(m)%name(5:7) if(num(3:3) /= 'W' .and. num(3:3)/= 'E')cycle if(num(1:1) == '0')read(num(2:2),'(i1)')number if(num(1:1) /= '0')read(num(1:2),'(i2)')number if(num(3:3) == 'E')number = 99-number if(i == 1)print '(i,1x,2a,i,1x,f10.4)',m,lat%ele(m)%name, num, number,end%vec(1) matrix(i,number) = end%vec(1) endif start=end enddo end do do m = 1, 99 write(11, '(20e12.4)')matrix(1:20,m) end do end