* S30SAF Example Program Text * Mark 22 Release. NAG Copyright 2008. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER LDP, MMAX, NMAX PARAMETER (LDP=50,MMAX=50,NMAX=50) * .. Local Scalars .. DOUBLE PRECISION B, 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 S30SAF * .. Executable Statements .. WRITE (NOUT,*) 'S30SAF Example Program Results' WRITE (NOUT,*) WRITE (NOUT,*) 'Asian Option: Geometric Continuous Average-Rate' * Skip heading in data file READ (NIN,*) * Read problem parameters. READ (NIN,*) PUT READ (NIN,*) S, SIGMA, R, B 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 S30SAF(PUT,M,N,X,S,T,SIGMA,R,B,P,LDP,IFAIL) * IF (IFAIL.EQ.0) THEN * IF (PUT.EQ.'C' .OR. PUT.EQ.'c') THEN WRITE (NOUT,*) 'Asian Call :' ELSE IF (PUT.EQ.'P' .OR. PUT.EQ.'p') THEN WRITE (NOUT,*) 'Asian 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)') ' Cost of carry = ', B 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,' ** S30SAF returned with IFAIL = ',I5) END