PROGRAM s30aafe ! S30AAF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : nag_wp, s30aaf ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: q, r, s, sigma INTEGER :: i, ifail, j, ldp, m, n CHARACTER (1) :: calput ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: p(:,:), t(:), x(:) ! .. Executable Statements .. WRITE (nout,*) 'S30AAF Example Program Results' ! Skip heading in data file READ (nin,*) READ (nin,*) calput READ (nin,*) s, sigma, r, q READ (nin,*) m, n ldp = m ALLOCATE (p(ldp,n),t(n),x(m)) READ (nin,*) (x(i),i=1,m) READ (nin,*) (t(i),i=1,n) ifail = 0 CALL s30aaf(calput,m,n,x,s,t,sigma,r,q,p,ldp,ifail) WRITE (nout,*) WRITE (nout,*) 'Black-Scholes-Merton formula' SELECT CASE (calput) CASE ('C','c') WRITE (nout,*) 'European Call :' CASE ('P','p') WRITE (nout,*) 'European Put :' END SELECT WRITE (nout,99998) ' Spot = ', s WRITE (nout,99998) ' Volatility = ', sigma WRITE (nout,99998) ' Rate = ', r WRITE (nout,99998) ' Dividend = ', q WRITE (nout,*) WRITE (nout,*) ' Strike Expiry Option Price' DO i = 1, m DO j = 1, n WRITE (nout,99999) x(i), t(j), p(i,j) END DO END DO 99999 FORMAT (1X,2(F9.4,1X),6X,F9.4) 99998 FORMAT (A,1X,F8.4) END PROGRAM s30aafe