SUBROUTINE SFT(F,NPTS,NSPEC,AMP,PHI) C C This subroutine does a Fourier series transform on C the set of points F. C C Input: C C F Array of points for which the transform is to be taken. C The points must be equally spaced. C NPTS Number of points, must be odd. C C Output: C C NSPEC Number of harmonics to calculate. C AMP Array of amplitudes. C PHI Array of phase angles (radians). C C Note: If An are the coefficients of the cosine terms and C Bn are the coefficients of the sine terms then, AMP(n) = C SQRT( An*An + Bn*Bn ) & PHI(n) = ATAN2( An, Bn ). C DIMENSION F(NPTS), AMP(NSPEC), PHI(NSPEC) REAL nDXi DATA PI/3.14159265358979/, ROOTWO/1.41421356237310/ C DXi = 2.*Pi/(NPTS-1) NPTSM2 = NPTS-2 C DO 2000 n=1,NSPEC nDXi = n*DXi An = F(1) Bn = 0. C DO 1000 j=2,NPTSM2,2 An = An + 4.*F(j)*COS((j-1)*nDXi) + 2.*F(j+1)*COS(j*nDXi) 1000 Bn = Bn + 4.*F(j)*SIN((j-1)*nDXi) + 2.*F(j+1)*SIN(j*nDXi) An = An + 4.*F(NPTS-1)*COS((NPTS-2)*nDXi) + F(NPTS) Bn = Bn + 4.*F(NPTS-1)*SIN((NPTS-2)*nDXi) An = 2./(3.*(NPTS-1))*An Bn = 2./(3.*(NPTS-1))*Bn C AMP(n) = SQRT( An*An + Bn*Bn )/ROOTWO PHI(n) = 0. IF( AMP(n) .EQ. 0. ) GO TO 2000 PHI(n) = ATAN2( An, Bn ) 2000 CONTINUE C RETURN END