subroutine readtrrun(lunit,ntid) * * Read TR_RFA data files * This method of reading the files * gets read errors if the column fields * are not of equal width. * The nt/read method does not. * This loop method also suffers from * the 132-character record limit. *2 January jac * integer lunit,nrec,ndata * vector vec real rr character*3 str3 character*8 str8 character*6 str character*20 str20 character*30 str30 integer ii * * print *,' READTRRUN called with LUNIT,NTID=',lunit,ntid * Read single real numbers nrec=0 ndata=0 10 continue read(lunit,*,err=100,end=900)str20 nrec=nrec+1 ndata=ndata+1 * print *,' nrec,str20',nrec,str20 * conditions file if (str20(1:5).eq.'CONDX')then read(lunit,*,err=100,end=900)ii nrec=nrec+1 vec(6)=ii endif * lattice/beamenergy if (str20(1:7).eq.'LATTICE')then read(lunit,*,err=100,end=900)str20 nrec=nrec+1 vec(7)=0. if (str20(5:8).eq.'4000')vec(7)=4. * Correct mistake in data files of 12/15/2010 if (str20(5:8).eq.'4500')vec(7)=4. if (str20(1:5).eq.'CHESS')vec(7)=5.3 if (str20(5:8).eq.'2085')vec(7)=2.085 endif * location if (str20(1:8).eq.'LOCATION')then read(lunit,'(a4,i1)',err=100,end=900)str,ii nrec=nrec+1 vec(8)=ii endif * bias if (str20(1:4).eq.'BIAS')then read(lunit,*,err=100,end=900)rr nrec=nrec+1 vec(9)=rr endif * delay if (str20(1:5).eq.'DELAY')then read(lunit,*,err=100,end=900)rr nrec=nrec+1 vec(10)=rr endif * hrange if (str20(1:2).eq.'H '.or.str20(1:5).eq.'H ')then read(lunit,*,err=100,end=900)rr nrec=nrec+1 vec(11)=rr endif * vscale if (str20(1:2).eq.'V '.or.str20(1:5).eq.'V ')then read(lunit,*,err=100,end=900)rr nrec=nrec+1 vec(12)=rr endif * avcount if (str20(1:3).eq.'AVG')then read(lunit,*,err=100,end=900)ii nrec=nrec+1 vec(13)=ii endif * number of bunches if (str20(1:4).eq.'NBKT')then read(lunit,*,err=100,end=900)ii nrec=nrec+1 vec(14)=ii endif * spacing if (str20(1:7).eq.'SPACING')then read(lunit,*,err=100,end=900)rr nrec=nrec+1 vec(15)=rr endif * positron current if (str20(1:3).eq.'POS')then read(lunit,*,err=100,end=900)ii nrec=nrec+1 vec(16)=ii/100. endif * electron current if (str20(1:3).eq.'ELE')then read(lunit,*,err=100,end=900)ii nrec=nrec+1 vec(17)=ii/100. endif * chicane current if (str20(1:4).eq.'CHIC')then read(lunit,*,err=100,end=900)ii nrec=nrec+1 vec(18)=ii endif if(nrec.le.50)goto 10 100 continue nrec=nrec+1 2000 format(1x,a4) * if(nrec.le.10)print *, ' Error found in record ',nrec if(nrec.le.50)goto 10 900 continue *====================================================================== c Reread file searching for two strings and an integer rewind lunit nrec=0 ndata=0 20 continue * read(lunit,'(a3, a8,i4)',err=200,end=910)str3,str8,ii read(lunit,'(a5,a8,i4)',err=200,end=910)str20,str30,ii * read(lunit,'(a13)',err=200,end=910)str20 nrec=nrec+1 ndata=ndata+1 * print *,'str20',str20(1:4) * print *,'str30',str30(1:5) * CSR HBUMPING and VBUMPING if (str20(1:4).eq.' CSR')then read(lunit,*,err=200,end=910)jj if (str30(1:5).eq.'HBUMP')then nrec=nrec+1 vec(19)=ii vec(20)=jj elseif (str30(1:5).eq.'VBUMP')then nrec=nrec+1 vec(21)=ii vec(22)=jj endif endif if(nrec.le.50)goto 20 200 continue nrec=nrec+1 * if(nrec.le.10)print *, ' Error found in record ',nrec if(nrec.le.50)goto 20 *====================================================================== c Reread file searching for two strings rewind lunit nrec=0 ndata=0 30 continue read(lunit,'(a5,a8,i4)',err=300,end=910)str20,str30 nrec=nrec+1 ndata=ndata+1 * print *,'str20',str20(1:4) * print *,'str30',str30(1:5) * CSR CERN current if (str20(1:4).eq.' CSR' .and. str30(1:4).eq.'CERN')then read(lunit,*,err=300,end=910)jj *Calibration according to JPS e-mail of 4/15/2014 if(iy.le.2013.and.im.lt.12)then vec(8)=(jj/1000.+0.408)*.954 else vec(8)=(jj/1000.+0.428)*.954 endif * Truncate at 0.01 mA jj=int(vec(8)*100+0.5) vec(8)=real(jj)/100. endif if(nrec.le.50)goto 30 300 continue nrec=nrec+1 * if(nrec.le.10)print *, ' Error found in record ',nrec if(nrec.le.50)goto 30 910 continue * * Now load ntuple if(ntid.gt.0.and.vec(1).ge.2010..and.vec(1).le.2020)then call hfn(ntid,vec) endif * end