CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C C SUBROUTINE F I E L D R C C C C PURPOSE: READS MAGNETIC FIELD VALUES FOR PARTICLE TRACKING C C FOR A TOROIDAL MAGNET C C C C WRITTEN BY: B.A.M. C C C C DATE: 14-AUG-85 C C C C CHANGES: WHAT WHO WHEN C C Unix Compatible Version BAM 05/11/00 C C C C C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C 1 2 3 4 5 6 7 8 C2345678901234567890123456789012345678901234567890123456789012345678901234567890 C SUBROUTINE FIELD(X,B,RI,CHAR,P,FAC,IOUT,ICONT) DIMENSION B(3),X(3),RI(3) DIMENSION XX(0:200),YY(0:200) CHARACTER*10 FNAME CHARACTER*5 TEXT(15) C C X COORDINATE C B MAGNETIC FIELD IN TESLA C RI INVERSE RADIUS IN M**(-1) C CHAR CHARGE IN UNITS OF E C P MOMENTUM IN GEV/C C FAC COMMON FACTOR FOR THE MAGNETIC FIELD C ICONT CONTROLLING THE FUNCTION OF THE SUBROUTINE C GOTO(100,200,300),ICONT C 100 CONTINUE PI=P IF(IREAD.EQ.1) RETURN C C DO 110 II=1,2*IOUT C READ(1,1002) FNAME C WRITE(5,1013) II,FNAME C110 CONTINUE IF((IREAD.EQ.1).AND.(IOUT.EQ.0)) RETURN C READ(1,1002) FNAME C WRITE(5,1011) FNAME FNAME='btoro.dat' print*,'open b-field file:',FNAME OPEN(UNIT=1,ACCESS='SEQUENTIAL',STATUS='OLD',FILE=FNAME) DO 101 I=1,3 READ(1,1012) (TEXT(II),II=1,15) IF(TEXT(2).EQ.' R[M]') GOTO 102 101 CONTINUE 102 CONTINUE C C K-LOOP: LOOPS THROUGH RADIAL POSITIONS TO READ MAGNETIC FIELD VALUES IMAX=200 DO 11 K=0,IMAX READ(1,1001,ERR=12) DUM1,DUM2,XXK,DUM3,YYK C WRITE(3,2001) K,XXK,YYK C WRITE(6,2001) K,XXK,YYK IF((K.GT.1).AND.(XXK.LE.0.)) GOTO 12 XX(K)=XXK YY(K)=ABS(YYK) 11 CONTINUE C 12 IMAX=K-1 DR=XX(IMAX)-XX(IMAX-1) !STEPSIZE IF(INIT.NE.1) THEN WRITE(3,1100) IMAX,DR WRITE(6,1100) IMAX,DR 1100 FORMAT(/,' SR FIELDR read ',I3, 1 ' x, B(x) pairs with ',f8.3,' m stepsize ',/) INIT=1 ENDIF CLOSE(UNIT=1) IREAD=1 RETURN C 200 CONTINUE B(1)=0. B(2)=0. B(3)=0. RAD=SQRT(X(2)**2+X(3)**2) IF((RAD.GT.XX(IMAX)).OR.(RAD.LT.XX(1))) GOTO 201 RN=RAD/DR NR=IFIX(RN) BB=YY(NR)+(YY(NR+1)-YY(NR))*(RN-FLOAT(NR)) B(1)=0. B(2)=0. B(3)=BB 201 CONTINUE DO 1 I=1,3 RI(I)=B(I)*CHAR*.2997925/PI ! 1/R IN 1/METER 1 CONTINUE RETURN 300 CONTINUE RETURN 1001 FORMAT(3F10.4,2F12.6) 1002 FORMAT(A10) 1011 FORMAT(' SR FIELDR: READING INPUT FILE ',A10,/) 1012 FORMAT(15A5) 1013 FORMAT(' SR FIELDR: ',I3,2X,A10) 2001 FORMAT(' ',I5,8F10.4) 2012 FORMAT(' ',15A5) END