DO 8 J=NPP,INP 



8 DATA(J)=0.0 



9 AINP=INP 

 0ELR=1.0/AINP 

 DELK=(1.0/AINP)/GRIDKM 



C INP= TOTAL NO. OF DATA PTS.TO A POWER OF 2 



C DELR=NORMALIZED FREQUENCY INTERVAL IN CYCLES PER DATA INTERVAL 



WRITE(I0UT,50)DELR,INP,NP 

 50 FORMATC FREQ. INT = ' ,E8.3, ' POWER OF 2 DATA PTS = ',I6,' NO. OF INPUT 

 1 DATA PTS=',I6) 

 WRITE(I0UT,560)I0RGN 

 560 FORMATC ORIGIN FOR PHASE SPECTRUM IS INPUT PT.N0.',I4) 

 C NOW STORE DATA IN COMPLEX FORM IN ADATA 



53 DO 2 J=1,INP 

 I=(J*2)-1 

 ADATA(I)=DATA(J) 

 IA=I+1 

 2 ADATA(IA)=0.0 

 C COMPUTE AND PLOT NORMALIZED AMPLITUDE SPECTRUM 



CALL NLOGN(M, ADATA, -1.0) 

 INX=INP+1 



IF(K0UNT-2) 301,301,302 

 C CORRECT FFT OF PREWHITENING FILTER FOR PHASE SHIFT 



302 ANN=N(1) 



CALL TSHIFT(M, ADATA, ANN, DELR) 



DO 303 I=1,INX,2 



JX=(I+l)/2 



J=I+1 



BDATA(JX)=(SQRT(ADATA(I)**2+ADATA(J)**2))*ANCR.^ 



IF(ADATA(I).LT.O.O) BDATA( JX )=-BDATA( JX ) 



303 CONTINUE 

 60 TO 204 



301 DO 201 I=1,INX,2 



JX=(I+l)/2 



J=I+1 

 201 BDATA(JX)=( SQRT(ADATA(I )**2 +ADATA( J)**2))*AN0RM 

 C COMPUTE ROUGH PHASE SPECTRUM FROM PREWHITENED DATA 

 C OR COSINE TAPERED DATA 



IF(KPHA.EQ.l.AND.N(l).LE.O) GO TO 567 



IF(KPHA.EQ.1.AND.K0UNT.EQ.2) GO TO 567 



GO TO 568 

 567 ANN=I0RGN-1 

 C CORRECT PHASE SPECTRUM FOR DESIRED ORIGIN 



CALL TSHIFT(M, ADATA, ANN, DELR) 



DO 569 I=1,INX,2 



JX=(I+l)/2 



B=JX-1 



B=B*0ELR*360.0 



J=I+1 



IF(ABS (ADATA( I ) ) .LT. l.E-20) ADATA( I )=ADATA( I )+l.E-20 



PHASE(JX)=(ATAN2(ADATA(J),ADATA(I)))*57. 295779 

 569 IF(IPHA.GT.O.AND.B.GT.O)PHASE(JX)=PHASE(JX)/B 



IF(IPHA.GT.O) GO TO 541 



