C ... $Id: REALFT.FOR 2.400 1996/10/24 21:25:12 BenH Release2_4 BenH $ C ... $Log: REALFT.FOR $ C ... Revision 2.400 1996/10/24 21:25:12 BenH C ... Release 2.4 of AERI applications for AERI01, at CART. C ... C ... Revision 2.300 1996/01/10 14:18:23 BenH C ... AERIAPPS.LIB, Release2_3 C ... C ... Revision 1.1 1995/08/21 21:08:36 BenH C ... Completed templates in all modules, and created first RCS files. C ... C**************************************************************************** C C PROGRAM: REALFT (Subroutine) C C PURPOSE: C To set up the working array for the computation of a C discrete Fourier transform. C C AERI SYSTEM SOFTWARE PACKAGE INFORMATION: C (C) COPYRIGHT UW/SSEC C ALL RIGHTS RESERVED C Space Science & Engineering Center C University of Wisconsin - Madison C C Contacts: Ben Howell, Bob Knuteson C C DESCRIPTION: C This subroutine is called by "FT2IFG" and by "FT2CXS" to compute C the Fourier transform of the specified array. This subroutine C sets up the data field for the transform, which is then computed C by the subroutine "FOUR1". C C ARGUMENTS: C DATA R*4 (i/o) Working array for the Fourier transform C N I*4 (input) Number of complex points in the working array C (N must be a power of 2!!) C ISIGN I*4 (input) Indicator for "direction" of Fourier transform C = 1 for discrete Fourier transform C = -1 for discrete inverse Fourier transform C (NOTE: eg. spectrum-to-interferogram = inverse Fourier transform) C C EXTERNALS: C FOUR1 C C**************************************************************************** C SUBROUTINE REALFT(DATA,N,ISIGN) C C Calculates the Fourier Transform of a set of 2N real-valued data points. C Replaces this data (which is stored in array DATA) by the positive frequenc C half of its complex Fourier Transform. The real-valued first and last C components of the complex transform are returned as elements DATA(1) and C DATA(2) respectively. N must be a power of 2. This routine also calculate C the inverse transform of a complex data array if it is the transform of C real data. (Result in this case must be multiplied by 1/N) C NOTE: Array DATA must be dimensioned (2*N+2)! C REAL*8 WR,WI,WPR,WPI,WTEMP,THETA,DN DIMENSION DATA (*) C DN = FLOAT(N) THETA = 6.28318530717959D0/2.0D0/DN WR = 1.0D0 WI = 0.0D0 C1 = 0.5 IF (ISIGN .EQ. 1) THEN C2 = -0.5 CALL FOUR1(DATA,N,+1) DATA(2*N+1) = DATA(1) DATA(2*N+2) = DATA(2) ELSE C2 = 0.5 THETA = - THETA DATA(2*N+1) = DATA(2) DATA(2*N+2) = 0.0 DATA(2) = 0.0 ENDIF WPR = -2.0D0*DSIN(0.5D0*THETA)**2 WPI = DSIN(THETA) N2P3 = 2*N + 3 DO 11 I = 1, N/2+1 I1 = 2*I-1 I2 = I1 + 1 I3 = N2P3 - I2 I4 = I3 + 1 WRS = SNGL(WR) WIS = SNGL(WI) H1R = C1*(DATA(I1) + DATA(I3)) H1I = C1*(DATA(I2) - DATA(I4)) H2R = -C2*(DATA(I2) + DATA(I4)) H2I = C2*(DATA(I1) - DATA(I3)) DATA(I1) = H1R + WRS*H2R - WIS*H2I DATA(I2) = H1I + WRS*H2I + WIS*H2R DATA(I3) = H1R - WRS*H2R + WIS*H2I DATA(I4) = -H1I + WRS*H2I + WIS*H2R WTEMP = WR WR = WR*WPR - WI*WPI + WR WI = WI*WPR + WTEMP*WPI + WI 11 CONTINUE IF (ISIGN .EQ. 1) THEN DATA(2) = DATA(2*N+1) ELSE CALL FOUR1(DATA,N,-1) ENDIF RETURN END