subroutine write_RD_out(directory, h_min,h_max,v_min,v_max,chis,Bpppp, Bpppp2,coeff, files_so_far, rd_files,type) use sim_utils use gain_fit_mod implicit none real(rp) h_max, h_min, v_max, v_min, chis real(rp) Bpppp, Bpppp2 real(rp) true_gain(1:4) real(rp) coeff(1:4) integer i integer, save :: lun26 integer files_so_far character*20 rd_files(20) character*100 out_file, type character*16 directory logical first/.true./ if(first)then out_file = trim(in_file_0)//'_out' lun26=lunget() open(lun26, file=trim(directory)//'/'//out_file) write(lun26,'(a7,i2,a1,a12, i2,a1)')'mfiles=',files_so_far,';', 'array file[',files_so_far,']' do i=1,files_so_far write(lun26,'(a5,i2,a3,a1,a,a1)') 'file[',i,']= ', '"',trim(rd_files(i)),'"' end do write(lun26, '(a,1x,i2,a,1x,a,a)')' gain_correct = ',gain_correct,',', trim(type), ' to tbt data' write(lun26,'(a7,11(a12),18x,a12,18x,a12,4x,2a12,18x,a12,18x)') & '! BPM ','h_min','h_max','h_max-h_min','v_min','v_max', & 'v_max-v_min',' gain(1)',' gain(2)',' gain(3)',' gain(4)','coeff','chis','name','button ave','rms but ave',' true_gain' first=.false. endif true_gain = orbit_data(1)%detector(bpm)%true_gain write(lun26, '(i7,11es12.4,4es12.4,4x,a12,4x,2es12.4, 4es12.4)')bpm, h_min,h_max,h_max-h_min,v_min,v_max,v_max-v_min, 1./gain, coeff, chis, bpm_names(bpm), & Bpppp/norbits, sqrt((Bpppp2- Bpppp**2/norbits)/norbits),true_gain return end subroutine write_RD_out