Program g01slfe
! G01SLF Example Program Text
! Mark 27.3 Release. NAG Copyright 2021.
! .. Use Statements ..
Use nag_library, Only: g01slf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, lk, ll, lm, ln, lout
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: peqk(:), pgtk(:), plek(:)
Integer, Allocatable :: ivalid(:), k(:), l(:), m(:), n(:)
! .. Intrinsic Procedures ..
Intrinsic :: max, mod, repeat
! .. Executable Statements ..
Write (nout,*) 'G01SLF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the input vectors
Read (nin,*) ln
Allocate (n(ln))
Read (nin,*) n(1:ln)
Read (nin,*) ll
Allocate (l(ll))
Read (nin,*) l(1:ll)
Read (nin,*) lm
Allocate (m(lm))
Read (nin,*) m(1:lm)
Read (nin,*) lk
Allocate (k(lk))
Read (nin,*) k(1:lk)
! Allocate memory for output
lout = max(ln,ll,lm,lk)
Allocate (pgtk(lout),plek(lout),peqk(lout),ivalid(lout))
! Calculate probability
ifail = -1
Call g01slf(ln,n,ll,l,lm,m,lk,k,plek,pgtk,peqk,ivalid,ifail)
If (ifail==0 .Or. ifail==1) Then
! Display titles
Write (nout,*) &
' N L M K PLEK PGTK ', &
'PEQK IVALID'
Write (nout,*) repeat('-',78)
! Display results
Do i = 1, lout
Write (nout,99999) n(mod(i-1,ln)+1), l(mod(i-1,ll)+1), &
m(mod(i-1,lm)+1), k(mod(i-1,lk)+1), plek(i), pgtk(i), peqk(i), &
ivalid(i)
End Do
End If
99999 Format (1X,4(I6,4X),3(F6.3,4X),I3)
End Program g01slfe