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

NAG FL Interface Introduction
Example description
    Program s30acfe

!     S30ACF Example Program Text

!     Mark 30.3 Release. nAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: nag_wp, s30acf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, ifail, mode, n
      Character (1)                    :: calput
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: k(:), p(:), r(:), s0(:), sigma(:),   &
                                          t(:)
      Integer, Allocatable             :: ivalid(:)
!     .. Executable Statements ..
      Write (nout,*) 'S30ACF Example Program Results'

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

      Write (nout,*)
      Write (nout,*) '     SIGMA    IVALID'
      Write (nout,*)

      Read (nin,*) calput
      Read (nin,*) n, mode

      Allocate (p(n),k(n),s0(n),t(n),r(n),sigma(n),ivalid(n))

!     Read p, k, s0, t and r from data file
      Read (nin,*) p(1:n)
      Read (nin,*) k(1:n)
      Read (nin,*) s0(1:n)
      Read (nin,*) t(1:n)
      Read (nin,*) r(1:n)

!     Find the implied volatilities, sigma
      ifail = 0
      Call s30acf(calput,n,p,k,s0,t,r,sigma,mode,ivalid,ifail)

!     Print solution
      Do i = 1, n
        Write (nout,99999) sigma(i), ivalid(i)
      End Do

99999 Format (1X,E12.3,I5)
    End Program s30acfe