    PROGRAM nag_tsa_spectral_ex08

      ! Example Program Text for nag_tsa_spectral
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_tsa_spectral, ONLY : nag_bivar_spectral_cov
      USE nag_examples_io, ONLY : nag_std_out, nag_std_in
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC AIMAG, KIND, REAL
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, l, m, s
      REAL (wp) :: tap
      CHARACTER (1) :: method
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: xy_cov(:), yx_cov(:)
      COMPLEX (wp), ALLOCATABLE :: f_xy(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) &
       'Example Program Results for nag_tsa_spectral_ex08'

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) m, l, s
      READ (nag_std_in,*) tap
      READ (nag_std_in,*) method

      ALLOCATE (xy_cov(m),yx_cov(m),f_xy(l)) ! Allocate storage

      READ (nag_std_in,*) xy_cov
      READ (nag_std_in,*) yx_cov

      CALL nag_bivar_spectral_cov(method,xy_cov,yx_cov,f_xy,s=s,tap=tap)

      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) '                 Returned sample spectrum'
      WRITE (nag_std_out,*)
      WRITE (nag_std_out,*) &
       '       Real  Imaginary       Real  Imaginary       Real  Imaginary'
      WRITE (nag_std_out,*) &
       ' Lag   part     part   Lag   part     part   Lag   part     part'
      WRITE (nag_std_out,'((3(I4,2F9.4)))') (i-1,REAL(f_xy(i)),AIMAG(f_xy(i)), &
       i=1,l)

      DEALLOCATE (xy_cov,yx_cov,f_xy) ! Deallocate storage

    END PROGRAM nag_tsa_spectral_ex08
