    Program g11sbfe

!     G11SBF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: g11sbf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, ifail, ip, ldx, n, ns
!     .. Local Arrays ..
      Integer, Allocatable             :: irl(:)
      Logical, Allocatable             :: x(:,:)
!     .. Executable Statements ..
      Write (nout,*) 'G11SBF Example Program Results'
      Write (nout,*)

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

      ldx = n
      Allocate (x(ldx,ip),irl(n))

!     Read in data
      Read (nin,*)(x(i,1:ip),i=1,n)

      ifail = 0
      Call g11sbf(ip,n,ns,x,ldx,irl,ifail)

!     Display results
      Write (nout,*) 'Frequency     Score pattern'
      Write (nout,*)
      Do i = 1, ns
        Write (nout,99999) irl(i), x(i,1:ip)
      End Do

99999 Format (1X,I5,12X,5(L2))
    End Program g11sbfe
