NAG Library Manual, Mark 28.4
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program g13bcfe

!     G13BCF Example Program Text

!     Mark 28.4 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use nag_library, Only: g13bcf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: r0xy, r0yx, statxy, statyx, sxy, syx
      Integer                          :: i, ifail, nl, nxy
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: rxy(:), ryx(:), x(:), y(:)
!     .. Executable Statements ..
      Write (nout,*) 'G13BCF Example Program Results'
      Write (nout,*)

!     Skip heading in data file
      Read (nin,*)

!     Read series length and number of lags
      Read (nin,*) nxy, nl

      Allocate (x(nxy),y(nxy),rxy(nl),ryx(nl))

!     Read series
      Read (nin,*) x(1:nxy)
      Read (nin,*) y(1:nxy)

!     Call routine to calculate cross correlations between X and Y
      ifail = 0
      Call g13bcf(x,y,nxy,nl,sxy,r0xy,rxy,statxy,ifail)

!     Call routine to calculate cross correlations between Y and X
      ifail = 0
      Call g13bcf(y,x,nxy,nl,syx,r0yx,ryx,statyx,ifail)

!     Display results
      Write (nout,*) '                           Between        Between'
      Write (nout,*) '                           X and Y        Y and X'
      Write (nout,*)
      Write (nout,99999) 'Standard deviation ratio', sxy, syx
      Write (nout,*)
      Write (nout,*) 'Cross correlation at lag'
      Write (nout,99999) '                       0', r0xy, r0yx
      Write (nout,99998)(i,rxy(i),ryx(i),i=1,nl)
      Write (nout,*)
      Write (nout,99997) 'Test statistic          ', statxy, statyx

99999 Format (1X,A,F10.4,F15.4)
99998 Format (21X,I4,F10.4,F15.4)
99997 Format (1X,A,F10.4,F15.4)
    End Program g13bcfe