program test_grid use bmad type (lat_struct) lat type (ele_struct) ele type (coord_struct), allocatable:: co(:) type(track_struct) track integer ix, i, j,k integer nargs,iargc integer lun character*140 lat_file character*120 line logical err/.false./ nargs = command_argument_count() if(nargs == 1)then call get_command_argument(1,lat_file) print *, 'Using ', trim(lat_file) else lat_file = 'bmad.' print '(a37,$)',' Lattice file name ? (default= bmad.) ' read(5,'(a)') line call string_trim(line, line, ix) lat_file = line if(ix == 0) lat_file = 'bmad.' print *, ' lat_file = ', lat_file endif call bmad_parser (lat_file, lat) call reallocate_coord(co,lat%n_ele_max) lun=lunget() print *,' lun = ', lun co(0)%vec=0. do i=1,lat%n_ele_track track%n_pt = -1 call track1(co(i-1),lat%ele(i),lat%param,co(i), track=track) print *,' track%n_pt = ', track%n_pt do k=1,track%n_pt write(lun,'(a,6es12.4,1x,2es12.4)')'track_orb',track%orb(k)%vec, track%orb(k)%s,track%orb(k)%t print '(a,6es12.4,2es12.4)','track_orb',track%orb(k)%vec, track%orb(k)%s,track%orb(k)%t end do print '(i10,1x,6es12.4,1x,es12.4)',i,co(i)%vec, lat%ele(i)%s end do close(unit=lun) end