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

NAG FL Interface Introduction
Example description
    Program g13cefe

!     G13CEF Example Program Text

!     Mark 30.0 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: g13cef, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: t
      Integer                          :: i, ifail, j, ng
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: ca(:), calw(:), caup(:), sc(:),      &
                                          sclw(:), scup(:), xg(:), xyig(:),    &
                                          xyrg(:), yg(:)
      Real (Kind=nag_wp)               :: stats(4)
!     .. Executable Statements ..
      Write (nout,*) 'G13CEF Example Program Results'
      Write (nout,*)

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

!     Read in the problem size
      Read (nin,*) ng

!     Read in statistics
      Read (nin,*) stats(1:4)

      Allocate (xg(ng),yg(ng),xyrg(ng),xyig(ng),ca(ng),calw(ng),caup(ng),      &
        sc(ng),sclw(ng),scup(ng))

!     Read in data
      Read (nin,*)(xg(i),yg(i),xyrg(i),xyig(i),i=1,ng)

!     Calculate cross-amplitude spectrum
      ifail = -1
      Call g13cef(xg,yg,xyrg,xyig,ng,stats,ca,calw,caup,t,sc,sclw,scup,ifail)
      If (ifail/=0) Then
        If (ifail<2) Then
          Go To 100
        End If
      End If

!     Display results
      Write (nout,*) '      Cross amplitude spectrum'
      Write (nout,*)
      Write (nout,*) '                    Lower     Upper'
      Write (nout,*) '          Value     bound     bound'
      Write (nout,99999)(j-1,ca(j),calw(j),caup(j),j=1,ng)
      Write (nout,*)
      Write (nout,99998) 'Squared coherency test statistic =', t
      Write (nout,*)
      Write (nout,*) '         Squared coherency'
      Write (nout,*)
      Write (nout,*) '                    Lower     Upper'
      Write (nout,*) '          Value     bound     bound'
      Write (nout,99999)(j-1,sc(j),sclw(j),scup(j),j=1,ng)

100   Continue

99999 Format (1X,I5,3F10.4)
99998 Format (1X,A,F12.4)
    End Program g13cefe