subroutine read_xbsm_gain(channel_gain,in_file) implicit none character*100 in_file_0/'3C-4_physical_order.calib'/ character*100 in_file, out_file character*2 subdir/'04'/ character*100 file,prefix character*200 string integer number integer iu/1/ real channel_gain(0:31) integer ios integer ix integer channel logical start_flag/.false./ prefix = '/nfs/acc/user/dlr/development9_linux/xbsm/' ! which data file to read print '(a,a,a,$)',' xbsm calibration file ? ',trim(in_file_0),' ' read(*,'(a)')string call string_trim(string,string,ix) if(ix /= 0 .and. ix /= len(string))in_file_0 = string print *,' ix = ', ix if(ix==4)then in_file_0 = in_file_0(1:4)//'_physical_order.calib' call string_trim(in_file_0, in_file_0, ix) in_file_0 = trim(prefix)//in_file_0(1:ix) endif in_file = in_file_0 print '(a,a)',' in_file = ', in_file ! open file print '(a)',in_file file = in_file open(unit=iu,file = file, type= "old", readonly, IOSTAT=ios ) if(ios /= 0)then if(ios == 6.or. ios == 29)print *,' File not found ' stop endif do read(iu,'(a)',IOSTAT=ios)string if(ios /= 0)exit read(string,*,iostat=ios)channel, channel_gain(channel-1) if(ios /= 0)then print '(a,a)',' Error reading string ',string stop endif end do channel_gain(:) = channel_gain(:)/10000. print '(a,i,a)',' read ', channel, ' channels' close(unit=iu) return end subroutine gain_correct(bunches,turns,adc, channel_gain) implicit none integer adc(0:31,0:4096,183) integer bunches, turns integer i,j real channel_gain(0:31) print '(10e12.4)',channel_gain do i=1,bunches do j=1,turns adc(0:31,j,i) = adc(0:31,j,i)*channel_gain(0:31) end do end do return end