Feb1.doc 1/2 File Function - A Lorentzian f x 1 x x0 1 w for\TLORENT.FOR cpp\BLILOREN.C The code for using the bli to produce a Lorentzian (is given in for\TLORENT.ZIP cpp\cloren.zip The output is for\loren.out but you need viw to find that x=0 is line 63 -19.8413 -15.8730 -11.9048 -7.93651 -3.96825 0.284217E-13 1.98413 3.96825 5.95238 7.93651 11.9048 2 0.597528E-03 0.867610E-03 0.137258E-02 0.249093E-02 0.583801E-02 0.262741E-01 0.128281 0.566860 0.500839E-01 0.160250E-01 0.454596E-02 Consider three items of interest. First the name Lorent in Fortran implies an integer. Second I found this by going to watfor. This implies that the code for\TLORENT.FOR has the line C$INCLUDE BLI This line is also included by Watcom which includes the subroutine bli twice. I used only 128 points in the above. The plot closer to the peak is This is a set of decidedly not equally spaced points. Linear interpolation The simplest interpolation scheme is based on the expansion f x (1.1) f A x f x0 x x0 x x x 0 Approximate f x f x1 f x0 (1.2) x x x x1 x0 0 So that this becomes f x1 f x0 f A x f x0 x x0 (1.3) x1 x0 This has the feature that is easy to rememeber and in addtion fA(x0)f(x0), fA(x1)f(x1) making fA(x) continuous if in all cases x0<=x<=x. In code that is f 43 f 42 f A x f 42 x x0 (1.4) 1.98413 0 x 1.98413 The function AlorenA(x) must have a part that looks at the file for\loren.out for a given x and returns the fact that x(63) <= x <= x(64). This is the locate routine. Locate.doc Addition to function in practice The practical function also needs to use static variables, ../Progdet/PANDA.mht#static_variables so that it can store data in along with code. These enable the function to read and organize its files on the first call for use on later calls. FUNCTION FUN1(X) DIMENSION XP(137),DP(137) SAVE NC,NDAT,XP,DP DATA NC/0/ Feb1.doc 5 IF(NC.EQ.0)THEN NC=1 OPEN(1,FILE=’loren.out’) NDAT=1 READ(1,*,ERR=10)XP(NDAT),DP(NDAT) NDAT=NDAT+1 IF(NDAT.LE.137)THEN GOTO 5 ELSE PRINT*,' FROM FUN1 NDAT > 137 ' READ(*,*)ITEST ENDIF NDAT=NDAT-1 ENDIF CALL LOCATE(X,XP,NDAT,J) FUN1=DP(J)+(X-XP(J))*(DP(J+1)2 DP(J))/(XP(J+1)-XP(J)) RETURN END 1/2