PROGRAM g01hcfe ! G01HCF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : g01hcf, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: prob, rho INTEGER :: df, ierr, ifail CHARACTER (1) :: tail ! .. Local Arrays .. REAL (KIND=nag_wp) :: a(2), b(2) ! .. Executable Statements .. WRITE (nout,*) 'G01HCF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) ! Display titles WRITE (nout,*) ' A(1) B(1) A(2) B(2) & & DF RHO TAIL P' WRITE (nout,*) D_LP: DO ierr = 0 a(1:2) = 0.0_nag_wp b(1:2) = 0.0_nag_wp READ (nin,FMT='(a1)',ADVANCE='no',IOSTAT=ierr) tail ! Read parameter values SELECT CASE (tail) CASE ('l','L') READ (nin,*,IOSTAT=ierr) df, rho, b(1), b(2) CASE ('c','C') READ (nin,*,IOSTAT=ierr) df, rho, a(1), b(1), a(2), b(2) CASE ('u','U') READ (nin,*,IOSTAT=ierr) df, rho, a(1), a(2) CASE DEFAULT WRITE (nout,*) 'Invalid problem specification in data file' EXIT D_LP END SELECT IF (ierr/=0) THEN EXIT D_LP END IF ! Calculate probablity ifail = 0 prob = g01hcf(tail,a,b,df,rho,ifail) ! Display results SELECT CASE (tail) CASE ('l','L') WRITE (nout,99999,ADVANCE='no') '-Inf', b(1), '-Inf', b(2) CASE ('u','U') WRITE (nout,99998,ADVANCE='no') a(1), 'Inf', a(2), 'Inf' CASE ('c','C') WRITE (nout,99997,ADVANCE='no') a(1), b(1), a(2), b(2) END SELECT WRITE (nout,99996) df, rho, tail, prob END DO D_LP 99999 FORMAT (1X,2(A4,8X,E11.4,1X)) 99998 FORMAT (1X,2(E11.4,2X,A3,8X)) 99997 FORMAT (1X,4(E11.4,1X)) 99996 FORMAT (I3,1X,F7.4,2X,A1,2X,F8.4) END PROGRAM g01hcfe