SUBROUTINE FILTER(X,NP,CUT,H,N.K,WGT) 

 C GENERAL ROUTINE TO' HIGH OR LOW PASS A SET OF EQUALLY 

 C SPACED DATA USING MARTIN FILTERS. 



C X=INPUT DATA AND OUTPUT DATA,NP=NO.OF POINTS IN X,CUT=NORMALIZED 

 C CUTOFF OF FILTER IN CYCLES/DATA INTERVAL, H=SLOPE PARAMETER, 

 CN=HALF LENGTH OF FILTER, TOTAL LENGTH=2N+1, 

 C K=1=HIGH PASS,=0 FOR LOW PASS. 

 C WEIGHTS STORED IN WGT 



DIMENSION X(1),WGT(1) 



NA=N+1 



WGT(1)=2.0*(CUT+H) 

 C CENTER WEIGHT STORED IN LOCATION 1 



SUM=0.0 



PI=3. 1415925 



DO 61 I=2,NA 



P=I-1 



Q=1.0-16.0*H**2*P**2 



IF (ABS(Q).GT. 0.0001) GO TO 62 



WGT(I)=SIN(2.*PI*P*(CUT+H))/(4.0*P) 



GO TO 61 



62 WGT(I)=((C0S(2.*PI*P*H))/Q)*((SIN(2.*PI*P*(CUT+H)))/(PI*P)) 

 61 SUM=SUM+WGT(I) 



DELTA=1.-(WGT(1)+2.*SUM) 

 AX=2*N+1 



IF(K.LT.l) GO TO 78 

 DO 65 1=2, NA 

 65 WGT(I)=(WGT(I)+DELTA/AX)*(-1.0) 

 WGT(1)=1.0-(WGT(1)+DELTA/AX) 

 GO TO 79 



78 DO 80 I=1,NA 



80 WGT(I)=WGT(I)+DELTA/AX 



79 NB=NP-N 



C CONVOLVE WEIGHTS WITH DATA. 

 DO 63 I=NA,NB 

 II=I+1-NA 

 SUM=0.0 

 DO 64 J=1,NA 

 J1=I+J-1 

 J2=I-J+1 

 64 SUM=SUM+WGT(J)*(X(J1)+X(J2)) 



63 X{II)=SUM-WGT(1)*X(I) 



C SHIFT FILTERED DATA TO CORRECT LOCATION AND ZERO ENDS. 

 II=NB+1-NA 

 DO 67 1=1,11 

 J=II+1-I 

 L=J+N 



67 X(L)=X(J) 

 DO 68 I=1,N 



68 X(I)=0.0 

 NC=NB+1 



DO 69 I=NC,NP 



69 X(I)=0.0 

 RETURN 

 END 



171 



