subroutine write_lost_muons(n,s, orbit, ele_name,i) use bmad use parameters_bmad implicit none type (coord_struct) orbit integer, save :: lun33 integer n,i real(rp) s logical first/.true./ character*16 ele_name if(first)then lun33 = lunget() open(unit=lun33,file=trim(directory)//'/'//'lost_muons.dat') first = .false. write(lun33,'(a10,1x,11a12)')'muon','s','x','xp','y','yp','z','pz','element','turn','(x**2+y**2)**.5','time','state' endif if(n<0)then close(lun33) return endif write(lun33,'(i10,1x,7es12.4,1x,a12,1x,i10,1x,2es12.4,1x,a20)')n,s, orbit%vec,ele_name,i,sqrt(orbit%vec(1)**2+orbit%vec(3)**2),orbit%t, coord_state_name(orbit%state) return end