program g2tracking_test use bmad implicit none type (lat_struct), target:: lat, low_e_lat,high_e_lat, matchlat type (lat_struct) latb type (branch_struct), pointer :: branch ! ring type (branch_struct), pointer:: from_branch ! injection line type (ele_struct), pointer :: fork_ele type (ele_struct) ele_at_s, ele_save type (ele_struct), pointer :: lord_ele type (ele_struct), allocatable :: ele_time_bins(:) type (coord_struct), allocatable :: from_orbit(:) type (coord_struct), allocatable, save :: co(:), all_orb(:) type (coord_struct), allocatable :: coSteps(:),co_electron(:) type (coord_struct), allocatable :: low_e_orb(:), high_e_orb(:) type (coord_struct) to_orbit type (coord_struct) start_orb, orb_at_s, co_start, co_end type (coord_struct) opt_orb type (coord_struct) co_muon_end type (coord_struct) co_elec_end type (em_field_struct) field type (track_struct) track integer pgopen, istat1, istat2 integer lun,lun32 integer nargs, iargc, ios integer end, nturns, nmuons, nmuon_first integer unit integer status/0/ integer datetime_values(8) integer system real(rp), allocatable :: NN(:) real(rp) muon_lifetime character*120 line, lat_file, lat_file_name/''/,new_file/' '/, muon_file/' '/ character*120 string ! character*16 ele_name character*16 date, time, zone logical itexists ! real(rp), dimension(100) :: fnal_w_integral real(rp) start, finish ! character*16 epsdistr, tdistr, pzdistr, inf_aperture, twiss_ref, ring_twiss, character*16 input_call/''/ character*16 directory namelist /input/ lat_file_name, nmuons, nturns call cpu_time(start) call date_and_time(date,time,zone,datetime_values) print '(a10,a10,a1,a10)',' date = ',date,' time = ', time directory = trim(date)//'_'//trim(time(1:6)) status= system('mkdir ' // directory) if(status == 0)print '(a20,a)',' create directory = ', trim(directory) OPEN (UNIT=5, FILE='g2test_input.dat', STATUS='old', IOSTAT=ios) READ (5, NML=input, IOSTAT=ios) print *, 'ios=', ios rewind(unit=5) ! READ (5, NML=input) CLOSE(5) if(input_call /= '')then open(unit=5,file=input_call, status='old', iostat=ios) read(5,nml=input, iostat=ios) string = 'cp '//input_call//' '//trim(directory)//'/.' call execute_command_line(string) endif OPEN (UNIT=5, FILE='input.dat', STATUS='old', IOSTAT=ios) lun=lunget() open(unit=lun, file=trim(directory)//'/input.dat') do while(ios == 0) read(5,'(a)', IOSTAT=ios)string if(ios == 0)write(lun,'(a)')string end do close(unit=lun) WRITE(6,NML=input) print '(a,es16.8)',' muon anomalous magnetic moment = ', anomalous_moment_of(antimuon$) print '(a,es15.8)',' anomalous moment of muon ',anomalous_moment_of(antimuon$) !if (spin_tracking_on) bmad_com%spin_tracking_on = .true. lat_file = lat_file_name string = 'cp'//' '//trim(lat_file)//' '//trim(directory)//'/.' print *,string call execute_command_line(string) inquire(file='quad_plate_misalign.bmad' , exist=itexists) if(itexists)then string = 'cp'//' '//'quad_plate_misalign.bmad'//' '//trim(directory)//'/.' print *,string call execute_command_line(string) endif call bmad_parser (lat_file, lat) end