subroutine read_cbpmii_button_gain(file,comments_list, table0_bpm_data, table1_bpm_data) use precision_def implicit none type range_struct real(rp) range(0:10) end type type button_gain_struct character*10 label type (range_struct) button(0:3) end type type (button_gain_struct) table0_bpm_data(0:120), table1_bpm_data(0:120) character*130 string, dir character*100 file character*13 label character*120 comments_list(100) character*4 bpm_name integer bpm,ix,i integer ix2 integer iu integer io integer com real(rp) temp(0:10) logical ok dir = '/nfs/acc/user/dlr/development9_linux/BPM_tbt_gain/summarize_gain/' iu=1 call read_string(' button gain file ? (DEF= cbpmii_gain_template.dat) ','cbpmii_gain_template.dat', file) print '(a130)' ,trim(dir)//trim(file) open(unit = iu, file = trim(dir)//trim(file), readonly) com=0 do read(iu,'(a)',IOSTAT=io)string if(io/= 0)exit if(index(string,'#')/= 0)then com = com + 1 comments_list(com) = string cycle endif ix = index(string,'[BPM_') ix2 = index(string,']')-2 if(ix /= 0)then if(ix+5 == ix2)read(string(ix+5:ix2),'(i1)')bpm if(ix+6 == ix2)read(string(ix+5:ix2),'(i2)')bpm if((ix+5 == ix2 .or. ix+6 == ix2) .and.string(ix2+1:ix2+1) == 'E')bpm = 99-bpm if(ix2>ix+6)then bpm_name(1:ix2+2-ix-5) = string(ix+5:ix2+1) print '(a)',bpm_name call bpm_name_to_number(bpm, bpm_name,ok) if(.not.ok)print '(2a)',' No template data for ',bpm_name endif print '(a,i)',string(1:20), bpm read(iu,*,IOSTAT=io)label, temp if(io /= 0)exit if(index(label,'.GAIN_TABLE_0')/= 0)then table0_bpm_data(bpm)%label = string(1:10) table0_bpm_data(bpm)%button(0)%range(0:10)=temp(0:10) ! print '(11f10.4)',table0_bpm_data(bpm)%button(0)%range(0:10) ! read(string(14:100),*) table0_bpm_data(bpm)%button(0)%range(0:10) ! print '(a13,11f10.4)',label, table0_bpm_data(bpm)%button(0)%range(0:10) do i=1,3 read(iu,*) table0_bpm_data(bpm)%button(i)%range ! print '(13x,11f10.4)', table0_bpm_data(bpm)%button(i)%range end do endif read(iu,*,IOSTAT = io)label, temp if(io /= 0)exit if(index(label,'.GAIN_TABLE_1')/= 0)then table1_bpm_data(bpm)%label = ' ' table1_bpm_data(bpm)%button(0)%range(0:10)=temp(0:10) ! print '(a13,11f10.4)',label, table1_bpm_data(bpm)%button(0)%range(0:10) do i=1,3 read(iu,*) table1_bpm_data(bpm)%button(i)%range ! print '(13x,11f10.4)', table1_bpm_data(bpm)%button(i)%range end do endif endif end do close(unit=iu) end subroutine