Program g01sbfe
! G01SBF Example Program Text
! Mark 27.3 Release. NAG Copyright 2021.
! .. Use Statements ..
Use nag_library, Only: g01sbf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, ldf, lout, lt, ltail
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: df(:), p(:), t(:)
Integer, Allocatable :: ivalid(:)
Character (1), Allocatable :: tail(:)
! .. Intrinsic Procedures ..
Intrinsic :: max, mod, repeat
! .. Executable Statements ..
Write (nout,*) 'G01SBF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the input vectors
Read (nin,*) ltail
Allocate (tail(ltail))
Read (nin,*) tail(1:ltail)
Read (nin,*) lt
Allocate (t(lt))
Read (nin,*) t(1:lt)
Read (nin,*) ldf
Allocate (df(ldf))
Read (nin,*) df(1:ldf)
! Allocate memory for output
lout = max(lt,ldf,ltail)
Allocate (p(lout),ivalid(lout))
! Calculate probability
ifail = -1
Call g01sbf(ltail,tail,lt,t,ldf,df,p,ivalid,ifail)
If (ifail==0 .Or. ifail==1) Then
! Display titles
Write (nout,*) ' TAIL T DF P IVALID'
Write (nout,*) repeat('-',47)
! Display results
Do i = 1, lout
Write (nout,99999) tail(mod(i-1,ltail)+1), t(mod(i-1,lt)+1), &
df(mod(i-1,ldf)+1), p(i), ivalid(i)
End Do
End If
99999 Format (5X,A1,2(4X,F6.2),4X,F6.3,4X,I3)
End Program g01sbfe