      SUBROUTINE BNDPAS( X, N, DELTAT, FMIN, FMAX )

C     BAND-PASS FILTER OF A COMPLEX TIME SERIES
C     This version assumes time series was real and therefore
C     filters symmetically

      PARAMETER ( PI = 3.141592, ALPHA = 0.54 )
      COMPLEX X( * )

C     *** Compute indices for frequency band ***

      DELTAF = 1.0 / ( N * DELTAT )
      IMIN   = FMIN / DELTAF
      IMAX   = FMAX / DELTAF

C     ------ Quick exit if full band is passed:
      IF ( IMIN .LE. 1 .AND. IMAX .GE. N / 2 + 1 ) RETURN

C     *** Check N is a power of 2 ***

      IF ( N .LE. 0 )
     &   STOP 'FATAL ERROR in BNDPAS: N must be positive'

      NT = 2**( INT( LOG10( REAL( N ) ) / 0.30104 ) +1 )
      IF ( NT .NE. N )
     &   STOP 'FATAL ERROR in BNDPAS: N must be a power of 2'

C     *** Forward transform ***

      CALL CFFT( X, N, 1 )
      CALL CFFTSC( X, N )

C     *** Zero out-of-band components (Hanning window) ***

      DO I = 1, N/2 + 1

         IF ( I .GE. IMIN .AND. I .LE. IMAX ) THEN
            WEIGHT = ALPHA +
     &         ( 1.0 - ALPHA ) * COS( PI * ( I - 1 ) / ( IMAX - 1 ) )
            WEIGHT = 1.0   ! disable windowing
         ELSE
            WEIGHT = 0.0
         ENDIF

         X( I ) = WEIGHT * X( I )

         IF ( I .GT. 1 .AND. I .LT. N/2+1 )
     &                     X( N+2-I ) = WEIGHT * X( N+2-I )
      END DO

C     *** Transform back ***

      CALL CFFT( X, N, -1 )

      RETURN
      END
