* S30AAF Example Program Text * Mark 22 Release. NAG Copyright 2007. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER LDP, MMAX, NMAX PARAMETER (LDP=50,MMAX=50,NMAX=50) * .. Local Scalars .. DOUBLE PRECISION Q, R, S, SIGMA INTEGER I, IFAIL, J, M, N CHARACTER PUT * .. Local Arrays .. DOUBLE PRECISION P(LDP,NMAX), T(NMAX), X(MMAX) * .. External Subroutines .. EXTERNAL S30AAF * .. Executable Statements .. WRITE (NOUT,*) 'S30AAF Example Program Results' WRITE (NOUT,*) WRITE (NOUT,*) 'Black-Scholes-Merton formula' * Skip heading in data file READ (NIN,*) * Read problem parameters. READ (NIN,*) PUT READ (NIN,*) S, SIGMA, R, Q READ (NIN,*) M, N * IF (M.LE.MMAX .AND. N.LE.NMAX) THEN * Read array of strike/exercise prices, X READ (NIN,*) (X(I),I=1,M) READ (NIN,*) (T(I),I=1,N) * IFAIL = 1 * CALL S30AAF(PUT,M,N,X,S,T,SIGMA,R,Q,P,LDP,IFAIL) * IF (IFAIL.EQ.0) THEN IF (PUT.EQ.'C' .OR. PUT.EQ.'c') THEN WRITE (NOUT,*) 'European Call :' ELSE IF (PUT.EQ.'P' .OR. PUT.EQ.'p') THEN WRITE (NOUT,*) 'European Put :' END IF WRITE (NOUT,'(A,1X,F8.4)') ' Spot = ', S WRITE (NOUT,'(A,1X,F8.4)') ' Volatility = ', SIGMA WRITE (NOUT,'(A,1X,F8.4)') ' Rate = ', R WRITE (NOUT,'(A,1X,F8.4)') ' Dividend = ', Q * WRITE (NOUT,*) WRITE (NOUT,*) ' Strike Expiry Option Price' * DO 40 I = 1, M DO 20 J = 1, N WRITE (NOUT,99999) X(I), T(J), P(I,J) 20 CONTINUE 40 CONTINUE ELSE WRITE (NOUT,*) WRITE (NOUT,99998) IFAIL END IF END IF * 99999 FORMAT (1X,2(F9.4,1X),6X,F9.4) 99998 FORMAT (1X,' ** S30AAF returned with IFAIL = ',I5) END