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

NAG FL Interface Introduction
Example description
    Program g05pxfe

!     G05PXF Example Program Text

!     Mark 27.2 Release. NAG Copyright 2021.

!     .. Use Statements ..
      Use nag_library, Only: g05kff, g05pxf, nag_wp, x04caf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: lseed = 1, nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: genid, i, ifail, lda, lstate, m, n,  &
                                          subid
      Character (1)                    :: init, side
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:,:)
      Integer                          :: seed(lseed)
      Integer, Allocatable             :: state(:)
!     .. Executable Statements ..
      Write (nout,*) 'G05PXF Example Program Results'
      Write (nout,*)
      Flush (nout)

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

!     Read in the base generator information and seed
      Read (nin,*) genid, subid, seed(1)

!     Initial call to initializer to get size of STATE array
      lstate = 0
      Allocate (state(lstate))
      ifail = 0
      Call g05kff(genid,subid,seed,lseed,state,lstate,ifail)

!     Reallocate STATE
      Deallocate (state)
      Allocate (state(lstate))

!     Initialize the generator to a repeatable sequence
      ifail = 0
      Call g05kff(genid,subid,seed,lseed,state,lstate,ifail)

!     Read in the problem size
      Read (nin,*) n, m

!     Read in control parameters
      Read (nin,*) side, init

      lda = m
      Allocate (a(lda,n))

!     Read in A if required
      If (init=='N' .Or. init=='n') Then
        Read (nin,*)(a(i,1:n),i=1,m)
      End If

!     Generate the random orthogonal matrix
      ifail = 0
      Call g05pxf(side,init,m,n,state,a,lda,ifail)

!     Display the results
      ifail = 0
      Call x04caf('General',' ',m,n,a,lda,'Random Matrix',ifail)

    End Program g05pxfe