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

NAG FL Interface Introduction
Example description
    Program g03ebfe

!     G03EBF Example Program Text

!     Mark 30.0 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: g03ebf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: p
      Integer                          :: i, ifail, l, ldx, ldy, m, n
      Character (80)                   :: fmt
      Character (1)                    :: scal, stype, update
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: d(:,:), sx(:), sy(:), x(:,:), y(:,:)
      Integer, Allocatable             :: isv(:)
!     .. Executable Statements ..

      Write (nout,*) 'G03EBF Example Program Results'
      Write (nout,*)

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

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

!     Read in information on the type of distance matrix to use
      Read (nin,*) update, scal, stype

      ldx = m
      ldy = n
      Allocate (x(ldx,l),y(ldy,l),isv(l),sx(l),sy(l),d(m,n))

!     Read in the data for first matrix of observations
      Read (nin,*)(x(i,1:l),i=1,m)

!     Read in the data for second matrix of observations
      Read (nin,*)(y(i,1:l),i=1,n)

!     Read in variable inclusion flags
      Read (nin,*) isv(1:l)

!     Read in scaling
      If (scal=='G' .Or. scal=='g') Then
        Read (nin,*) sx(1:l)
        If (stype=='I' .Or. stype=='i') Then
          Read (nin,*) sy(1:l)
        End If
      End If

!     Compute the distance matrix
      ifail = 0
      Call g03ebf(update,scal,stype,p,m,n,l,x,ldx,isv,y,ldy,sx,sy,d,ifail)

!     Display results
      Write (nout,*) ' Distance Matrix'
      Write (nout,*)
      Write (fmt,99999) '(3X,', n, 'I8)'
      Write (nout,fmt)(i,i=1,n)
      Write (nout,*)
      Write (fmt,99999) '(1X,I2,2X,', n, '(3X,F5.2))'
      Do i = 1, m
        Write (nout,fmt) i, d(i,1:n)
      End Do


99999 Format (A,I0,A)
    End Program g03ebfe